static bool Toggle(Rect position, ChiselEditToolBase editMode, Type editModeType, GUIStyle style) { var selected = ToolManager.activeToolType == editModeType; var content = selected ? editMode.ActiveIconContent : editMode.IconContent; return(GUI.Toggle(position, selected, content, style)); }
public override void OnToolGUI(EditorWindow window) { if (lastSelectedTool == null || lastSelectedTool != this) { if (lastSelectedTool != null) { lastSelectedTool.OnDeactivate(); } lastSelectedTool = this; OnActivate(); } var sceneView = window as SceneView; var dragArea = sceneView.position; dragArea.position = Vector2.zero; ChiselOptionsOverlay.AdditionalSettings = null; ChiselOptionsOverlay.SetTitle(OptionsTitle); OnSceneGUI(sceneView, dragArea); ChiselOptionsOverlay.Show(); ChiselToolsOverlay.Show(); ChiselSnappingOptionsOverlay.Show(); }
public virtual void OnActivate() { lastSelectedTool = this; lastRememberedToolType = this.GetType(); UnitySceneExtensions.Snapping.SnapMask = ToolUsedSnappingModes; SnapSettingChanged?.Invoke(); }
static void OnDuringSceneGUI(SceneView sceneView) { // Workaround to Unity stop redrawing sceneview after a second, which makes hovering over edge visualization stop working if (Event.current.type == EventType.MouseMove) { sceneView.Repaint(); } var prevSkin = GUI.skin; GUI.skin = ChiselSceneGUIStyle.GetSceneSkin(); try { ChiselSceneGUIStyle.Update(); ChiselGridSettings.GridOnSceneGUI(sceneView); ChiselOutlineRenderer.Instance.OnSceneGUI(sceneView); if (EditorWindow.mouseOverWindow == sceneView || // This helps prevent weird issues with overlapping sceneviews + avoid some performance issues with multiple sceneviews open (Event.current.type != EventType.MouseMove && Event.current.type != EventType.Layout)) { ChiselDragAndDropManager.Instance.OnSceneGUI(sceneView); ChiselClickSelectionManager.Instance.OnSceneGUI(sceneView); } if (Tools.current != Tool.Custom) { ChiselEditToolBase.ShowDefaultOverlay(); } } finally { GUI.skin = prevSkin; } }
// TODO: move to dedicated manager internal static void Register(ChiselEditToolBase editMode) { if (editMode.GetType() == typeof(ChiselCreateTool)) { return; } editModes[editMode.ToolName] = editMode; }
internal static void Register(ChiselEditToolBase editMode) { if (editMode.GetType() == typeof(ChiselPlacementTool)) { return; } editModes[editMode.ToolName] = editMode; editMode.UpdateIcon(); }
public void ToolNotActivatingBugWorkAround() { if (lastSelectedTool == null) { if (EditorTools.activeToolType == this.GetType()) { OnActivate(); lastSelectedTool = this; } } }
void OnToolModeChanged() { if (Tools.current != Tool.Custom) { ChiselEditToolBase.ClearLastRememberedType(); return; } if (!typeof(ChiselEditToolBase).IsAssignableFrom(ToolManager.activeToolType)) { ChiselEditToolBase.ClearLastRememberedType(); } }
static void EditModeButton(Rect position, bool enabled, ChiselEditToolBase editMode, GUIStyle style) { var editModeType = editMode.GetType(); using (new EditorGUI.DisabledScope(!enabled)) { EditorGUI.BeginChangeCheck(); var value = Toggle(position, editMode, editModeType, style); if (EditorGUI.EndChangeCheck() && value) { ToolManager.SetActiveTool(editModeType); ChiselEditorSettings.Save(); } } }
public virtual void OnActivate() { lastSelectedTool = this; UnitySceneExtensions.Snapping.SnapMask = ToolUsedSnappingModes; }
private static void OnSelectionChanged() { ChiselClickSelectionManager.Instance.OnSelectionChanged(); ChiselOutlineRenderer.Instance.OnSelectionChanged(); ChiselEditToolBase.NotifyOnSelectionChanged(); }