static void OnGUIContents(GeneratorSpiralStairs generator, bool isSceneGUI)
        {
            GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty);
            {
                EditorGUI.BeginChangeCheck();
                var totalSteps = Mathf.Max(IntValueSettings(generator.TotalSteps, TotalStepsContent, TotalStepsTooltip, isSceneGUI), 1);
                if (EditorGUI.EndChangeCheck())
                {
                    generator.TotalSteps = totalSteps;
                }

                EditorGUI.BeginChangeCheck();
                var stepDepth = Mathf.Max(FloatUnitsSettings(generator.StepDepth, StepDepthContent, StepDepthTooltip, isSceneGUI), GeneratorSpiralStairsSettings.kMinStepDepth);
                if (EditorGUI.EndChangeCheck())
                {
                    generator.StepDepth = stepDepth;
                }

                EditorGUI.BeginChangeCheck();
                var stepHeight = Mathf.Max(FloatUnitsSettings(generator.StepHeight, StepHeightContent, StepHeightTooltip, isSceneGUI), GeneratorSpiralStairsSettings.kMinStepHeight);
                if (EditorGUI.EndChangeCheck())
                {
                    generator.StepHeight = stepHeight;
                }

                GUILayout.Space(4);

                EditorGUI.BeginChangeCheck();
                var stairsWidth = Mathf.Max(FloatUnitsSettings(generator.StairsWidth, StairsWidthContent, StairsWidthTooltip, isSceneGUI), 0.01f);
                if (EditorGUI.EndChangeCheck())
                {
                    generator.StairsWidth = stairsWidth;
                }

                EditorGUI.BeginChangeCheck();
                var stairsHeight = Mathf.Max(FloatUnitsSettings(generator.StairsHeight, StairsHeightContent, StairsHeightTooltip, isSceneGUI), 0.01f);
                if (EditorGUI.EndChangeCheck())
                {
                    generator.StairsHeight = stairsHeight;
                }

                EditorGUI.BeginChangeCheck();
                var stairsDepth = Mathf.Max(FloatUnitsSettings(generator.StairsDepth, StairsDepthContent, StairsDepthTooltip, isSceneGUI), 0.01f);
                if (EditorGUI.EndChangeCheck())
                {
                    generator.StairsDepth = stairsDepth;
                }

                GUILayout.Space(4);

                EditorGUI.BeginChangeCheck();
                var extraDepth = Mathf.Max(FloatUnitsSettings(generator.ExtraDepth, ExtraDepthContent, ExtraDepthTooltip, isSceneGUI), 0);
                if (EditorGUI.EndChangeCheck())
                {
                    generator.ExtraDepth = extraDepth;
                }

                EditorGUI.BeginChangeCheck();
                var extraHeight = Mathf.Max(FloatUnitsSettings(generator.ExtraHeight, ExtraHeightContent, ExtraHeightTooltip, isSceneGUI), 0);
                if (EditorGUI.EndChangeCheck())
                {
                    generator.ExtraHeight = extraHeight;
                }
            }
            GUILayout.EndVertical();
        }
示例#2
0
        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();
                }
            }
        }
 public static bool OnShowGUI(GeneratorSpiralStairs generator, bool isSceneGUI)
 {
     CSG_GUIStyleUtility.InitStyles();
     OnGUIContents(generator, isSceneGUI);
     return(true);
 }