static void NamedGeneratorButton(ChiselGeneratorMode generator, Rect togglePosition, GUIStyle style, bool isActive)
        {
            var temp = togglePosition;

            temp.xMin += 5;
            temp.width = 20;
            {
                EditorGUI.BeginChangeCheck();
                var value = GUI.Toggle(temp, generator.InToolBox, GUIContent.none);
                if (EditorGUI.EndChangeCheck())
                {
                    SetInToolBox(generator, value);
                }
            }
            temp       = togglePosition;
            temp.xMin += 25;
            {
                EditorGUI.BeginChangeCheck();
                var content    = ChiselEditorResources.GetIconContentWithName(generator.ToolName, generator.ToolName)[0];
                var isSelected = ChiselGeneratorManager.GeneratorMode == generator;
                var value      = ToggleButton(temp, content, isSelected, style, isActive);
                if (EditorGUI.EndChangeCheck() && value)
                {
                    // TODO: make undoable
                    generator.InToolBox = true;
                    ChiselCreateTool.ActivateTool();
                    ChiselGeneratorManager.GeneratorMode = generator;
                    ChiselEditorSettings.Save();
                    SceneView.RepaintAll();
                }
            }
        }
        static void GeneratorButton(Rect position, ChiselGeneratorMode generator, GUIStyle style, bool isActive)
        {
            EditorGUI.BeginChangeCheck();
            var content    = generator.Content;
            var isSelected = ChiselGeneratorManager.GeneratorMode == generator;
            var value      = ToggleButton(position, content, isSelected && isActive, style, isActive);

            if (EditorGUI.EndChangeCheck())
            {
                if (Event.current.button == 2)
                {
                    ChiselPlacementToolsSelectionWindow.SetInToolBox(generator, false);
                }
                else
                {
                    ChiselCreateTool.ActivateTool();
                    ChiselGeneratorManager.GeneratorMode = generator;
                    if (value)
                    {
                        ChiselEditorSettings.Save();
                    }
                    SceneView.RepaintAll();
                }
            }
        }
Ejemplo n.º 3
0
        internal static void ActivateTool(ChiselGeneratorMode currentTool)
        {
            if (currentTool != null && Tools.hidden)
            {
                Tools.hidden = false;
            }
            if (currentTool == Instance.data.currentGenerator)
            {
                return;
            }
            if (currentTool != null && Tools.hidden)
            {
                Tools.hidden = false;
            }

            var prevTool = Instance.data.currentGenerator;

            if (prevTool != null)
            {
                prevTool.OnDeactivate();
            }
            Instance.data.currentGenerator = null;
            if (currentTool != null)
            {
                currentTool.OnActivate();
            }
            Instance.data.currentGenerator = currentTool;

            ChiselToolsOverlay.UpdateCreateToolIcon();

            GeneratorSelectionChanged?.Invoke(prevTool, currentTool);
        }
 // TODO: move somewhere else
 public static void SetInToolBox(ChiselGeneratorMode generator, bool value)
 {
     // TODO: make undoable
     generator.InToolBox = value;
     if (ChiselGeneratorManager.GeneratorMode == generator)
     {
         if (!DeselectGeneratorMode())
         {
             generator.InToolBox = true;
         }
     }
     ChiselEditorSettings.Save();
     if (Event.current.type != EventType.Repaint)
     {
         SceneView.RepaintAll();
     }
 }
 public void GeneratorSelectionChanged(ChiselGeneratorMode prevGenerator, ChiselGeneratorMode nextGenerator)
 {
     Repaint();
 }