2using System.Collections;
3using System.Collections.Generic;
36 if(
instance.OnSelectionChange !=
null)
47 if(
instance.OnRemovedFromSelection !=
null)
48 instance.OnRemovedFromSelection += del;
50 instance.OnRemovedFromSelection = del;
53 private List<GameObject> _gameObjects =
new List<GameObject>();
65 if(
instance.OnRemovedFromSelection !=
null)
73 if(
instance.OnSelectionChange !=
null )
94 if(
instance.OnRemovedFromSelection !=
null)
99 foreach(GameObject go
in selection)
102 if(
instance.OnSelectionChange !=
null )
103 instance.OnSelectionChange(selection);
111 if (!selection)
return;
122 if(
instance.OnSelectionChange !=
null)
123 instance.OnSelectionChange(
new List<GameObject>(){ go });
131 if(
instance._RemoveFromSelection(go))
133 if(
instance.OnRemovedFromSelection !=
null )
134 instance.OnRemovedFromSelection(
new List<GameObject>() { go } );
136 if(
instance.OnSelectionChange !=
null )
141 private static void UndoRedoPerformed()
143 if(
instance.OnSelectionChange !=
null )
154 if(
instance.OnSelectionChange !=
null )
158#region Implementation
160 private void _InitializeSelected(GameObject go)
166 private void _DeinitializeSelected(GameObject go)
168 var highlight = go.GetComponentsInChildren<pb_SelectionHighlight>();
170 if(highlight !=
null)
171 pb_ObjectUtility.Destroy(highlight);
176 private bool _AddToSelection(GameObject go)
178 if(go !=
null && !_gameObjects.Contains(go))
180 _InitializeSelected(go);
181 _gameObjects.Add(go);
188 private bool _RemoveFromSelection(GameObject go)
190 if(go !=
null && _gameObjects.Contains(go) )
192 pb_ObjectUtility.Destroy(go.GetComponentsInChildren<pb_SelectionHighlight>());
193 _gameObjects.Remove(go);
204 int count = _gameObjects.Count;
206 for(
int i = 0; i < count; i++)
207 _DeinitializeSelected(_gameObjects[i]);
209 _gameObjects.Clear();
static void AddRedoPerformedListener(Callback callback)
static void AddUndoPerformedListener(Callback callback)
static List< GameObject > gameObjects
A list of the currently selected GameObjects.
static void AddOnSelectionChangeListener(Callback< IEnumerable< GameObject > > del)
static void RemoveFromSelection(GameObject go)
static void AddOnRemovedFromSelectionListener(Callback< IEnumerable< GameObject > > del)
static void AddToSelection(GameObject go)
static void SetSelection(IEnumerable< GameObject > selection)
Callback< IEnumerable< GameObject > > OnSelectionChange
static GameObject activeGameObject
static void SetSelection(GameObject selection)
Callback< IEnumerable< GameObject > > OnRemovedFromSelection
static void OnExternalUpdate()