public void OnReassigning(object source, GOReassigningEventArgs e) { Reassign(e.GameObject, e.NewParent); }
public void Reassign(GameObject gameObject, GameObject newParent) { if (!IsInitialized) return; var oldParent = gameObject.ParentObject; // remove the game object from its old parrent if (gameObject.ParentObject != null) { gameObject.ParentObject.RemoveChild(gameObject); } else if (ObjectList.Contains(gameObject)) { ObjectList.Remove(gameObject); } else { Console.WriteLine("GameObjectManager reassign: game object not found in manager"); return; } // add the game object to its new parent if (newParent != null) { newParent.AddChild(gameObject); } else { ObjectList.Add(gameObject); } SelectedObject = gameObject; GOReassigningEventArgs e = new GOReassigningEventArgs(); e.GameObject = gameObject; e.NewParent = oldParent; }