示例#1
0
        public void Load()
        {
            if (!ConfirmationLoad.activeSelf)
            {
                ConfirmationLoad.SetActive(true);
                return;
            }

            RuntimeUndo.Purge();
            ExposeToEditor[] editorObjects = ExposeToEditor.FindAll(ExposeToEditorObjectType.EditorMode).Select(go => go.GetComponent <ExposeToEditor>()).ToArray();
            for (int i = 0; i < editorObjects.Length; ++i)
            {
                ExposeToEditor exposeToEditor = editorObjects[i];
                if (exposeToEditor != null)
                {
                    DestroyImmediate(exposeToEditor.gameObject);
                }
            }

            ConfirmationLoad.SetActive(false);
            if (m_sceneManager != null)
            {
                m_sceneManager.ActiveScene.Name = SaveFileName;
                m_sceneManager.LoadScene(m_sceneManager.ActiveScene, () =>
                {
                    SaveButton.interactable = false;
                });
            }
        }
示例#2
0
        public virtual void SelectAll()
        {
            IEnumerable <GameObject> filtered = Editor.IsPlaying ?
                                                ExposeToEditor.FindAll(Editor, ExposeToEditorObjectType.PlayMode) :
                                                ExposeToEditor.FindAll(Editor, ExposeToEditorObjectType.EditorMode);

            Editor.Selection.objects = filtered.ToArray();
        }
示例#3
0
        protected override void Awake()
        {
            base.Awake();

            IOC.Register <IRTE>(this);
            IOC.RegisterFallback(this);

            ExposeToEditor[] editorObjects = ExposeToEditor.FindAll(this, ExposeToEditorObjectType.Undefined, false).Select(go => go.GetComponent <ExposeToEditor>()).ToArray();
            for (int i = 0; i < editorObjects.Length; ++i)
            {
                editorObjects[i].ObjectType = ExposeToEditorObjectType.EditorMode;
            }

            Tools.SnappingMode          = SnappingMode.BoundingBox;
            IsOpened                    = !IsInPlayMode;
            PlaymodeStateChanged       += OnPlaymodeStateChanged;
            IsOpenedChanged            += OnIsOpenedChanged;
            Selection.SelectionChanged += OnRuntimeSelectionChanged;
            Tools.ToolChanged          += OnRuntimeToolChanged;
            Tools.PivotRotationChanged += OnPivotRotationChanged;
            Undo.UndoCompleted         += OnUndoCompleted;
            Undo.RedoCompleted         += OnRedoCompleted;
            Undo.StateChanged          += OnUndoRedoStateChanged;

            TransformPanel.SetActive(Selection.activeTransform != null);
            if (Prefabs != null && PrefabsPanel != null && PrefabPresenter != null)
            {
                Prefabs = Prefabs.Where(p => p != null).ToArray();
                for (int i = 0; i < Prefabs.Length; ++i)
                {
                    GameObject presenter = Instantiate(PrefabPresenter);
                    presenter.transform.SetParent(PrefabsPanel.transform);
                    presenter.transform.position   = Vector3.zero;
                    presenter.transform.localScale = Vector3.one;

                    InstantiatePrefab instantiatePrefab = presenter.GetComponentInChildren <InstantiatePrefab>();
                    if (instantiatePrefab != null)
                    {
                        instantiatePrefab.Prefab = Prefabs[i];
                    }
                    TakeSnapshot takeSnapshot = presenter.GetComponentInChildren <TakeSnapshot>();
                    if (takeSnapshot != null)
                    {
                        takeSnapshot.TargetPrefab = Prefabs[i];
                    }
                }
            }
        }
示例#4
0
        private void Awake()
        {
            Instance = this;

            ExposeToEditor[] editorObjects = ExposeToEditor.FindAll(ExposeToEditorObjectType.Undefined, false).Select(go => go.GetComponent <ExposeToEditor>()).ToArray();
            for (int i = 0; i < editorObjects.Length; ++i)
            {
                editorObjects[i].ObjectType = ExposeToEditorObjectType.EditorMode;
            }

            RuntimeTools.SnappingMode                      = SnappingMode.BoundingBox;
            RuntimeEditorApplication.IsOpened              = !IsInPlayMode;
            RuntimeEditorApplication.SceneCameras          = new[] { EditorCamera };
            RuntimeEditorApplication.PlaymodeStateChanged += OnPlaymodeStateChanged;
            RuntimeEditorApplication.IsOpenedChanged      += OnIsOpenedChanged;
            RuntimeSelection.SelectionChanged             += OnRuntimeSelectionChanged;
            RuntimeTools.ToolChanged          += OnRuntimeToolChanged;
            RuntimeTools.PivotRotationChanged += OnPivotRotationChanged;
            RuntimeUndo.UndoCompleted         += OnUndoCompleted;
            RuntimeUndo.RedoCompleted         += OnRedoCompleted;
            RuntimeUndo.StateChanged          += OnUndoRedoStateChanged;

            TransformPanel.SetActive(RuntimeSelection.activeTransform != null);
            if (Prefabs != null && PrefabsPanel != null && PrefabPresenter != null)
            {
                Prefabs = Prefabs.Where(p => p != null).ToArray();
                for (int i = 0; i < Prefabs.Length; ++i)
                {
                    GameObject presenter = Instantiate(PrefabPresenter);
                    presenter.transform.SetParent(PrefabsPanel.transform);
                    presenter.transform.position   = Vector3.zero;
                    presenter.transform.localScale = Vector3.one;

                    InstantiatePrefab instantiatePrefab = presenter.GetComponentInChildren <InstantiatePrefab>();
                    if (instantiatePrefab != null)
                    {
                        instantiatePrefab.Prefab = Prefabs[i];
                    }
                    TakeSnapshot takeSnapshot = presenter.GetComponentInChildren <TakeSnapshot>();
                    if (takeSnapshot != null)
                    {
                        takeSnapshot.TargetPrefab = Prefabs[i];
                    }
                }
            }
        }
示例#5
0
        public virtual void CreateScene()
        {
            RuntimeSelection.objects = null;
            RuntimeUndo.Purge();
            ExposeToEditor[] editorObjects = ExposeToEditor.FindAll(ExposeToEditorObjectType.EditorMode, false).Select(go => go.GetComponent <ExposeToEditor>()).ToArray();
            for (int i = 0; i < editorObjects.Length; ++i)
            {
                ExposeToEditor exposeToEditor = editorObjects[i];
                if (exposeToEditor != null)
                {
                    DestroyImmediate(exposeToEditor.gameObject);
                }
            }

            GameObject dirLight = new GameObject();

            dirLight.transform.rotation = Quaternion.Euler(50, -30, 0);
            dirLight.transform.position = new Vector3(0, 10, 0);
            Light lightComponent = dirLight.AddComponent <Light>();

            lightComponent.type = LightType.Directional;

            dirLight.name = "Directional Light";
            dirLight.AddComponent <ExposeToEditor>();

            GameObject camera = new GameObject();

            camera.name = "Main Camera";
            camera.transform.position = new Vector3(0, 0, -10);
            camera.AddComponent <Camera>();
            camera.tag = "MainCamera";
            camera.AddComponent <ExposeToEditor>();

            m_activeScene = ProjectItem.CreateScene("New Scene");

            if (SceneCreated != null)
            {
                SceneCreated(this, new ProjectManagerEventArgs(ActiveScene));
            }
        }
        public virtual void CreateScene()
        {
            RuntimeSelection.objects = null;
            RuntimeUndo.Purge();
            ExposeToEditor[] editorObjects = ExposeToEditor.FindAll(ExposeToEditorObjectType.EditorMode, false).Select(go => go.GetComponent <ExposeToEditor>()).ToArray();
            for (int i = 0; i < editorObjects.Length; ++i)
            {
                ExposeToEditor exposeToEditor = editorObjects[i];
                if (exposeToEditor != null)
                {
                    DestroyImmediate(exposeToEditor.gameObject);
                }
            }



            m_activeScene = ProjectItem.CreateScene("New Scene");

            if (SceneCreated != null)
            {
                SceneCreated(this, new ProjectManagerEventArgs(ActiveScene));
            }
        }
示例#7
0
        private void LateUpdate()
        {
            if (InputController._GetMouseButtonDown(0))
            {
                if (RuntimeTools.ActiveTool != null && RuntimeTools.ActiveTool != BoxSelection.Current)
                {
                    return;
                }

                if (!IPointerOverEditorArea)
                {
                    return;
                }

                if (RuntimeTools.IsViewing)
                {
                    return;
                }

                if (!RuntimeSelection.Enabled)
                {
                    return;
                }

                bool       rangeSelect = InputController._GetKey(RangeSelectKey);
                bool       multiselect = InputController._GetKey(MultiselectKey) || InputController._GetKey(MultiselectKey2) || rangeSelect;
                Ray        ray         = SceneCamera.ScreenPointToRay(InputController._MousePosition);
                RaycastHit hitInfo;

                //if (Physics.Raycast(ray, out hitInfo, float.MaxValue, LayerMask.value))
                if (Physics.Raycast(ray, out hitInfo, float.MaxValue))
                {
                    GameObject hitGO     = hitInfo.collider.gameObject;
                    bool       canSelect = CanSelect(hitGO);
                    if (canSelect)
                    {
                        hitGO = hitGO.GetComponentInParent <ExposeToEditor>().gameObject;
                        if (multiselect)
                        {
                            List <Object> selection;
                            if (RuntimeSelection.objects != null)
                            {
                                selection = RuntimeSelection.objects.ToList();
                            }
                            else
                            {
                                selection = new List <Object>();
                            }

                            if (selection.Contains(hitGO))
                            {
                                selection.Remove(hitGO);
                                if (rangeSelect)
                                {
                                    selection.Insert(0, hitGO);
                                }
                            }
                            else
                            {
                                selection.Insert(0, hitGO);
                            }
                            RuntimeSelection.Select(hitGO, selection.ToArray());
                        }
                        else
                        {
                            RuntimeSelection.activeObject = hitGO;
                        }
                    }
                    else
                    {
                        if (!multiselect)
                        {
                            RuntimeSelection.activeObject = null;
                        }
                    }
                }
                else
                {
                    if (!multiselect)
                    {
                        RuntimeSelection.activeObject = null;
                    }
                }
            }

            if (RuntimeEditorApplication.IsActiveWindow(this))
            {
                if (InputController._GetKeyDown(SelectAllKey) && InputController._GetKey(ModifierKey))
                {
                    IEnumerable <GameObject> filtered = RuntimeEditorApplication.IsPlaying ?
                                                        ExposeToEditor.FindAll(ExposeToEditorObjectType.PlayMode) :
                                                        ExposeToEditor.FindAll(ExposeToEditorObjectType.EditorMode);
                    RuntimeSelection.objects = filtered.ToArray();
                }
            }
        }