private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath) { if (!GridPaintingState.savingPalette) { GridPaletteBrushes.FlushCache(); } }
private void HandleBrushPicking() { Event evt = Event.current; if (evt.type == EventType.MouseDown && IsPickingEvent(evt) && !isHotControl) { m_ModeBeforePicking = EditMode.SceneViewEditMode.GridPainting; if (inEditMode && EditMode.editMode != EditMode.SceneViewEditMode.GridPicking) { m_ModeBeforePicking = EditMode.editMode; EditMode.ChangeEditMode(EditMode.SceneViewEditMode.GridPicking, GridPaintingState.instance); } m_MarqueeStart = mouseGridPosition; m_MarqueeType = MarqueeType.Pick; s_LastActivePaintableGrid = this; Event.current.Use(); GUI.changed = true; GUIUtility.hotControl = m_PermanentControlID; OnBrushPickStarted(); } if (evt.type == EventType.MouseDrag && isHotControl && m_MarqueeStart.HasValue && m_MarqueeType == MarqueeType.Pick && IsPickingEvent(evt)) { RectInt rect = GridEditorUtility.GetMarqueeRect(m_MarqueeStart.Value, mouseGridPosition); OnBrushPickDragged(new BoundsInt(new Vector3Int(rect.xMin, rect.yMin, 0), new Vector3Int(rect.size.x, rect.size.y, 1))); Event.current.Use(); GUI.changed = true; } if (evt.rawType == EventType.MouseUp && isHotControl && m_MarqueeStart.HasValue && m_MarqueeType == MarqueeType.Pick && IsPickingEvent(evt)) { // Check if event only occurred in the PaintableGrid window as evt.type will filter for this if (evt.type == EventType.MouseUp && m_MarqueeType == MarqueeType.Pick) { RectInt rect = GridEditorUtility.GetMarqueeRect(m_MarqueeStart.Value, mouseGridPosition); Vector2Int pivot = GetMarqueePivot(m_MarqueeStart.Value, mouseGridPosition); PickBrush(new BoundsInt(new Vector3Int(rect.xMin, rect.yMin, 0), new Vector3Int(rect.size.x, rect.size.y, 1)), new Vector3Int(pivot.x, pivot.y, 0)); if (inEditMode && EditMode.editMode != m_ModeBeforePicking) { EditMode.ChangeEditMode(m_ModeBeforePicking, GridPaintingState.instance); } GridPaletteBrushes.ActiveGridBrushAssetChanged(); s_LastActivePaintableGrid = this; Event.current.Use(); GUI.changed = true; } else // Event occurred outside of PaintableGrid window, cancel the pick event { OnBrushPickCancelled(); } m_MarqueeType = MarqueeType.None; m_MarqueeStart = null; GUIUtility.hotControl = 0; InspectorWindow.RepaintAllInspectors(); } }
private void HandleBrushPicking() { Event current = Event.current; if (current.type == EventType.MouseDown && this.IsPickingEvent(current) && !this.isHotControl) { this.m_ModeBeforePicking = EditMode.SceneViewEditMode.GridPainting; if (this.inEditMode && EditMode.editMode != EditMode.SceneViewEditMode.GridPicking) { this.m_ModeBeforePicking = EditMode.editMode; EditMode.ChangeEditMode(EditMode.SceneViewEditMode.GridPicking, ScriptableSingleton <GridPaintingState> .instance); } this.m_MarqueeStart = new Vector2Int?(this.mouseGridPosition); this.m_MarqueeType = PaintableGrid.MarqueeType.Pick; PaintableGrid.s_LastActivePaintableGrid = this; Event.current.Use(); GUI.changed = true; GUIUtility.hotControl = this.m_PermanentControlID; this.OnBrushPickStarted(); } if (current.type == EventType.MouseDrag && this.isHotControl && this.m_MarqueeStart.HasValue && this.m_MarqueeType == PaintableGrid.MarqueeType.Pick && this.IsPickingEvent(current)) { RectInt marqueeRect = GridEditorUtility.GetMarqueeRect(this.m_MarqueeStart.Value, this.mouseGridPosition); this.OnBrushPickDragged(new BoundsInt(new Vector3Int(marqueeRect.xMin, marqueeRect.yMin, 0), new Vector3Int(marqueeRect.size.x, marqueeRect.size.y, 1))); Event.current.Use(); GUI.changed = true; } if (current.type == EventType.MouseUp && this.m_MarqueeStart.HasValue && this.m_MarqueeType == PaintableGrid.MarqueeType.Pick && this.IsPickingEvent(current)) { RectInt marqueeRect2 = GridEditorUtility.GetMarqueeRect(this.m_MarqueeStart.Value, this.mouseGridPosition); if (this.isHotControl) { Vector2Int marqueePivot = this.GetMarqueePivot(this.m_MarqueeStart.Value, this.mouseGridPosition); this.PickBrush(new BoundsInt(new Vector3Int(marqueeRect2.xMin, marqueeRect2.yMin, 0), new Vector3Int(marqueeRect2.size.x, marqueeRect2.size.y, 1)), new Vector3Int(marqueePivot.x, marqueePivot.y, 0)); if (this.inEditMode && EditMode.editMode != this.m_ModeBeforePicking) { EditMode.ChangeEditMode(this.m_ModeBeforePicking, ScriptableSingleton <GridPaintingState> .instance); } GridPaletteBrushes.ActiveGridBrushAssetChanged(); PaintableGrid.s_LastActivePaintableGrid = this; InspectorWindow.RepaintAllInspectors(); Event.current.Use(); GUI.changed = true; GUIUtility.hotControl = 0; } this.m_MarqueeType = PaintableGrid.MarqueeType.None; this.m_MarqueeStart = null; } }
public void OnEnable() { instances.Add(this); if (clipboardView == null) { clipboardView = CreateInstance <GridPaintPaletteClipboard>(); clipboardView.owner = this; clipboardView.hideFlags = HideFlags.HideAndDontSave; clipboardView.unlocked = false; } if (m_PaintableSceneViewGrid == null) { m_PaintableSceneViewGrid = CreateInstance <PaintableSceneViewGrid>(); m_PaintableSceneViewGrid.hideFlags = HideFlags.HideAndDontSave; } GridPaletteBrushes.FlushCache(); EditMode.editModeStarted += OnEditModeStart; EditMode.editModeEnded += OnEditModeEnd; GridSelection.gridSelectionChanged += OnGridSelectionChanged; GridPaintingState.RegisterPainterInterest(this); GridPaintingState.scenePaintTargetChanged += OnScenePaintTargetChanged; GridPaintingState.brushChanged += OnBrushChanged; SceneView.onSceneGUIDelegate += OnSceneViewGUI; PrefabUtility.prefabInstanceUpdated += PrefabInstanceUpdated; AssetPreview.SetPreviewTextureCacheSize(256, GetInstanceID()); wantsMouseMove = true; wantsMouseEnterLeaveWindow = true; if (m_PreviewResizer == null) { m_PreviewResizer = new PreviewResizer(); m_PreviewResizer.Init("TilemapBrushInspector"); } minSize = new Vector2(240f, 200f); if (palette == null && TilemapEditorUserSettings.lastUsedPalette != null && GridPalettes.palettes.Contains(TilemapEditorUserSettings.lastUsedPalette)) { palette = TilemapEditorUserSettings.lastUsedPalette; } Tools.onToolChanged += ToolChanged; ShortcutIntegration.instance.contextManager.RegisterToolContext(m_ShortcutContext); }
private void OnBrushInspectorGUI() { GridBrushBase gridBrush = GridPaintingState.gridBrush; if (!(gridBrush == null)) { EditorGUI.BeginChangeCheck(); if (GridPaintingState.activeBrushEditor != null) { GridPaintingState.activeBrushEditor.OnPaintInspectorGUI(); } else if (GridPaintingState.fallbackEditor != null) { GridPaintingState.fallbackEditor.OnInspectorGUI(); } if (EditorGUI.EndChangeCheck()) { GridPaletteBrushes.ActiveGridBrushAssetChanged(); } } }
public void OnEnable() { GridPaintPaletteWindow.instances.Add(this); if (this.clipboardView == null) { this.clipboardView = ScriptableObject.CreateInstance <GridPaintPaletteClipboard>(); this.clipboardView.owner = this; this.clipboardView.hideFlags = HideFlags.HideAndDontSave; this.clipboardView.unlocked = false; } if (this.m_PaintableSceneViewGrid == null) { this.m_PaintableSceneViewGrid = ScriptableObject.CreateInstance <PaintableSceneViewGrid>(); this.m_PaintableSceneViewGrid.hideFlags = HideFlags.HideAndDontSave; } GridPaletteBrushes.FlushCache(); EditorApplication.globalEventHandler = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.globalEventHandler, new EditorApplication.CallbackFunction(this.HotkeyHandler)); EditMode.editModeStarted += new Action <IToolModeOwner, EditMode.SceneViewEditMode>(this.OnEditModeStart); EditMode.editModeEnded += new Action <IToolModeOwner>(this.OnEditModeEnd); GridSelection.gridSelectionChanged += new Action(this.OnGridSelectionChanged); GridPaintingState.RegisterPainterInterest(this); GridPaintingState.scenePaintTargetChanged += new Action <GameObject>(this.OnScenePaintTargetChanged); GridPaintingState.brushChanged += new Action <GridBrushBase>(this.OnBrushChanged); SceneView.onSceneGUIDelegate = (SceneView.OnSceneFunc)Delegate.Combine(SceneView.onSceneGUIDelegate, new SceneView.OnSceneFunc(this.OnSceneViewGUI)); PrefabUtility.prefabInstanceUpdated = (PrefabUtility.PrefabInstanceUpdated)Delegate.Combine(PrefabUtility.prefabInstanceUpdated, new PrefabUtility.PrefabInstanceUpdated(this.PrefabInstanceUpdated)); AssetPreview.SetPreviewTextureCacheSize(256, base.GetInstanceID()); base.wantsMouseMove = true; base.wantsMouseEnterLeaveWindow = true; if (this.m_PreviewResizer == null) { this.m_PreviewResizer = new PreviewResizer(); this.m_PreviewResizer.Init("TilemapBrushInspector"); } base.minSize = new Vector2(240f, 200f); if (this.palette == null && TilemapEditorUserSettings.lastUsedPalette != null && GridPalettes.palettes.Contains(TilemapEditorUserSettings.lastUsedPalette)) { this.palette = TilemapEditorUserSettings.lastUsedPalette; } Tools.onToolChanged = (Tools.OnToolChangedFunc)Delegate.Combine(Tools.onToolChanged, new Tools.OnToolChangedFunc(this.ToolChanged)); }