/// <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(); }
/// <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(); }
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(); }); }
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); }
/// <summary> /// Selects tool for use within custom system. /// </summary> /// <param name="tool">Tool that is to be selected. Specify `null` to /// revert to previous Unity tool.</param> /// <returns> /// Instance of tool that was selected. /// </returns> public ToolBase SelectTool(ToolBase tool) { if (tool != null) { this.AutoActivateTileSystem(); if (ToolUtility.ActiveTileSystem == null) { // Deselect tool because no tile system is selected! tool = null; } else if (this.currentTool == null) { // Reveal active tile system in scene palette when tool is first activated. // Let's not keep scrolling to the active tile system each time the user // selects another tool since this can be quite annoying! ToolUtility.RevealTileSystem(ToolUtility.ActiveTileSystem, false); // Automatically show tool palette upon activating tool if specified // in user preferences. if (RtsPreferences.AutoShowToolPalette) { ToolUtility.ShowToolPalette(false); } } } if (tool != null) { // Should current Unity tool be preserved whilst custom tool is used? if (UnityEditor.Tools.current != Tool.None) { this.previousUnityTool = UnityEditor.Tools.current; UnityEditor.Tools.current = Tool.None; } } else if (UnityEditor.Tools.current == Tool.None) { // Revert back to former Unity tool because tool has been deselected! UnityEditor.Tools.current = this.previousUnityTool; } // Will tool selection actually change? if (tool == this.currentTool) { return(tool); } // Reset active plop reference to avoid issues when switching tools. ToolUtility.ActivePlop = null; if (this.currentTool != null) { this.previousTool = this.currentTool; } // Switch to specified tool. var oldTool = this.currentTool; this.currentTool = tool; if (oldTool != null) { oldTool.OnDisable(); } if (tool != null) { if (oldTool == null) { // No tool was active prior to using this method to select a tool. this.BeginEditMode(); } tool.OnEnable(); } else if (oldTool != null) { // A tool was active prior to using this method to deselect tool. this.ExitEditMode(); } // Raise event for tool change. if (this.ToolChanged != null) { try { this.ToolChanged(oldTool, this.currentTool); } catch (Exception ex) { Debug.LogException(ex); } } ToolUtility.RepaintToolPalette(); // Brush palette only needs to be repainted when tool is first selected or deselected. if (oldTool == null || tool == null) { ToolUtility.RepaintBrushPalette(); } SceneView.RepaintAll(); return(tool); }
/// <inheritdoc/> public override void OnCheckKeyboardShortcuts() { bool usingNozzleRadius = (ToolUtility.BrushNozzle == BrushNozzle.Round); int nozzleSizeIncrement = usingNozzleRadius ? 2 : 1; switch (Event.current.type) { case EventType.ScrollWheel: s_WheelRadius -= Event.current.delta.y; if (Mathf.Abs(s_WheelRadius) >= 0.25f) { this.OnMouseWheel(s_WheelRadius >= 0f ? +1f : -1f); s_WheelRadius = 0f; } break; case EventType.KeyDown: switch (Event.current.keyCode) { // Increase/decrease brush radius: case KeyCode.LeftBracket: this.NozzleSize -= nozzleSizeIncrement; ToolUtility.RepaintToolPalette(); SceneView.RepaintAll(); Event.current.Use(); break; case KeyCode.RightBracket: this.NozzleSize += nozzleSizeIncrement; ToolUtility.RepaintToolPalette(); SceneView.RepaintAll(); Event.current.Use(); break; // Increase/decrease variation offset. case KeyCode.Alpha0: if (this.EnableVariationShifting && !this.TemporarilyDisableVariationShifting) { this.VariationShiftCount = 0; Event.current.Use(); } break; case KeyCode.Minus: case KeyCode.KeypadMinus: if (this.EnableVariationShifting && !this.TemporarilyDisableVariationShifting) { --this.VariationShiftCount; Event.current.Use(); } break; case KeyCode.Plus: case KeyCode.Equals: case KeyCode.KeypadPlus: if (this.EnableVariationShifting && !this.TemporarilyDisableVariationShifting) { ++this.VariationShiftCount; Event.current.Use(); } break; } break; } }