private void UpdateUIState(bool isInPlayMode) { if (ProjectionButton != null) { ProjectionButton.gameObject.SetActive(!isInPlayMode); } EditorCamera.gameObject.SetActive(!isInPlayMode); PlayerCamera.gameObject.SetActive(isInPlayMode); SelectionController.gameObject.SetActive(!isInPlayMode); PlayButton.gameObject.SetActive(!isInPlayMode); HintButton.gameObject.SetActive(!isInPlayMode); SaveButton.gameObject.SetActive(!isInPlayMode); LoadButton.gameObject.SetActive(!isInPlayMode); StopButton.gameObject.SetActive(isInPlayMode); UndoButton.gameObject.SetActive(!isInPlayMode); RedoButton.gameObject.SetActive(!isInPlayMode); UI.gameObject.SetActive(!isInPlayMode); Grid.gameObject.SetActive(TogGrid.isOn && !isInPlayMode); LoadButton.interactable = m_sceneManager != null && m_saveFileExists; if (isInPlayMode) { RuntimeEditorApplication.ActivateWindow(RuntimeWindowType.GameView); } else { RuntimeEditorApplication.ActivateWindow(RuntimeWindowType.SceneView); } }
private void OnPlaymodeStateChanged() { if (RuntimeEditorApplication.IsPlaying) { RuntimeEditorApplication.ActivateWindow(RuntimeWindowType.GameView); } else { RuntimeEditorApplication.ActivateWindow(RuntimeWindowType.SceneView); } if (PlayToggle != null) { PlayToggle.isOn = RuntimeEditorApplication.IsPlaying; } UpdateLoadSaveButtonsState(); }
public void CompleteSpawn() { if (RuntimeEditorApplication.IsPointerOverWindow(RuntimeWindowType.SceneView)) { if (m_resource is Material) { Material material = (Material)m_resource; Camera sceneCamera = RuntimeEditorApplication.ActiveSceneCamera; if (sceneCamera) { Ray ray = sceneCamera.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo)) { MeshRenderer renderer = hitInfo.collider.GetComponentInChildren <MeshRenderer>(); SkinnedMeshRenderer sRenderer = hitInfo.collider.GetComponentInChildren <SkinnedMeshRenderer>(); if (renderer != null || sRenderer != null) { RuntimeUndo.BeginRecord(); } if (renderer != null) { RuntimeUndo.RecordValue(renderer, Strong.PropertyInfo((MeshRenderer x) => x.sharedMaterials)); Material[] materials = renderer.sharedMaterials; for (int i = 0; i < materials.Length; ++i) { materials[i] = material; } renderer.sharedMaterials = materials; } if (sRenderer != null) { RuntimeUndo.RecordValue(sRenderer, Strong.PropertyInfo((SkinnedMeshRenderer x) => x.sharedMaterials)); Material[] materials = sRenderer.sharedMaterials; for (int i = 0; i < materials.Length; ++i) { materials[i] = material; } sRenderer.sharedMaterials = materials; } if (renderer != null || sRenderer != null) { RuntimeUndo.EndRecord(); } if (renderer != null || sRenderer != null) { RuntimeUndo.BeginRecord(); } if (renderer != null) { RuntimeUndo.RecordValue(renderer, Strong.PropertyInfo((MeshRenderer x) => x.sharedMaterials)); } if (sRenderer != null) { RuntimeUndo.RecordValue(sRenderer, Strong.PropertyInfo((SkinnedMeshRenderer x) => x.sharedMaterials)); } if (renderer != null || sRenderer != null) { RuntimeUndo.EndRecord(); } } } } else { if (m_state == State.AfterSpawn) { bool isEnabled = RuntimeUndo.Enabled; RuntimeUndo.Enabled = false; RuntimeSelection.objects = m_selection; RuntimeUndo.Enabled = isEnabled; RuntimeUndo.BeginRecord(); RuntimeUndo.RecordSelection(); RuntimeUndo.BeginRegisterCreateObject(m_instance); RuntimeUndo.EndRecord(); RuntimeUndo.Enabled = false; RuntimeSelection.activeGameObject = m_instance; RuntimeUndo.Enabled = isEnabled; RuntimeUndo.BeginRecord(); RuntimeUndo.RegisterCreatedObject(m_instance); RuntimeUndo.RecordSelection(); RuntimeUndo.EndRecord(); } } EndSpawn(); RuntimeEditorApplication.ActivateWindow(RuntimeWindowType.SceneView); } else { if (!RuntimeEditorApplication.IsPointerOverWindow(RuntimeWindowType.Hierarchy)) { EndSpawn(); } } }