private void HandleMouseEnterLeave() { if (Event.current.type == EventType.MouseEnterWindow) { if (PaintableGrid.InGridEditMode()) { GridPaintingState.activeGrid = this; Event.current.Use(); } } else if (Event.current.type == EventType.MouseLeaveWindow) { if (m_PreviousMousePosition.HasValue && guiRect.Contains(m_PreviousMousePosition.Value) && GridPaintingState.activeBrushEditor != null) { GridPaintingState.activeBrushEditor.OnMouseLeave(); } m_PreviousMousePosition = null; if (PaintableGrid.InGridEditMode()) { GridPaintingState.activeGrid = null; Event.current.Use(); Repaint(); } } }
public void OnDisable() { CallOnToolDeactivated(); instances.Remove(this); if (instances.Count <= 1) { GridPaintingState.gridBrush = null; } DestroyPreviewInstance(); DestroyImmediate(clipboardView); DestroyImmediate(m_PaintableSceneViewGrid); if (m_PreviewUtility != null) { m_PreviewUtility.Cleanup(); } m_PreviewUtility = null; if (PaintableGrid.InGridEditMode()) { EditMode.QuitEditMode(); } EditMode.editModeStarted -= OnEditModeStart; EditMode.editModeEnded -= OnEditModeEnd; Tools.onToolChanged -= ToolChanged; GridSelection.gridSelectionChanged -= OnGridSelectionChanged; SceneView.onSceneGUIDelegate -= OnSceneViewGUI; GridPaintingState.scenePaintTargetChanged -= OnScenePaintTargetChanged; GridPaintingState.brushChanged -= OnBrushChanged; GridPaintingState.UnregisterPainterInterest(this); PrefabUtility.prefabInstanceUpdated -= PrefabInstanceUpdated; ShortcutIntegration.instance.contextManager.DeregisterToolContext(m_ShortcutContext); }
private void ToolChanged(Tool from, Tool to) { if (to != Tool.None && PaintableGrid.InGridEditMode()) { EditMode.QuitEditMode(); } base.Repaint(); }
protected override void PickBrush(BoundsInt position, Vector3Int pickingStart) { if (!(this.grid == null) && !(this.gridBrush == null)) { this.gridBrush.Pick(this.grid, this.brushTarget, position, pickingStart); if (!PaintableGrid.InGridEditMode()) { EditMode.ChangeEditMode(EditMode.SceneViewEditMode.GridPainting, default(Bounds), ScriptableSingleton <GridPaintingState> .instance); } this.m_ActivePick = new RectInt?(new RectInt(position.min.x, position.min.y, position.size.x, position.size.y)); } }
private void CallOnToolDeactivated() { if (GridPaintingState.gridBrush != null && this.m_PreviousToolActivatedEditor != null) { this.m_PreviousToolActivatedEditor.OnToolDeactivated(this.m_PreviousToolActivated); this.m_PreviousToolActivatedEditor = null; if (!PaintableGrid.InGridEditMode()) { Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); } } }
protected override void PickBrush(BoundsInt position, Vector3Int pickingStart) { if (grid == null || gridBrush == null) { return; } gridBrush.Pick(grid, brushTarget, position, pickingStart); if (!PaintableGrid.InGridEditMode()) { EditMode.ChangeEditMode(EditMode.SceneViewEditMode.GridPainting, new Bounds(), GridPaintingState.instance); } m_ActivePick = new RectInt(position.min.x, position.min.y, position.size.x, position.size.y); }
public void OnSceneGUI(SceneView sceneView) { base.UpdateMouseGridPosition(); base.OnGUI(); if (PaintableGrid.InGridEditMode()) { this.CallOnSceneGUI(); if (this.grid != null && (GridPaintingState.activeGrid == this || GridSelection.active)) { this.CallOnPaintSceneGUI(); } if (Event.current.type == EventType.Repaint) { EditorGUIUtility.AddCursorRect(new Rect(0f, 17f, sceneView.position.width, sceneView.position.height - 17f), MouseCursor.CustomCursor); } } this.HandleMouseEnterLeave(sceneView); }
public void OnSceneGUI(SceneView sceneView) { UpdateMouseGridPosition(); base.OnGUI(); if (PaintableGrid.InGridEditMode()) { CallOnSceneGUI(); if ((grid != null) && (GridPaintingState.activeGrid == this || GridSelection.active)) { CallOnPaintSceneGUI(); } if (Event.current.type == EventType.Repaint) { EditorGUIUtility.AddCursorRect(new Rect(0, EditorGUI.kWindowToolbarHeight, sceneView.position.width, sceneView.position.height - EditorGUI.kWindowToolbarHeight), MouseCursor.CustomCursor); } } HandleMouseEnterLeave(sceneView); }
private void UpdateCache() { GridLayout gridLayout; if (PaintableGrid.InGridEditMode()) { gridLayout = ((!(GridPaintingState.scenePaintTarget != null)) ? null : GridPaintingState.scenePaintTarget.GetComponentInParent <GridLayout>()); } else { gridLayout = ((!(Selection.activeGameObject != null)) ? null : Selection.activeGameObject.GetComponentInParent <GridLayout>()); } if (gridLayout != this.m_ActiveGridProxy) { this.m_ActiveGridProxy = gridLayout; SceneViewGridManager.FlushCachedGridProxy(); } this.ShowGlobalGrid(!this.active); }
public void OnEditModeStart(IToolModeOwner owner, EditMode.SceneViewEditMode editMode) { if (GridPaintingState.gridBrush != null && PaintableGrid.InGridEditMode() && GridPaintingState.activeBrushEditor != null) { GridBrushBase.Tool tool = PaintableGrid.EditModeToBrushTool(editMode); GridPaintingState.activeBrushEditor.OnToolActivated(tool); this.m_PreviousToolActivatedEditor = GridPaintingState.activeBrushEditor; this.m_PreviousToolActivated = tool; for (int i = 0; i < GridPaintPaletteWindow.Styles.sceneViewEditModes.Length; i++) { if (GridPaintPaletteWindow.Styles.sceneViewEditModes[i] == editMode) { Cursor.SetCursor(GridPaintPaletteWindow.Styles.mouseCursorTextures[i], (!(GridPaintPaletteWindow.Styles.mouseCursorTextures[i] != null)) ? Vector2.zero : GridPaintPaletteWindow.Styles.mouseCursorOSHotspot[(int)SystemInfo.operatingSystemFamily], CursorMode.Auto); break; } } } base.Repaint(); }
public void OnDestroy() { this.DestroyPreviewInstance(); UnityEngine.Object.DestroyImmediate(this.clipboardView); UnityEngine.Object.DestroyImmediate(this.m_PaintableSceneViewGrid); if (this.m_PreviewUtility != null) { this.m_PreviewUtility.Cleanup(); } this.m_PreviewUtility = null; if (PaintableGrid.InGridEditMode()) { EditMode.QuitEditMode(); } if (GridPaintPaletteWindow.instances.Count <= 1) { GridPaintingState.gridBrush = null; } }
private void UpdateCache() { GridLayout gridProxy = null; if (PaintableGrid.InGridEditMode()) { gridProxy = GridPaintingState.scenePaintTarget != null?GridPaintingState.scenePaintTarget.GetComponentInParent <GridLayout>() : null; } else { gridProxy = Selection.activeGameObject != null?Selection.activeGameObject.GetComponentInParent <GridLayout>() : null; } if (gridProxy != m_ActiveGridProxy) { m_ActiveGridProxy = gridProxy; FlushCachedGridProxy(); } ShowGlobalGrid(!active); }
public void OnDestroy() { DestroyPreviewInstance(); DestroyImmediate(clipboardView); DestroyImmediate(m_PaintableSceneViewGrid); if (m_PreviewUtility != null) { m_PreviewUtility.Cleanup(); } m_PreviewUtility = null; if (PaintableGrid.InGridEditMode()) { EditMode.QuitEditMode(); } if (instances.Count <= 1) { GridPaintingState.gridBrush = null; } }
public void OnEditModeStart(IToolModeOwner owner, EditMode.SceneViewEditMode editMode) { if (GridPaintingState.gridBrush != null && PaintableGrid.InGridEditMode() && GridPaintingState.activeBrushEditor != null) { GridBrushBase.Tool tool = PaintableGrid.EditModeToBrushTool(editMode); GridPaintingState.activeBrushEditor.OnToolActivated(tool); m_PreviousToolActivatedEditor = GridPaintingState.activeBrushEditor; m_PreviousToolActivated = tool; for (int i = 0; i < k_SceneViewEditModes.Length; ++i) { if (k_SceneViewEditModes[i] == editMode) { Cursor.SetCursor(MouseStyles.mouseCursorTextures[i], MouseStyles.mouseCursorTextures[i] != null ? MouseStyles.mouseCursorOSHotspot[(int)SystemInfo.operatingSystemFamily] : Vector2.zero, CursorMode.Auto); break; } } } Repaint(); }