public static bool OnShowGUI(GeneratorSphere generator, bool isSceneGUI)
        {
            CSG_GUIStyleUtility.InitStyles();
            OnGUIContents(generator, isSceneGUI);

            return(true);
        }
 static void SphereSettingsGUI(GeneratorSphere generator, bool isSceneGUI)
 {
     GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
     {
         generator.SphereSmoothShading = SettingsToggle(generator.SphereSmoothShading, SmoothShadingContent, isSceneGUI);
         TooltipUtility.SetToolTip(SmoothShadingTooltip);
         generator.IsHemiSphere = SettingsToggle(generator.IsHemiSphere, HemiSphereContent, isSceneGUI);
         TooltipUtility.SetToolTip(HemiSphereTooltip);
     }
     GUILayout.EndVertical();
 }
        void ResetTool()
        {
            RealtimeCSG.CSGGrid.ForceGrid = false;
            if (!freedrawGenerator)
            {
                freedrawGenerator = ScriptableObject.CreateInstance <GeneratorFreeDraw>();
                freedrawGenerator.snapFunction    = EditModeManager.SnapPointToGrid;
                freedrawGenerator.raySnapFunction = EditModeManager.SnapPointToRay;
                freedrawGenerator.shapeCancelled  = OnShapeCancelledEvent;
                freedrawGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }
            if (!cylinderGenerator)
            {
                cylinderGenerator = ScriptableObject.CreateInstance <GeneratorCylinder>();
                cylinderGenerator.snapFunction    = EditModeManager.SnapPointToGrid;
                cylinderGenerator.raySnapFunction = EditModeManager.SnapPointToRay;
                cylinderGenerator.shapeCancelled  = OnShapeCancelledEvent;
                cylinderGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }
            if (!boxGenerator)
            {
                boxGenerator = ScriptableObject.CreateInstance <GeneratorBox>();
                boxGenerator.snapFunction    = EditModeManager.SnapPointToGrid;
                boxGenerator.raySnapFunction = EditModeManager.SnapPointToRay;
                boxGenerator.shapeCancelled  = OnShapeCancelledEvent;
                boxGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }
            if (!sphereGenerator)
            {
                sphereGenerator = ScriptableObject.CreateInstance <GeneratorSphere>();
                sphereGenerator.snapFunction    = EditModeManager.SnapPointToGrid;
                sphereGenerator.raySnapFunction = EditModeManager.SnapPointToRay;
                sphereGenerator.shapeCancelled  = OnShapeCancelledEvent;
                sphereGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }
            if (!linearStairsGenerator)
            {
                linearStairsGenerator = ScriptableObject.CreateInstance <GeneratorLinearStairs>();
                linearStairsGenerator.snapFunction    = EditModeManager.SnapPointToGrid;
                linearStairsGenerator.raySnapFunction = EditModeManager.SnapPointToRay;
                linearStairsGenerator.shapeCancelled  = OnShapeCancelledEvent;
                linearStairsGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }
            if (!spiralStairsGenerator)
            {
                spiralStairsGenerator = ScriptableObject.CreateInstance <GeneratorSpiralStairs>();
                spiralStairsGenerator.snapFunction    = EditModeManager.SnapPointToGrid;
                spiralStairsGenerator.raySnapFunction = EditModeManager.SnapPointToRay;
                spiralStairsGenerator.shapeCancelled  = OnShapeCancelledEvent;
                spiralStairsGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }

            var generator = InternalCurrentGenerator;

            if (generator != null)
            {
                var obj = generator as ScriptableObject;
                if (obj)
                {
                    generator.Init();
                }
            }
        }
        static void OnGUIContents(GeneratorSphere generator, bool isSceneGUI)
        {
            var distanceUnit = RealtimeCSG.CSGSettings.DistanceUnit;
            var nextUnit     = Units.CycleToNextUnit(distanceUnit);
            var unitText     = Units.GetUnitGUIContent(distanceUnit);

            //GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
            //{
            //bool enabled = generator.HaveBrushes;
            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
            {
                /*
                 * EditorGUI.BeginDisabledGroup(!enabled);
                 * {
                 *      if (isSceneGUI)
                 *              GUILayout.BeginVertical(GUI.skin.box, width100);
                 *      else
                 *              GUILayout.BeginVertical(GUIStyle.none);
                 *      {
                 *              bool mixedValues = !enabled;
                 *              CSGOperationType operation = generator.CurrentCSGOperationType;
                 *              EditorGUI.BeginChangeCheck();
                 *              operation = CSG_EditorGUIUtility.ChooseOperation(operation, mixedValues);
                 *              if (EditorGUI.EndChangeCheck())
                 *              {
                 *                      generator.CurrentCSGOperationType = operation;
                 *              }
                 *      }
                 *      GUILayout.EndVertical();
                 * }
                 * EditorGUI.EndDisabledGroup();
                 */
                if (isSceneGUI)
                {
                    SphereSettingsGUI(generator, isSceneGUI);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
            {
                GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                {
                    EditorGUI.BeginDisabledGroup(!generator.CanCommit);
                    {
                        GUILayout.Label(RadiusContent, width65);
                        if (isSceneGUI)
                        {
                            TooltipUtility.SetToolTip(RadiusTooltip);
                        }
                        var radius = generator.SphereRadius;
                        EditorGUI.BeginChangeCheck();
                        {
                            if (!isSceneGUI)
                            {
                                radius = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, radius)));
                            }
                            else
                            {
                                radius = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, radius), width65));
                            }
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            generator.SphereRadius = radius;
                        }
                        if (GUILayout.Button(unitText, EditorStyles.miniLabel, width25))
                        {
                            distanceUnit = nextUnit;
                            RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit;
                            RealtimeCSG.CSGSettings.UpdateSnapSettings();
                            RealtimeCSG.CSGSettings.Save();
                            CSG_EditorGUIUtility.UpdateSceneViews();
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();
                if (!isSceneGUI)
                {
                    TooltipUtility.SetToolTip(RadiusTooltip);
                }

                {
                    generator.SphereSplits = IntSettingsSlider(generator.SphereSplits, 1, RealtimeCSG.CSGSettings.MaxSphereSplits, SplitsContent, isSceneGUI);
                    TooltipUtility.SetToolTip(SplitsTooltip);
                }
                {
                    generator.SphereOffset = SettingsSlider(generator.SphereOffset, 0, 360, OffsetContent, isSceneGUI);
                    TooltipUtility.SetToolTip(OffsetTooltip);
                }
            }
            GUILayout.EndVertical();

            if (!isSceneGUI)
            {
                GUILayout.Space(5);

                SphereSettingsGUI(generator, isSceneGUI);

                //GUILayout.Space(10);
            }                    /* else
                                  * {
                                  *     GUILayout.Space(10);
                                  * }*/
                                 /*
                                  * EditorGUI.BeginDisabledGroup(!generator.CanCommit);
                                  * {
                                  *      GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                                  *      {
                                  *              if (GUILayout.Button(CommitContent)) { generator.DoCommit(); }
                                  *              TooltipUtility.SetToolTip(CommitTooltip);
                                  *              if (GUILayout.Button(CancelContent)) { generator.DoCancel(); }
                                  *              TooltipUtility.SetToolTip(CancelTooltip);
                                  *      }
                                  *      GUILayout.EndHorizontal();
                                  * }
                                  * EditorGUI.EndDisabledGroup();
                                  */
            //}
            //GUILayout.EndVertical();
        }
        static void OnGUIContents(GeneratorSphere generator, bool isSceneGUI)
        {
            var distanceUnit = RealtimeCSG.CSGSettings.DistanceUnit;
            var nextUnit     = Units.CycleToNextUnit(distanceUnit);
            var unitText     = Units.GetUnitGUIContent(distanceUnit);

            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
            {
                if (isSceneGUI)
                {
                    SphereSettingsGUI(generator, isSceneGUI);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
            {
                GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
                {
                    EditorGUI.BeginDisabledGroup(!generator.CanCommit);
                    {
                        GUILayout.Label(RadiusContent, width65);

                        if (isSceneGUI)
                        {
                            TooltipUtility.SetToolTip(RadiusTooltip);
                        }

                        var radius = generator.SphereRadius;
                        EditorGUI.BeginChangeCheck();
                        {
                            if (!isSceneGUI)
                            {
                                radius = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, radius)));
                            }
                            else
                            {
                                radius = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, radius), width65));
                            }
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            generator.SphereRadius = radius;
                        }

                        if (GUILayout.Button(unitText, EditorStyles.miniLabel, width25))
                        {
                            distanceUnit = nextUnit;
                            RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit;
                            RealtimeCSG.CSGSettings.UpdateSnapSettings();
                            RealtimeCSG.CSGSettings.Save();
                            CSG_EditorGUIUtility.RepaintAll();
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }

                GUILayout.EndHorizontal();

                if (!isSceneGUI)
                {
                    TooltipUtility.SetToolTip(RadiusTooltip);
                }


                generator.SphereSplits = IntSettingsControl
                                         (
                    generator.SphereSplits,
                    1,
                    RealtimeCSG.CSGSettings.MaxSphereSplits,
                    SplitsContent,
                    isSceneGUI
                                         );

                TooltipUtility.SetToolTip(SplitsTooltip);

                generator.SphereOffset = FloatSettingsControl
                                         (
                    generator.SphereOffset,
                    0,
                    360,
                    OffsetContent,
                    isSceneGUI
                                         );

                TooltipUtility.SetToolTip(OffsetTooltip);
            }

            GUILayout.EndVertical();

            if (!isSceneGUI)
            {
                GUILayout.Space(5);

                SphereSettingsGUI(generator, isSceneGUI);
            }
        }