Ejemplo n.º 1
0
 public static void Select(Object activeObject, Object[] selection)
 {
     if (IsSelectionChanged(selection))
     {
         RuntimeUndo.RecordSelection();
         m_activeObject = activeObject;
         SetObjects(selection);
         RuntimeUndo.RecordSelection();
     }
 }
Ejemplo n.º 2
0
 private void Update()
 {
     if (InputController.GetKeyDown(UndoKey) && InputController.GetKey(ModifierKey))
     {
         RuntimeUndo.Undo();
     }
     else if (InputController.GetKeyDown(RedoKey) && InputController.GetKey(ModifierKey))
     {
         RuntimeUndo.Redo();
     }
 }
Ejemplo n.º 3
0
        public static void Reset()
        {
            m_windows           = new List <RuntimeEditorWindow>();
            m_pointerOverWindow = null;
            m_activeWindow      = null;
            m_activeCameraIndex = 0;
            GameCameras         = null;
            SceneCameras        = null;
            m_isOpened          = false;
            m_isPlaying         = false;

            RuntimeSelection.objects = null;
            RuntimeUndo.Reset();
            RuntimeTools.Reset();
        }
Ejemplo n.º 4
0
        private void StartGame()
        {
            DestroyGame();

            m_editorObjects        = ExposeToEditor.FindAll(ExposeToEditorObjectType.EditorMode, true).Select(go => go.GetComponent <ExposeToEditor>()).OrderBy(exp => exp.transform.GetSiblingIndex()).ToArray();
            m_enabledEditorObjects = m_editorObjects.Where(eo => eo.gameObject.activeSelf).ToArray();
            m_editorSelection      = RuntimeSelection.objects;

            HashSet <GameObject> selectionHS       = new HashSet <GameObject>(RuntimeSelection.gameObjects != null ? RuntimeSelection.gameObjects : new GameObject[0]);
            List <GameObject>    playmodeSelection = new List <GameObject>();

            for (int i = 0; i < m_editorObjects.Length; ++i)
            {
                ExposeToEditor editorObj = m_editorObjects[i];
                if (editorObj.Parent != null)
                {
                    continue;
                }

                GameObject playmodeObj = Instantiate(editorObj.gameObject, editorObj.transform.position, editorObj.transform.rotation);

                ExposeToEditor playModeObjExp = playmodeObj.GetComponent <ExposeToEditor>();
                playModeObjExp.ObjectType = ExposeToEditorObjectType.PlayMode;
                playModeObjExp.SetName(editorObj.name);
                playModeObjExp.Init();

                ExposeToEditor[] editorObjAndChildren   = editorObj.GetComponentsInChildren <ExposeToEditor>(true);
                ExposeToEditor[] playModeObjAndChildren = playmodeObj.GetComponentsInChildren <ExposeToEditor>(true);
                for (int j = 0; j < editorObjAndChildren.Length; j++)
                {
                    if (selectionHS.Contains(editorObjAndChildren[j].gameObject))
                    {
                        playmodeSelection.Add(playModeObjAndChildren[j].gameObject);
                    }
                }

                editorObj.gameObject.SetActive(false);
            }

            bool isEnabled = RuntimeUndo.Enabled;

            RuntimeUndo.Enabled      = false;
            RuntimeSelection.objects = playmodeSelection.ToArray();
            RuntimeUndo.Enabled      = isEnabled;
            RuntimeUndo.Store();
        }
Ejemplo n.º 5
0
        private void DestroyGame()
        {
            if (m_editorObjects == null)
            {
                return;
            }

            OnDestoryGameOverride();

            ExposeToEditor[] playObjects = ExposeToEditor.FindAll(ExposeToEditorObjectType.PlayMode, true).Select(go => go.GetComponent <ExposeToEditor>()).ToArray();
            for (int i = 0; i < playObjects.Length; ++i)
            {
                ExposeToEditor playObj = playObjects[i];
                if (playObj != null)
                {
                    DestroyImmediate(playObj.gameObject);
                }
            }

            for (int i = 0; i < m_enabledEditorObjects.Length; ++i)
            {
                ExposeToEditor editorObj = m_enabledEditorObjects[i];
                if (editorObj != null)
                {
                    editorObj.gameObject.SetActive(true);
                }
            }


            bool isEnabled = RuntimeUndo.Enabled;

            RuntimeUndo.Enabled      = false;
            RuntimeSelection.objects = m_editorSelection;
            RuntimeUndo.Enabled      = isEnabled;
            RuntimeUndo.Restore();

            m_editorObjects        = null;
            m_enabledEditorObjects = null;
            m_editorSelection      = null;
        }