示例#1
0
        void ResetTool()
        {
            Grid.ForceGrid = false;
            if (!freedrawGenerator)
            {
                freedrawGenerator = ScriptableObject.CreateInstance <FreeDrawGenerator>();
                freedrawGenerator.snapFunction    = CSGBrushEditorManager.SnapPointToGrid;
                freedrawGenerator.raySnapFunction = CSGBrushEditorManager.SnapPointToRay;
                freedrawGenerator.shapeCancelled  = OnShapeCancelledEvent;
                freedrawGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }
            if (!cylinderGenerator)
            {
                cylinderGenerator = ScriptableObject.CreateInstance <CylinderGenerator>();
                cylinderGenerator.snapFunction    = CSGBrushEditorManager.SnapPointToGrid;
                cylinderGenerator.raySnapFunction = CSGBrushEditorManager.SnapPointToRay;
                cylinderGenerator.shapeCancelled  = OnShapeCancelledEvent;
                cylinderGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }
            if (!boxGenerator)
            {
                boxGenerator = ScriptableObject.CreateInstance <BoxGenerator>();
                boxGenerator.snapFunction    = CSGBrushEditorManager.SnapPointToGrid;
                boxGenerator.raySnapFunction = CSGBrushEditorManager.SnapPointToRay;
                boxGenerator.shapeCancelled  = OnShapeCancelledEvent;
                boxGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }
            if (!sphereGenerator)
            {
                sphereGenerator = ScriptableObject.CreateInstance <SphereGenerator>();
                sphereGenerator.snapFunction    = CSGBrushEditorManager.SnapPointToGrid;
                sphereGenerator.raySnapFunction = CSGBrushEditorManager.SnapPointToRay;
                sphereGenerator.shapeCancelled  = OnShapeCancelledEvent;
                sphereGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }

            var generator = InternalCurrentGenerator;

            if (generator != null)
            {
                var obj = generator as ScriptableObject;
                if (obj)
                {
                    generator.Init();
                }
            }
        }
示例#2
0
 static void CylinderSettingsGUI(CylinderGenerator generator, bool isSceneGUI)
 {
     if (isSceneGUI)
     {
         GUILayout.BeginHorizontal(GUILayout.MinWidth(0));
     }
     {
         if (isSceneGUI)
         {
             GUILayout.BeginVertical(width110);
         }
         {
             generator.CircleSmoothShading = SettingsToggle(generator.CircleSmoothShading, SmoothShadingContent, width110, isSceneGUI);
             TooltipUtility.SetToolTip(SmoothShadingTooltip);
             generator.CircleDistanceToSide = SettingsToggle(generator.CircleDistanceToSide, AlignToSideContent, width110, isSceneGUI);
             TooltipUtility.SetToolTip(AlignToSideTooltip);
         }
         if (isSceneGUI)
         {
             GUILayout.EndVertical();
             GUILayout.BeginVertical(width80);
         }
         {
             generator.CircleSingleSurfaceEnds = !SettingsToggle(!generator.CircleSingleSurfaceEnds, RadialCapsContent, width80, isSceneGUI);
             TooltipUtility.SetToolTip(RadialCapsTooltip);
             generator.CircleRecenter = SettingsToggle(generator.CircleRecenter, FitShapeContent, width80, isSceneGUI);
             TooltipUtility.SetToolTip(FitShapeTooltip);
         }
         if (isSceneGUI)
         {
             GUILayout.EndVertical();
         }
     }
     if (isSceneGUI)
     {
         GUILayout.EndHorizontal();
     }
 }
示例#3
0
 public static bool OnShowGUI(CylinderGenerator generator, bool isSceneGUI)
 {
     GUIStyleUtility.InitStyles();
     OnGUIContents(generator, isSceneGUI);
     return(true);
 }
示例#4
0
        static void OnGUIContents(CylinderGenerator generator, bool isSceneGUI)
        {
            //GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
            //{
            //bool enabled = generator.HaveBrushes;
            GUILayout.BeginHorizontal(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 = GUIStyleUtility.ChooseOperation(operation, mixedValues);
                 *              if (EditorGUI.EndChangeCheck())
                 *              {
                 *                      generator.CurrentCSGOperationType = operation;
                 *              }
                 *      }
                 *      GUILayout.EndVertical();
                 * }
                 * EditorGUI.EndDisabledGroup();
                 */
                if (isSceneGUI)
                {
                    CylinderSettingsGUI(generator, isSceneGUI);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
            {
                var distanceUnit = RealtimeCSG.CSGSettings.DistanceUnit;
                var nextUnit     = Units.CycleToNextUnit(distanceUnit);
                var unitText     = Units.GetUnitGUIContent(distanceUnit);
                GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                {
                    GUILayout.Label(HeightContent, width65);
                    if (isSceneGUI)
                    {
                        TooltipUtility.SetToolTip(HeightTooltip);
                    }
                    var height = generator.HaveHeight ? generator.Height : GeometryUtility.CleanLength(generator.DefaultHeight);
                    EditorGUI.BeginChangeCheck();
                    {
                        if (!isSceneGUI)
                        {
                            height = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, height)));
                        }
                        else
                        {
                            height = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, height), width65));
                        }
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (generator.HaveHeight)
                        {
                            generator.Height = height;
                        }
                        else
                        {
                            generator.DefaultHeight = height;
                        }
                    }
                    if (GUILayout.Button(unitText, EditorStyles.miniLabel, width20))
                    {
                        distanceUnit = nextUnit;
                        RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit;
                        RealtimeCSG.CSGSettings.UpdateSnapSettings();
                        RealtimeCSG.CSGSettings.Save();
                        SceneView.RepaintAll();
                    }
                }
                //if (!isSceneGUI)
                {
                    GUILayout.EndHorizontal();
                    TooltipUtility.SetToolTip(HeightTooltip);
                    GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                }
                //else
                //{
                //	GUILayout.Space(12);
                //}
                {
                    EditorGUI.BeginDisabledGroup(!generator.CanCommit);
                    {
                        GUILayout.Label(RadiusContent, width65);
                        if (isSceneGUI)
                        {
                            TooltipUtility.SetToolTip(RadiusTooltip);
                        }
                        var radius = generator.RadiusA;
                        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.RadiusA = radius;
                        }
                        if (GUILayout.Button(unitText, EditorStyles.miniLabel, width20))
                        {
                            distanceUnit = nextUnit;
                            RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit;
                            RealtimeCSG.CSGSettings.UpdateSnapSettings();
                            RealtimeCSG.CSGSettings.Save();
                            SceneView.RepaintAll();
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();
                if (!isSceneGUI)
                {
                    TooltipUtility.SetToolTip(RadiusTooltip);
                }
            }
            GUILayout.EndVertical();

            {
                generator.CircleSides = IntSettingsSlider(generator.CircleSides, 3, 144, SidesContent, isSceneGUI);
                TooltipUtility.SetToolTip(SidesTooltip);
            }
            {
                generator.CircleOffset = SettingsSlider(generator.CircleOffset, 0, 360, OffsetContent, isSceneGUI);
                TooltipUtility.SetToolTip(OffsetTooltip);
            }



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

                CylinderSettingsGUI(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();
        }