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 BoxSettingsGUI(GeneratorBox generator, bool isSceneGUI) { var distanceUnit = RealtimeCSG.CSGSettings.DistanceUnit; var nextUnit = Units.CycleToNextUnit(distanceUnit); var unitText = Units.GetUnitGUIContent(distanceUnit); GUILayout.BeginVertical(CSG_GUIStyleUtility.ContentEmpty); { { GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { GUILayout.Label(HeightContent, Width65); var height = generator.HaveHeight ? generator.Height : GeometryUtility.CleanLength(generator.DefaultHeight); EditorGUI.BeginChangeCheck(); { height = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, height))); } if (EditorGUI.EndChangeCheck()) { if (generator.HaveHeight) { generator.Height = height; } else { generator.DefaultHeight = height; } } if (GUILayout.Button(unitText, EditorStyles.miniLabel, Width25)) { distanceUnit = nextUnit; RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit; RealtimeCSG.CSGSettings.UpdateSnapSettings(); RealtimeCSG.CSGSettings.Save(); CSG_EditorGUIUtility.RepaintAll(); } } GUILayout.EndHorizontal(); TooltipUtility.SetToolTip(HeightTooltip); } EditorGUI.BeginDisabledGroup(!generator.CanCommit); { GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { GUILayout.Label(LengthContent, Width65); var length = generator.Length; EditorGUI.BeginChangeCheck(); { length = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, length))); } if (EditorGUI.EndChangeCheck()) { generator.Length = length; } if (GUILayout.Button(unitText, EditorStyles.miniLabel, Width25)) { distanceUnit = nextUnit; RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit; RealtimeCSG.CSGSettings.UpdateSnapSettings(); RealtimeCSG.CSGSettings.Save(); CSG_EditorGUIUtility.RepaintAll(); } } GUILayout.EndHorizontal(); TooltipUtility.SetToolTip(LengthTooltip); GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { GUILayout.Label(WidthContent, Width65); var width = generator.Width; EditorGUI.BeginChangeCheck(); { width = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, width))); } if (EditorGUI.EndChangeCheck()) { generator.Width = width; } if (GUILayout.Button(unitText, EditorStyles.miniLabel, Width25)) { distanceUnit = nextUnit; RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit; RealtimeCSG.CSGSettings.UpdateSnapSettings(); RealtimeCSG.CSGSettings.Save(); CSG_EditorGUIUtility.RepaintAll(); } } GUILayout.EndHorizontal(); TooltipUtility.SetToolTip(WidthTooltip); } EditorGUI.EndDisabledGroup(); } GUILayout.EndVertical(); }
public static bool OnShowGUI(GeneratorBox generator, bool isSceneGUI) { CSG_GUIStyleUtility.InitStyles(); OnGUIContents(generator, isSceneGUI); return(true); }
static void OnGUIContents(GeneratorBox generator, bool isSceneGUI) { //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) { BoxSettingsGUI(generator, isSceneGUI: true); } } GUILayout.EndHorizontal(); if (!isSceneGUI) { GUILayout.Space(5); BoxSettingsGUI(generator, isSceneGUI: false); //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(); }