Example #1
0
        /// <inheritdoc/>
        public override void OnTool(ToolEvent e, IToolContext context)
        {
            switch (e.Type)
            {
            case EventType.MouseDown:
                ToolBase fallbackRestoreTool;

                Brush pickedBrush = null;

                if (ToolUtility.ActivePlop != null && ToolUtility.ActivePlop.Brush != null)
                {
                    fallbackRestoreTool = ToolManager.Instance.Find <PlopTool>();

                    // Get plop at pointer.
                    pickedBrush = ToolUtility.ActivePlop.Brush;
                    // Pick rotation from tile also!
                    ToolUtility.Rotation = ToolUtility.ActivePlop.PaintedRotation;
                }
                else
                {
                    fallbackRestoreTool = ToolManager.DefaultPaintTool;

                    // Get tile at pointer.
                    var tile = context.TileSystem.GetTile(e.MousePointerTileIndex);
                    if (tile != null)
                    {
                        pickedBrush = tile.brush;

                        // Pick rotation from tile also!
                        ToolUtility.Rotation = tile.PaintedRotation;
                    }
                }

                // Select brush in tool window and force auto scroll.
                if (e.IsLeftButtonPressed)
                {
                    ToolUtility.SelectedBrush = pickedBrush;
                    ToolUtility.RevealBrush(pickedBrush);
                }
                else
                {
                    ToolUtility.SelectedBrushSecondary = pickedBrush;
                }

                ToolUtility.RepaintBrushPalette();

                // Switch to previous tool or the "Paint" tool.
                var toolManager = ToolManager.Instance;
                if (toolManager.PreviousTool != null && toolManager.PreviousTool != this)
                {
                    toolManager.CurrentTool = toolManager.PreviousTool;
                }
                else
                {
                    toolManager.CurrentTool = fallbackRestoreTool;
                }

                break;
            }
        }
Example #2
0
        /// <summary>
        /// Creates a new tile system using properties from the specified preset.
        /// </summary>
        /// <remarks>
        /// <para>This method does not automatically record the new game object with
        /// Unity's undo system. If undo functionality is desired then the callee should
        /// do this.</para>
        /// </remarks>
        /// <param name="preset">Tile system preset.</param>
        /// <returns>
        /// A new game object with an initialized <see cref="TileSystem"/>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// If <paramref name="preset"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.InvalidOperationException">
        /// <list type="bullet">
        /// <item>If preset defines an invalid name for a tile system.</item>
        /// <item>If preset defines a tile system with less than one cell.</item>
        /// </list>
        /// </exception>
        public static GameObject CreateTileSystemFromPreset(TileSystemPreset preset)
        {
            if (preset == null)
            {
                throw new ArgumentNullException("preset");
            }

            string name = preset.SystemName.Trim();

            if (string.IsNullOrEmpty(name))
            {
                throw new InvalidOperationException("Invalid name for tile system.");
            }
            if (preset.Rows < 1 || preset.Columns < 1)
            {
                throw new InvalidOperationException("Tile system must have at least one cell.");
            }

            // Create empty game object and add tile system component.
            var go         = new GameObject(name);
            var tileSystem = go.AddComponent <TileSystem>();

            tileSystem.CreateSystem(preset.TileWidth, preset.TileHeight, preset.TileDepth, preset.Rows, preset.Columns, preset.ChunkWidth, preset.ChunkHeight);

            TransformTileSystemUsingPreset(preset, go.transform);
            SetTileSystemPropertiesFromPreset(preset, tileSystem);

            // Place at end of the scene palette listing.
            tileSystem.sceneOrder = int.MaxValue;

            ToolUtility.RepaintScenePalette();

            return(go);
        }
        /// <summary>
        /// Automatically activate tile system from user selection if appropriate so that
        /// tool can be selected.
        /// </summary>
        private void AutoActivateTileSystem()
        {
            ToolUtility.SelectActiveOrParentTileSystem();

            if (ToolUtility.ActiveTileSystem == null)
            {
                // Okay, no tile system is actually selected.
                // Select first non-locked if possible; otherwise select first if possible.
                var tileSystems     = ToolUtility.GetAllTileSystemsInScene();
                var firstTileSystem = tileSystems.FirstOrDefault(s => s != null && !s.Locked);
                if (firstTileSystem == null)
                {
                    firstTileSystem = tileSystems.FirstOrDefault(s => s != null);
                }

                if (firstTileSystem != null)
                {
                    ToolUtility.SelectTileSystem(firstTileSystem);
                }
                else
                {
                    return;
                }
            }

            // When using a tool it only makes sense to have one selected tile system.
            if (Selection.objects.Length > 1)
            {
                Selection.objects = new Object[] { ToolUtility.ActiveTileSystem.gameObject };
            }
        }
Example #4
0
        private void DoToolSceneGUI(ToolBase tool)
        {
            var tileSystem = target as TileSystem;

            // Toggle preview material using control key.
            this.CheckSwitchImmediatePreviewMaterial();

            ToolUtility.CheckToolKeyboardShortcuts();

            // Preserve current state of handles.
            Matrix4x4 originalMatrix     = Handles.matrix;
            Color     restoreHandleColor = Handles.color;

            // Place handles within local space of tile system.
            Handles.matrix = tileSystem.transform.localToWorldMatrix;

            // Tools cannot interact with locked tile systems!
            if (!tileSystem.Locked)
            {
                tool.OnSceneGUI(this.toolEvent, this);
            }
            else
            {
                Vector3 activeCenter = Vector3.zero;
                activeCenter.x += this.toolEvent.MousePointerTileIndex.column * tileSystem.CellSize.x + tileSystem.CellSize.x / 2f;
                activeCenter.y -= this.toolEvent.MousePointerTileIndex.row * tileSystem.CellSize.y + tileSystem.CellSize.y / 2f;

                ToolHandleUtility.DrawWireBox(activeCenter, tileSystem.CellSize);
            }

            // Restore former state of handles.
            Handles.matrix = originalMatrix;
            Handles.color  = restoreHandleColor;
        }
Example #5
0
        private void CreateOrientedBrush(string brushName)
        {
            var newOrientedBrush = BrushUtility.CreateOrientedBrush(brushName);

            ToolUtility.ShowBrushInDesigner(newOrientedBrush);

            ToolUtility.RepaintBrushPalette();
        }
Example #6
0
        /// <inheritdoc/>
        public override void OnEnable()
        {
            ToolUtility.ShowBrushPalette(false);

            this.RandomizeVariationShift();

            this.EnableVariationShifting = true;
        }
        private void CreateAliasBrush(string brushName, Brush targetBrush)
        {
            var newAliasBrush = BrushUtility.CreateAliasBrush(brushName, targetBrush);

            ToolUtility.ShowBrushInDesigner(newAliasBrush);

            ToolUtility.RepaintBrushPalette();
        }
Example #8
0
        /// <inheritdoc/>
        protected override void PrepareOptions(ISettingStore store)
        {
            base.PrepareOptions(store);

            this.settingNozzleSizeOption = store.Fetch <int>("NozzleSize", this.DefaultNozzleSize,
                                                             filter: value => Mathf.Clamp(value, 1, 19)
                                                             );
            this.settingNozzleSizeOption.ValueChanged += (args) => ToolUtility.RepaintToolPalette();
        }
 /// <summary>
 /// Restore tool visibility to defaults.
 /// </summary>
 public static void RestoreToolVisibility()
 {
     Hidden.RestoreDefaultValue();
     foreach (var tool in ToolManager.Instance.Tools)
     {
         tool._visible = true;
     }
     ToolUtility.RepaintToolPalette();
 }
 private static void PrepareSettings_Tools(ISettingStore store)
 {
     AutoShowToolPalette = store.Fetch <bool>("AutoShowToolPalette", false);
     AutoShowToolPalette.ValueChanged += (args) => {
         // Immediately show tool palette if a tool is activated!
         if (args.NewValue && ToolManager.Instance.CurrentTool != null)
         {
             ToolUtility.ShowToolPalette(false);
         }
     };
 }
        void IHasCustomMenu.AddItemsToMenu(GenericMenu menu)
        {
            menu.AddItem(new GUIContent(TileLang.ParticularText("Action", "Reset Tool Options")), false, () => {
                this.clearInputFocus = true;

                foreach (var tool in ToolManager.Instance.Tools)
                {
                    tool.Options.RestoreDefaultValues();
                }
                ToolUtility.RepaintToolPalette();
            });
        }
Example #12
0
        private void CreateAutotileTileset(string tilesetName)
        {
            // Ensure that autotile artwork is re-expanded before proceeding to avoid
            // ignoring changes that have been made to user input.
            this.ExpandAutotileArtwork(s_BorderSize);

            // Create folder for autotile brush assets.
            string tilesetDirectoryName = tilesetName + " Autotile";
            string tilesetDirectoryPath = AssetDatabase.GenerateUniqueAssetPath(BrushUtility.GetBrushAssetPath() + tilesetDirectoryName);

            Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/" + tilesetDirectoryPath);

            // Create material for tileset.
            var atlasTexture  = EditorInternalUtility.SavePngAsset(tilesetDirectoryPath + "/atlas.png", this.atlasTexture);
            var atlasMaterial = BrushUtility.CreateTilesetMaterial(atlasTexture, this.enableAlphaBlending);

            AssetDatabase.CreateAsset(atlasMaterial, tilesetDirectoryPath + "/atlas.mat");
            AssetDatabase.ImportAsset(tilesetDirectoryPath + "/atlas.mat");

            // Calculate metrics for tileset.
            var tilesetMetrics = new TilesetMetrics(atlasTexture, this.tileWidth, this.tileHeight, s_BorderSize, s_Delta);

            // Create tileset.
            var autotileTileset = ScriptableObject.CreateInstance <AutotileTileset>();

            autotileTileset.Initialize(s_SelectedAutotileLayout, s_InnerJoins, atlasMaterial, atlasTexture, tilesetMetrics);
            autotileTileset.rawTexture      = this.autotileTexture;
            autotileTileset.procedural      = true;
            autotileTileset.ForceClampEdges = s_EnableClampEdges;

            Object.DestroyImmediate(this.atlasTexture);
            this.atlasTexture = null;

            // Save tileset and its material to asset file.
            string assetPath = tilesetDirectoryPath + "/" + tilesetName + ".asset";

            AssetDatabase.CreateAsset(autotileTileset, assetPath);

            AssetDatabase.ImportAsset(assetPath);

            // Ensure that changes are persisted immediately.
            AssetDatabase.SaveAssets();

            // Make sure that "Create Brushes" tab is shown.
            TilesetDesigner.s_SelectedTab = 0;
            ToolUtility.ShowTilesetInDesigner(autotileTileset);

            ToolUtility.RepaintBrushPalette();
        }
        private void OnKeyboardGUI()
        {
            int controlID = GUIUtility.GetControlID(FocusType.Keyboard);

            if (Event.current.GetTypeForControl(controlID) != EventType.KeyDown)
            {
                return;
            }

            if (GUIUtility.keyboardControl == 0)
            {
                ToolManager.Instance.CheckForKeyboardShortcut();
                ToolUtility.CheckToolKeyboardShortcuts();
            }
        }
        /// <summary>
        /// Select and activate nearest tile system in parent hierarchy of selected object.
        /// </summary>
        /// <seealso cref="SelectTileSystem(TileSystem)"/>
        /// <seealso cref="SelectPreviousTileSystem()"/>
        /// <seealso cref="SelectNextTileSystem()"/>
        /// <seealso cref="SelectNthTileSystem(int)"/>
        /// <seealso cref="ActiveTileSystem"/>
        public static void SelectActiveOrParentTileSystem()
        {
            var tileSystem = ActiveTileSystem;

            // If no tile system is currently active, search the parent hierarchy of the
            // active game object for a tile system and select it.
            if (tileSystem == null && Selection.activeTransform != null)
            {
                tileSystem = ToolUtility.FindParentTileSystem(Selection.activeTransform);
            }

            if (tileSystem != null)
            {
                SelectTileSystem(tileSystem);
            }
        }
Example #15
0
        /// <summary>
        /// Refresh preview image for specified brush and also refresh preview image
        /// for brushes which depend upon the specified brush.
        /// </summary>
        /// <remarks>
        /// <para>At the moment this only includes alias brushes which target the
        /// specified brush. In the future this may be updated to include oriented
        /// brushes which nest the specified brush.</para>
        /// </remarks>
        /// <param name="brush">The brush.</param>
        internal static void RefreshPreviewIncludingDependencies(Brush brush)
        {
            BrushAssetRecord record = BrushDatabase.Instance.FindRecord(brush);

            if (record != null)
            {
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(brush));

                // Refresh preview any alias brushes which target this brush.
                foreach (var dependencyRecord in FindDependencyBrushes(record.Brush))
                {
                    RefreshPreview(dependencyRecord.Brush);
                }

                ToolUtility.RepaintBrushPalette();
            }
        }
        /// <summary>
        /// Display user interface to replace tiles by brush in a tile system.
        /// </summary>
        /// <exclude/>
        public static void Command_ReplaceByBrush()
        {
            ReplaceByBrushWindow.ShowWindow((target, source, replacement) => {
                // Perform find and replace.
                int replaced = 0;
                switch (target)
                {
                default:
                case ReplaceByBrushTarget.ActiveTileSystem:
                    if (ToolUtility.ActiveTileSystem != null && ToolUtility.ActiveTileSystem.IsEditable && !ToolUtility.ActiveTileSystem.Locked)
                    {
                        replaced = ReplaceByBrush(ToolUtility.ActiveTileSystem, source, replacement);
                    }
                    break;

                case ReplaceByBrushTarget.SelectedTileSystems:
                    foreach (Object ob in Selection.GetFiltered(typeof(TileSystem), SelectionMode.ExcludePrefab))
                    {
                        TileSystem system = ob as TileSystem;
                        if (system.IsEditable && !system.Locked)
                        {
                            replaced += ReplaceByBrush(system, source, replacement);
                        }
                    }
                    break;

                case ReplaceByBrushTarget.All:
                    foreach (var tileSystem in ToolUtility.GetAllTileSystemsInScene())
                    {
                        if (tileSystem.IsEditable && !tileSystem.Locked)
                        {
                            replaced += ReplaceByBrush(tileSystem, source, replacement);
                        }
                    }
                    break;
                }

                string message = string.Format(
                    /* 0: quantity of tiles replaced */
                    TileLang.Text("Replace by Brush :: Matched and replaced {0} tile(s)."),
                    replaced
                    );
                Debug.Log(message + "\n");
            });
        }
        private void DrawTileSystemList()
        {
            this.AutoInitializeTileSystemsListControl();

            Rect scrollViewPosition = new Rect(0, 0, position.width, position.height);

            scrollViewPosition.yMin = GUILayoutUtility.GetLastRect().yMax;
            if (Event.current.type == EventType.Repaint)
            {
                this.scrollViewPosition = scrollViewPosition;
            }

            Rect listControlPosition = new Rect(0, 0, scrollViewPosition.width, this.systemsListControl.CalculateListHeight(this.systemsListAdaptor));
            Rect viewRect            = listControlPosition;

            viewRect.height += 7;
            if (viewRect.height > scrollViewPosition.height)
            {
                viewRect.width -= GUI.skin.verticalScrollbar.fixedWidth + GUI.skin.verticalScrollbar.margin.horizontal;
            }

            bool isMouseDownEvent = Event.current.type == EventType.MouseDown;

            try {
                this.scrollPosition = GUI.BeginScrollView(scrollViewPosition, this.scrollPosition, viewRect);
                this.systemsListControl.Draw(listControlPosition, this.systemsListAdaptor);
                GUI.EndScrollView();
            }
            finally {
                if (isMouseDownEvent)
                {
                    this.systemsListAdaptor.CanBeginEditingNameOnMouseUp = true;
                }
            }

            // Clear selection when mouse is clicked in empty area of list.
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                if (scrollViewPosition.Contains(Event.current.mousePosition))
                {
                    ToolUtility.SelectTileSystem(null);
                    Event.current.Use();
                }
            }
        }
 private void SelectBrushByIndex(int index)
 {
     if (index < 0 && this.BrushListModel.View == BrushListView.Tileset)
     {
         this.SelectedObject = null;
         this.BrushListModel.ScrollPosition = 0f;
         ToolUtility.RepaintBrushPalette();
         this.Repaint();
     }
     else
     {
         Brush nextBrush = this.BrushListModel.Records[index].Brush;
         if (nextBrush != null)
         {
             this.SelectedObject = nextBrush;
         }
     }
 }
        private void OnUseDefaults()
        {
            if (EditorUtility.DisplayDialog(
                    TileLang.ParticularText("Action", "Use Default Preferences"),
                    TileLang.Text("Would you like to use the default preferences?"),
                    TileLang.ParticularText("Action", "Yes"),
                    TileLang.ParticularText("Action", "No")
                    ))
            {
                RtsPreferences.ResetToDefaultValues();

                // Refresh editor windows.
                ToolUtility.RepaintToolPalette();
                ToolUtility.RepaintBrushPalette();
                // Refresh all scene views.
                SceneView.RepaintAll();
            }
        }
        private void DrawToolsTab()
        {
            EditorGUI.BeginChangeCheck();
            ReorderableListGUI.Title(TileLang.Text("Tool Palette:"));
            ReorderableListGUI.ListField(this.toolsAdaptor, ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons);
            if (EditorGUI.EndChangeCheck())
            {
                ToolManagementSettings.SaveToolOrdering();
                ToolUtility.RepaintToolPalette();
            }

            ExtraEditorGUI.TrailingTip(TileLang.Text("Specify which tools appear in the tools palette."));
            GUILayout.Space(5);

            RtsPreferences.AutoShowToolPalette.Value = EditorGUILayout.ToggleLeft(TileLang.Text("Automatically show tool palette upon activating tool"), RtsPreferences.AutoShowToolPalette);

            GUILayout.Space(5);
        }
        private void OnRename(string newName)
        {
            try {
                this.inputTilesetName = BrushDatabase.Instance.RenameTileset(this.Tileset, this.inputTilesetName);

                // Defocus name input field.
                GUIUtility.keyboardControl = 0;

                ToolUtility.RepaintBrushPalette();
            }
            catch (ArgumentException ex) {
                EditorUtility.DisplayDialog(
                    TileLang.ParticularText("Error", " Was unable to rename tileset"),
                    ex.Message,
                    TileLang.ParticularText("Action", "OK")
                    );
            }
        }
Example #22
0
        private void CreateTileset(string tilesetName)
        {
            // Create folder for atlas assets.
            string atlasFolder = AssetDatabase.GenerateUniqueAssetPath(BrushUtility.GetBrushAssetPath() + tilesetName);

            Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/" + atlasFolder);

            // Create material for tileset.
            var atlasMaterial = BrushUtility.CreateTilesetMaterial(this.tilesetTexture, this.alpha);

            AssetDatabase.CreateAsset(atlasMaterial, atlasFolder + "/atlas.mat");
            AssetDatabase.ImportAsset(atlasFolder + "/atlas.mat");

            // Use edge correction preset?
            if (this.edgeCorrectionPreset != EdgeCorrectionPreset.Custom)
            {
                this.borderSize = 0;
                this.delta      = (this.edgeCorrectionPreset == EdgeCorrectionPreset.InsetUVs) ? 0.5f : 0f;
            }

            // Calculate metrics for tileset.
            this.RecalculateMetrics();

            // Create tileset.
            var tileset = ScriptableObject.CreateInstance <Tileset>();

            tileset.Initialize(atlasMaterial, this.tilesetTexture, this.tilesetMetrics);
            tileset.procedural = this.procedural;

            // Save tileset and its material to asset file.
            string assetPath = atlasFolder + "/" + tilesetName + ".asset";

            AssetDatabase.CreateAsset(tileset, assetPath);
            AssetDatabase.ImportAsset(assetPath);

            // Ensure that changes are persisted immediately.
            AssetDatabase.SaveAssets();

            // Make sure that "Create Brushes" tab is shown.
            TilesetDesigner.s_SelectedTab = 0;
            ToolUtility.ShowTilesetInDesigner(tileset);

            ToolUtility.RepaintBrushPalette();
        }
        private void _brushList_BrushMouseDown(Brush brush)
        {
            // Double-click to ensure that designer window is shown.
            if (Event.current.clickCount == 2 && brush != null)
            {
                ToolUtility.ShowBrushInDesigner(brush);

                GUIUtility.hotControl = 0;
                GUIUtility.ExitGUI();
                return;
            }

            // If right mouse button was depressed, without holding control key, select
            // as primary brush ready for context menu.
            if (Event.current.button == 1 && !Event.current.control)
            {
                ToolUtility.SelectedBrush = brush;
            }
        }
Example #24
0
        private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            if (!s_EnableScanner)
            {
                return;
            }

            // Check for new brush/tileset assets.
            if (ContainsNewBrushOrTileset(importedAssets))
            {
                BrushDatabase.Instance.Rescan();
                ToolUtility.RepaintBrushPalette();
            }

            // Check for deleted brush/tileset assets.
            BrushDatabase.Instance.ClearMissingRecords();
            ToolUtility.RepaintBrushPalette();
            DesignerWindow.RepaintWindow();
        }
        internal void DrawBrushesGUI()
        {
            this.DrawToolbar();

            if (GUIUtility.keyboardControl == 0)
            {
                ToolManager.Instance.CheckForKeyboardShortcut();
                ToolUtility.CheckToolKeyboardShortcuts();
            }

            GUILayout.Space(-1);

            // Is selected brush (primary or secondary) about to be changed?
            this.brushList.Draw(false);

            this.DrawPrimarySecondaryBrushSwitcher();

            GUILayout.Space(5);
        }
        private void OnSelectedObjectChanged()
        {
            // Finish up with previous brush editor.
            this.UnloadDesignerView();

            if (this.SelectedObject is Brush)
            {
                this.LoadBrushDesignerView();

                if (!this.IsLocked)
                {
                    // Make sure that brush is shown in brush list.
                    this.BrushListModel.SelectedBrush = this.SelectedObject as Brush;
                    ToolUtility.RevealBrush(this.BrushListModel.SelectedBrush, false);
                }
            }
            else if (this.SelectedObject is Tileset)
            {
                this.LoadTilesetDesignerView();

                if (!this.IsLocked)
                {
                    // Make sure that tileset is shown in brush list.
                    this.BrushListModel.View            = BrushListView.Tileset;
                    this.BrushListModel.SelectedTileset = this.SelectedObject as Tileset;
                }
            }

            if (!this.History.IsNavigating)
            {
                if (this.designerView != null && this.SelectedObject != null && this.SelectedObject.Exists)
                {
                    this.currentState = this.designerView.CreateHistoryState();
                    this.History.AddToRecent(this.SelectedObject);
                }
            }

            // Clear active input control.
            this._clearFocusControl = true;

            this.Repaint();
        }
Example #27
0
        private void OnEnable()
        {
            var targetSystem = target as TileSystem;

            // Mark active target as the active tile system?
            //  - Must be part of current user selection!
            //  - Must not reside within an asset.
            if (Selection.activeGameObject == targetSystem.gameObject && Selection.instanceIDs.Length == 1)
            {
                if (!EditorUtility.IsPersistent(this.target) && ToolUtility.ActiveTileSystem != targetSystem)
                {
                    ToolUtility.ActiveTileSystem = targetSystem;

                    // Hide selected wireframe if tool is active.
                    if (ToolManager.Instance.CurrentTool != null)
                    {
                        ToolUtility.HideSelectedWireframe(targetSystem);
                    }
                }
            }
        }
        private static bool OnOpenAsset(int instanceID, int line)
        {
            var asset = EditorUtility.InstanceIDToObject(instanceID);

            var brush = asset as Brush;

            if (brush != null)
            {
                ToolUtility.ShowBrushInDesigner(brush);
                return(true);
            }

            var tileset = asset as Tileset;

            if (tileset != null)
            {
                ToolUtility.ShowTilesetInDesigner(tileset);
                return(true);
            }

            return(false);
        }
        /// <inheritdoc/>
        protected override void DoGUI()
        {
            // Generate a control ID for the palette window so that keyboard focus can be
            // easily removed from the active control.
            int paletteControlID = EditorGUIUtility.GetControlID(FocusType.Keyboard);

            if (this.clearInputFocus || Event.current.type == EventType.MouseDown || Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                this.clearInputFocus             = false;
                EditorGUIUtility.keyboardControl = paletteControlID;
                this.Repaint();
            }

            if (GUIUtility.keyboardControl == paletteControlID)
            {
                ToolManager.Instance.CheckForKeyboardShortcut();
                ToolUtility.CheckToolKeyboardShortcuts();
            }

            this.OnToolSelectorGUI();

            RotorzEditorGUI.DrawHoverTip(this);
        }
        private void AutoAddPostfixToName()
        {
            var tileSystems = ToolUtility.GetAllTileSystemsInScene();

            string baseName  = Regex.Replace(this.currentPreset.SystemName, "#\\d+$", "");
            string nextName  = baseName;
            int    increment = 1;

            while (true)
            {
next:
                foreach (var tileSystem in tileSystems)
                {
                    if (tileSystem.name == nextName)
                    {
                        nextName = string.Format("{0} #{1}", baseName, ++increment);
                        goto next;
                    }
                }
                break;
            }

            this.currentPreset.SystemName = nextName;
        }