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));
        }
Exemple #2
0
        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();
        }
Exemple #3
0
 public virtual void OnActivate()
 {
     lastSelectedTool       = this;
     lastRememberedToolType = this.GetType();
     UnitySceneExtensions.Snapping.SnapMask = ToolUsedSnappingModes;
     SnapSettingChanged?.Invoke();
 }
Exemple #4
0
        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;
 }
Exemple #6
0
 internal static void Register(ChiselEditToolBase editMode)
 {
     if (editMode.GetType() == typeof(ChiselPlacementTool))
     {
         return;
     }
     editModes[editMode.ToolName] = editMode;
     editMode.UpdateIcon();
 }
Exemple #7
0
 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();
                }
            }
        }
Exemple #10
0
 public virtual void OnActivate()
 {
     lastSelectedTool = this;
     UnitySceneExtensions.Snapping.SnapMask = ToolUsedSnappingModes;
 }
Exemple #11
0
 private static void OnSelectionChanged()
 {
     ChiselClickSelectionManager.Instance.OnSelectionChanged();
     ChiselOutlineRenderer.Instance.OnSelectionChanged();
     ChiselEditToolBase.NotifyOnSelectionChanged();
 }