Esempio n. 1
0
 public void CullDeletedSceneObject(SceneObject so)
 {
     if (vDeleted.Find((x) => x == so) == null)
     {
         return;
     }
     so.Disconnect(true);
     vDeleted.Remove(so);
     so.RootGameObject.SetParent(null);
     so.RootGameObject.Destroy();
 }
Esempio n. 2
0
        // remove SO from scene.
        // bDestroy means that SO is actually deleted, otherwise just added
        // to internal Deleted set, so it can be recovered by undo.
        public void RemoveSceneObject(SceneObject so, bool bDestroy)
        {
            if (so.RootGameObject.IsDestroyed)
            {
                DebugUtil.Log(4, "[Scene.RemoveSceneObject] tried to remove SO but it is already destroyed.");
                if (vSelected.Contains(so))
                {
                    Deselect(so);
                }
                vObjects.Remove(so);
                return;
            }
            DebugUtil.Log(4, "[Scene.RemoveSceneObject] removing {0} (destroy: {1})", so.Name, bDestroy);

            if (vSelected.Contains(so))
            {
                Deselect(so);
            }
            vObjects.Remove(so);
            OnSceneChanged(so, SceneChangeType.Removed);
            so.Disconnect(bDestroy);

            if (so.RootGameObject != null)
            {
                if (bDestroy)
                {
                    SceneUtil.DestroySO(so);
                }
                else
                {
                    // add to deleted set
                    vDeleted.Add(so);
                    deleted_objects.AddChild(so.RootGameObject, true);
                    so.RootGameObject.SetVisible(false);
                }
            }
        }