Exemple #1
0
        static void NamedGeneratorButton(ChiselPlacementToolInstance 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;
                    ChiselPlacementTool.ActivateTool();
                    ChiselGeneratorManager.GeneratorMode = generator;
                    ChiselEditorSettings.Save();
                    SceneView.RepaintAll();
                }
            }
        }
Exemple #2
0
        static void GeneratorButton(Rect position, ChiselPlacementToolInstance 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
                {
                    if (value)
                    {
                        ChiselPlacementTool.ActivateTool();
                        ChiselGeneratorManager.GeneratorMode = generator;
                        ChiselEditorSettings.Save();
                    }
                    SceneView.RepaintAll();
                }
            }
        }