public void DestroyTrack()
        {
            GameObject gameObject = objectHandle.Get();

            if (gameObject == null)
            {
                return;
            }
            G.Sys.LevelEditor_.RemoveGameObjectSilent(gameObject);
        }
Ejemplo n.º 2
0
            private void AddOrRemove(ReferenceMap.Handle <GameObject> beforeHandle, ref ReferenceMap.Handle <GameObject> afterHandle, bool add)
            {
                LevelEditor    editor     = G.Sys.LevelEditor_;
                GameObject     gameObject = beforeHandle.Get();
                ZEventListener comp       = (!add) ? addedComponentHandle.Get() : ((ZEventListener)((object)null));

                if (!gameObject.HasComponent <LevelSettings>())
                {
                    editor.RemoveGameObjectSilent(gameObject);
                }
                if (add)
                {
                    comp = gameObject.AddComponent <ZEventListener>();
                    var choice = new MusicChoice();
                    if (gameObject.HasComponent <LevelSettings>())
                    {
                        choice.Choices.Add("Level", new MusicChoiceEntry(""));
                    }
                    if (gameObject.HasComponent <MusicTrigger>())
                    {
                        choice.Choices.Add("Trigger", new MusicChoiceEntry(""));
                    }
                    if (gameObject.HasComponent <MusicZone>())
                    {
                        choice.Choices.Add("Zone", new MusicChoiceEntry(""));
                    }
                    choice.WriteObject(comp);
                    if (componentBytes != null)
                    {
                        Serializers.BinaryDeserializer.LoadComponentContentsFromBytes(comp, null, componentBytes);
                    }
                    comp.enabled = false;
                }
                else if (comp)
                {
                    comp.Destroy();
                }
                if (gameObject.HasComponent <LevelSettings>())
                {
                    EditorPatches.NeedsRefresh = true;
                }
                if (!gameObject.HasComponent <LevelSettings>())
                {
                    editor.AddGameObjectSilent(ref afterHandle, gameObject, editor.WorkingLevel_.GetLayerOfObject(gameObject));
                }
                addedComponentHandle = (!add) ? default(ReferenceMap.Handle <ZEventListener>) : editor.ReferenceMap_.GetHandleOrNull(comp);
                gameObject.ForEachILevelEditorListenerInChildren(listener => listener.OnLevelEditorToolFinish());
                Events.StaticEvent <ObjectHadComponentAddedOrRemoved.Data> .Broadcast(new ObjectHadComponentAddedOrRemoved.Data(gameObject));

                if (!gameObject.HasComponent <LevelSettings>())
                {
                    editor.SelectObject(gameObject);
                }
            }
Ejemplo n.º 3
0
 internal GameObject Create()
 {
     Redo();
     return(Handle.Get());
 }