private void UpdateState(Rect cameraRect, bool isGameView) { bool isPointerOver = cameraRect.Contains(InputController._MousePosition) && !RuntimeTools.IsPointerOverGameObject(); if (RuntimeEditorApplication.IsPointerOverWindow(this)) { if (!isPointerOver) { RuntimeEditorApplication.PointerExit(this); } } else { if (isPointerOver) { RuntimeEditorApplication.PointerEnter(this); } } if (isPointerOver) { if (InputController._GetMouseButtonUp(0) || InputController._GetMouseButtonUp(1) || InputController._GetMouseButtonUp(2) || InputController._GetMouseButtonDown(0) || InputController._GetMouseButtonDown(1) || InputController._GetMouseButtonDown(2)) { if (!isGameView || isGameView && RuntimeEditorApplication.IsPlaying) { RuntimeEditorApplication.ActivateWindow(this); } } } }
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 (InputController._GetMouseButtonUp(0) || InputController._GetMouseButtonUp(1) || InputController._GetMouseButtonUp(2) || InputController._GetMouseButtonDown(0) || InputController._GetMouseButtonDown(1) || InputController._GetMouseButtonDown(2)) { RuntimeEditorApplication.ActivateWindow(this); } } } UpdateOverride(); }