private void OnItemsRemoving(object sender, ItemsCancelArgs e)
        {
            if (e.Items == null)
            {
                return;
            }

            if (!RuntimeEditorApplication.IsActiveWindow(this))
            {
                e.Items.Clear();
                return;
            }

            for (int i = e.Items.Count - 1; i >= 0; i--)
            {
                ProjectItem item = (ProjectItem)e.Items[i];
                if (m_project.IsStatic(item))
                {
                    e.Items.Remove(item);
                }
            }

            if (e.Items.Count == 0)
            {
                PopupWindow.Show("Can't remove folder", "Unable to remove folders exposed from editor", "OK");
            }
        }
        protected override void UpdateOverride()
        {
            base.UpdateOverride();
            if (RuntimeEditorApplication.IsActiveWindow(this))
            {
                if (InputController._GetKeyDown(RemoveKey))
                {
                    if (m_treeView.SelectedItem != null)
                    {
                        ProjectItem projectItem = (ProjectItem)m_treeView.SelectedItem;
                        if (projectItem.Parent == null)
                        {
                            PopupWindow.Show("Unable to Remove", "Unable to remove root folder", "OK");
                        }
                        else
                        {
                            PopupWindow.Show("Remove Selected assets", "You can not undo this action", "Delete", args =>
                            {
                                m_treeView.RemoveSelectedItems();
                            }, "Cancel");
                        }
                    }
                }
            }


            if (RuntimeEditorApplication.IsPointerOverWindow(this))
            {
                if (m_dragProjectItem != null)
                {
                    m_treeView.ExternalItemDrag(InputController._MousePosition);
                }
            }
        }
Exemple #3
0
        private void Update()
        {
            #if UNITY_EDITOR
            UnityEditorToolsListener.Update();
            #endif

            if (RuntimeTools.ActiveTool != null)
            {
                return;
            }


            bool isGameViewActive = RuntimeEditorApplication.IsActiveWindow(RuntimeWindowType.GameView);
            bool isLocked         = RuntimeTools.IsViewing || isGameViewActive;
            if (!isLocked)
            {
                if (InputController.GetKeyDown(ViewToolKey))
                {
                    RuntimeTools.Current = RuntimeTool.View;
                }
                else if (InputController.GetKeyDown(MoveToolKey))
                {
                    RuntimeTools.Current = RuntimeTool.Move;
                }
                else if (InputController.GetKeyDown(RotateToolKey))
                {
                    RuntimeTools.Current = RuntimeTool.Rotate;
                }
                else if (InputController.GetKeyDown(ScaleToolKey))
                {
                    RuntimeTools.Current = RuntimeTool.Scale;
                }

                if (InputController.GetKeyDown(PivotRotationKey))
                {
                    if (RuntimeTools.PivotRotation == RuntimePivotRotation.Local)
                    {
                        RuntimeTools.PivotRotation = RuntimePivotRotation.Global;
                    }
                    else
                    {
                        RuntimeTools.PivotRotation = RuntimePivotRotation.Local;
                    }
                }
                if (InputController.GetKeyDown(PivotModeKey) &&
                    !(InputController.GetKey(KeyCode.LeftControl) || InputController.GetKey(KeyCode.LeftShift)))
                {
                    if (RuntimeTools.PivotMode == RuntimePivotMode.Center)
                    {
                        RuntimeTools.PivotMode = RuntimePivotMode.Pivot;
                    }
                    else
                    {
                        RuntimeTools.PivotMode = RuntimePivotMode.Center;
                    }
                }
            }
        }
        protected override void UpdateOverride()
        {
            base.UpdateOverride();
            if (!RuntimeEditorApplication.IsPointerOverWindow(this))
            {
                return;
            }

            if (InputController.GetKeyDown(SelectAllKey))
            {
                if (InputController.GetKey(ModifierKey))
                {
                    if (RuntimeEditorApplication.IsActiveWindow(this))
                    {
                        m_treeView.SelectedItems = m_treeView.Items;
                    }
                }
            }

            if (RuntimeTools.SpawnPrefab == null)
            {
                return;
            }

            m_treeView.ExternalItemDrag(Input.mousePosition);

            if (Input.GetMouseButtonUp(0))
            {
                m_isSpawningPrefab = true;
                GameObject prefabInstance = RuntimeTools.SpawnPrefab.InstantiatePrefab(Vector3.zero, Quaternion.identity);
                prefabInstance.SetActive(true);

                ExposeToEditor exposeToEditor = prefabInstance.GetComponent <ExposeToEditor>();
                if (exposeToEditor == null)
                {
                    exposeToEditor = prefabInstance.AddComponent <ExposeToEditor>();
                }

                exposeToEditor.SetName(RuntimeTools.SpawnPrefab.name);
                RuntimeUndo.BeginRecord();
                RuntimeUndo.RecordSelection();
                RuntimeUndo.BeginRegisterCreateObject(prefabInstance);
                RuntimeUndo.EndRecord();

                bool isEnabled = RuntimeUndo.Enabled;
                RuntimeUndo.Enabled = false;
                RuntimeSelection.activeGameObject = prefabInstance;
                RuntimeUndo.Enabled = isEnabled;

                RuntimeUndo.BeginRecord();
                RuntimeUndo.RegisterCreatedObject(prefabInstance);
                RuntimeUndo.RecordSelection();
                RuntimeUndo.EndRecord();

                RuntimeTools.SpawnPrefab = null;
            }
        }
 protected override void UpdateOverride()
 {
     base.UpdateOverride();
     if (InputController.GetKeyDown(DuplicateKey) && InputController.GetKey(ModifierKey))
     {
         if (RuntimeEditorApplication.IsActiveWindow(m_projectResources))
         {
             DuplicateProjectResources();
         }
     }
 }
        private void Update()
        {
            if (!RuntimeEditorApplication.IsActiveWindow(RuntimeWindowType.GameView) && RuntimeEditorApplication.IsOpened)
            {
                return;
            }

            if (InputController.GetKeyDown(KeyCode.Return))
            {
                SwitchPlayer(m_current, 0.0f, true);
            }
            else if (InputController.GetKeyDown(KeyCode.Backspace))
            {
                SwitchPlayer(m_current, 0.0f, false);
            }
        }
Exemple #7
0
        protected override void UpdateOverride()
        {
            base.UpdateOverride();
            if (!RuntimeEditorApplication.IsActiveWindow(this) && !RuntimeEditorApplication.IsActiveWindow(RuntimeWindowType.SceneView))
            {
                return;
            }

            if (InputController.GetKeyDown(RemoveKey))
            {
                if (m_listBox.SelectedItem != null)
                {
                    PopupWindow.Show("Remove Selected assets", "You can not undo this action", "Delete", args =>
                    {
                        m_listBox.RemoveSelectedItems();
                    }, "Cancel");
                }
            }
        }
Exemple #8
0
        private void HandleInput()
        {
            if (RuntimeTools.AutoFocus)
            {
                do
                {
                    if (RuntimeTools.ActiveTool != null)
                    {
                        break;
                    }

                    if (m_autoFocusTransform == null)
                    {
                        break;
                    }

                    if (m_autoFocusTransform.position == SecondaryPivot.position)
                    {
                        break;
                    }

                    if (m_focusAnimation != null && m_focusAnimation.InProgress)
                    {
                        break;
                    }

                    Vector3 offset = (m_autoFocusTransform.position - SecondaryPivot.position);
                    SceneCamera.transform.position    += offset;
                    Pivot.transform.position          += offset;
                    SecondaryPivot.transform.position += offset;
                }while (false);
            }

            if (InputController._GetMouseButtonUp(0) ||
                InputController._GetMouseButtonUp(1) ||
                InputController._GetMouseButtonUp(2))
            {
                m_handleInput        = false;
                m_mouseOrbit.enabled = false;
                m_rotate             = false;
                SetCursor();
                return;
            }

            bool isGameViewActive = RuntimeEditorApplication.IsActiveWindow(RuntimeWindowType.GameView);

            if (!isGameViewActive)
            {
                float mouseWheel = InputController._GetAxis("Mouse ScrollWheel");
                if (mouseWheel != 0)
                {
                    if (!RuntimeTools.IsPointerOverGameObject())
                    {
                        m_mouseOrbit.Zoom();
                    }
                }
            }

            if (m_lockInput)
            {
                return;
            }


            if (!isGameViewActive)
            {
                if (InputController._GetKeyDown(SnapToGridKey) && InputController._GetKey(ModifierKey))
                {
                    SnapToGrid();
                }

                if (InputController._GetKeyDown(FocusKey))
                {
                    Focus();
                }

                bool rotate = InputController._GetKey(RotateKey) || InputController._GetKey(RotateKey2) || InputController._GetKey(RotateKey3);
                bool pan    = InputController._GetMouseButton(2) || InputController._GetMouseButton(1) || InputController._GetMouseButton(0) && RuntimeTools.Current == RuntimeTool.View;
                if (pan != m_pan)
                {
                    m_pan = pan;
                    if (m_pan)
                    {
                        if (RuntimeTools.Current != RuntimeTool.View)
                        {
                            m_rotate = false;
                        }
                        m_dragPlane = new Plane(-SceneCamera.transform.forward, Pivot.position);
                    }
                    SetCursor();
                }
                else
                {
                    if (rotate != m_rotate)
                    {
                        m_rotate = rotate;
                        SetCursor();
                    }
                }
            }

            RuntimeTools.IsViewing = m_rotate || m_pan;
            bool isLocked = RuntimeTools.IsViewing || isGameViewActive;

            if (!IPointerOverEditorArea)
            {
                return;
            }


            bool isMouse0ButtonDown = InputController._GetMouseButtonDown(0);
            bool isMouse1ButtonDown = InputController._GetMouseButtonDown(1);
            bool isMouse2ButtonDown = InputController._GetMouseButtonDown(2);

            if (isMouse0ButtonDown || isMouse1ButtonDown || isMouse2ButtonDown)
            {
                m_handleInput       = !PositionHandle.IsDragging;
                m_lastMousePosition = InputController._MousePosition;
                if (m_rotate)
                {
                    m_mouseOrbit.enabled = true;
                }
            }



            if (m_handleInput)
            {
                if (isLocked)
                {
                    if (m_pan && (!m_rotate || RuntimeTools.Current != RuntimeTool.View))
                    {
                        Pan();
                    }
                }
            }
        }
Exemple #9
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();
                }
            }
        }