MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / BreakLinks

Method BreakLinks

Source/Editor/Modules/PrefabsModule.cs:179–218  ·  view source on GitHub ↗

Breaks any prefab links for the selected objects. Supports undo/redo.

()

Source from the content-addressed store, hash-verified

177 /// Breaks any prefab links for the selected objects. Supports undo/redo.
178 /// </summary>
179 public void BreakLinks()
180 {
181 // Skip in invalid states
182 if (!Editor.StateMachine.CurrentState.CanEditScene)
183 return;
184
185 // Get valid objects (the top ones, C++ backend will process the child objects)
186 var selection = Editor.SceneEditing.Selection.Where(x => x is ActorNode actorNode && actorNode.HasPrefabLink).ToList().BuildNodesParents();
187 if (selection.Count == 0)
188 return;
189
190 // Perform action
191 if (Editor.StateMachine.CurrentState.CanUseUndoRedo)
192 {
193 if (selection.Count == 1)
194 {
195 var action = BreakPrefabLinkAction.Break(((ActorNode)selection[0]).Actor);
196 Undo.AddAction(action);
197 action.Do();
198 }
199 else
200 {
201 var actions = new IUndoAction[selection.Count];
202 for (int i = 0; i < selection.Count; i++)
203 {
204 var action = BreakPrefabLinkAction.Break(((ActorNode)selection[i]).Actor);
205 actions[i] = action;
206 action.Do();
207 }
208 Undo.AddAction(new MultiUndoAction(actions));
209 }
210 }
211 else
212 {
213 for (int i = 0; i < selection.Count; i++)
214 {
215 ((ActorNode)selection[i]).Actor.BreakPrefabLink();
216 }
217 }
218 }
219
220 /// <summary>
221 /// Selects in Content Window the prefab asset used by the selected objects.

Callers

nothing calls this directly

Calls 6

BuildNodesParentsMethod · 0.80
WhereMethod · 0.80
BreakMethod · 0.80
AddActionMethod · 0.80
DoMethod · 0.45
BreakPrefabLinkMethod · 0.45

Tested by

no test coverage detected