Пример #1
0
        private void UpdateState(Rect cameraRect, bool isGameView)
        {
            bool isPointerOver = cameraRect.Contains(Input.mousePosition) && !RuntimeTools.IsPointerOverGameObject();

            if (RuntimeEditorApplication.IsPointerOverWindow(this))
            {
                if (!isPointerOver)
                {
                    RuntimeEditorApplication.PointerExit(this);
                }
            }
            else
            {
                if (isPointerOver)
                {
                    RuntimeEditorApplication.PointerEnter(this);
                }
            }

            if (isPointerOver)
            {
                if (Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1) || Input.GetMouseButtonUp(2) ||
                    Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2))
                {
                    if (!isGameView || isGameView && RuntimeEditorApplication.IsPlaying)
                    {
                        RuntimeEditorApplication.ActivateWindow(this);
                    }
                }
            }
        }
Пример #2
0
 private void OnDestroy()
 {
     RuntimeEditorApplication.ActivateWindow(null);
     RuntimeEditorApplication.PointerExit(this);
     RuntimeEditorApplication.RemoveWindow(this);
     OnDestroyOverride();
 }
        protected override void OnDestroyOverride()
        {
            base.OnDestroyOverride();

            RuntimeEditorApplication.ActivateWindow(null);
            RuntimeEditorApplication.PointerExit(this);
            RuntimeEditorApplication.RemoveWindow(this);
        }
Пример #4
0
        private void Update()
        {
            if (WindowType == RuntimeWindowType.GameView)
            {
                if (RuntimeEditorApplication.GameCameras == null || RuntimeEditorApplication.GameCameras.Length == 0)
                {
                    return;
                }

                Rect cameraRect = RuntimeEditorApplication.GameCameras[0].pixelRect;
                UpdateState(cameraRect, true);
            }
            else if (WindowType == RuntimeWindowType.SceneView)
            {
                if (RuntimeEditorApplication.ActiveSceneCamera == null)
                {
                    if (Camera.main != null)
                    {
                        RuntimeEditorApplication.SceneCameras = new[] { Camera.main };
                    }
                    else
                    {
                        return;
                    }
                }

                Rect cameraRect = RuntimeEditorApplication.ActiveSceneCamera.pixelRect;
                UpdateState(cameraRect, false);
            }
            else if (WindowType == RuntimeWindowType.None)
            {
                if (Camera.main == null)
                {
                    return;
                }

                Rect cameraRect = Camera.main.pixelRect;
                UpdateState(cameraRect, false);
            }
            else if (WindowType == RuntimeWindowType.Other)
            {
                return;
            }
            else
            {
                if (m_isPointerOver)
                {
                    if (Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1) || Input.GetMouseButtonUp(2) ||
                        Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2))
                    {
                        RuntimeEditorApplication.ActivateWindow(this);
                    }
                }
            }

            UpdateOverride();
        }
Пример #5
0
        void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
        {
            if (WindowType == RuntimeWindowType.SceneView || WindowType == RuntimeWindowType.GameView)
            {
                return;
            }

            RuntimeEditorApplication.ActivateWindow(this);
            OnPointerDownOverride(eventData);
        }
Пример #6
0
 void IPointerExitHandler.OnPointerExit(PointerEventData eventData)
 {
     if (WindowType == RuntimeWindowType.SceneView || WindowType == RuntimeWindowType.GameView)
     {
         return;
     }
     m_isPointerOver = false;
     RuntimeEditorApplication.PointerExit(this);
     OnPointerExitOverride(eventData);
 }
 protected override void OnPointerExitOverride(PointerEventData eventData)
 {
     base.OnPointerExitOverride(eventData);
     if (WindowType == RuntimeWindowType.SceneView || WindowType == RuntimeWindowType.GameView)
     {
         return;
     }
     m_isPointerOver = false;
     RuntimeEditorApplication.PointerExit(this);
 }
Пример #8
0
 private void Awake()
 {
     RuntimeEditorApplication.AddWindow(this);
     AwakeOverride();
 }
 protected override void AwakeOverride()
 {
     base.AwakeOverride();
     RuntimeEditorApplication.AddWindow(this);
 }