private void OnDestroy() { RuntimeEditorApplication.ActivateWindow(null); RuntimeEditorApplication.PointerExit(this); RuntimeEditorApplication.RemoveWindow(this); OnDestroyOverride(); }
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); } } } }
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(); }
void IPointerDownHandler.OnPointerDown(PointerEventData eventData) { if (WindowType == RuntimeWindowType.SceneView || WindowType == RuntimeWindowType.GameView) { return; } RuntimeEditorApplication.ActivateWindow(this); OnPointerDownOverride(eventData); }
void IPointerExitHandler.OnPointerExit(PointerEventData eventData) { if (WindowType == RuntimeWindowType.SceneView || WindowType == RuntimeWindowType.GameView) { return; } m_isPointerOver = false; RuntimeEditorApplication.PointerExit(this); OnPointerExitOverride(eventData); }
private void Start() { GameObject go = EditorSelection.activeGameObject; ExposeToEditor exposeToEditor = go.GetComponent <ExposeToEditor>(); HierarchyItem hierarchyItem = go.GetComponent <HierarchyItem>(); HashSet <Component> ignoreComponents = new HashSet <Component>(); if (exposeToEditor != null) { if (exposeToEditor.Colliders != null) { for (int i = 0; i < exposeToEditor.Colliders.Length; ++i) { Collider collider = exposeToEditor.Colliders[i]; if (!ignoreComponents.Contains(collider)) { ignoreComponents.Add(collider); } } } ignoreComponents.Add(exposeToEditor); } if (hierarchyItem != null) { ignoreComponents.Add(hierarchyItem); } InputName.text = go.name; TogEnableDisable.isOn = go.activeSelf; InputName.onEndEdit.AddListener(OnEndEditName); TogEnableDisable.onValueChanged.AddListener(OnEnableDisable); Component[] components = go.GetComponents <Component>(); //Component[] components = go.GetComponentsInChildren<Collider>(); for (int i = 0; i < components.Length; ++i) { Component component = components[i]; if (component == null) { continue; } if (ignoreComponents.Contains(component)) { continue; } if ((component.hideFlags & HideFlags.HideInInspector) != 0) { continue; } if (EditorsMap.IsObjectEditorEnabled(component.GetType())) { GameObject editorPrefab = EditorsMap.GetObjectEditor(component.GetType()); if (editorPrefab != null) { ComponentEditor componentEditorPrefab = editorPrefab.GetComponent <ComponentEditor>(); if (componentEditorPrefab != null) { ComponentEditor editor = Instantiate(componentEditorPrefab); editor.EndEditCallback = () => { RuntimeEditorApplication.SaveSelectedObjects(); }; editor.transform.SetParent(ComponentsPanel, false); editor.Component = component; } else { Debug.LogErrorFormat("editor prefab {0} does not have ComponentEditor script", editorPrefab.name); } } } } }
private void Awake() { RuntimeEditorApplication.AddWindow(this); AwakeOverride(); }