static StairsBottom EnumValueSettings(StairsBottom value, GUIContent content, ToolTip tooltip, bool isSceneGUI) { StairsBottom newValue; EditorGUI.BeginChangeCheck(); { GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { GUILayout.Label(content, width80); if (isSceneGUI) { TooltipUtility.SetToolTip(tooltip); } if (!isSceneGUI) { newValue = (StairsBottom)EditorGUILayout.EnumPopup(value); } else { newValue = (StairsBottom)EditorGUILayout.EnumPopup(value, width65); } } GUILayout.EndHorizontal(); if (!isSceneGUI) { TooltipUtility.SetToolTip(tooltip); } } if (EditorGUI.EndChangeCheck()) { return(newValue); } return(value); }
public void Reset() { stepDepth = RealtimeCSG.CSGSettings.LinearStairsStepLength; stepHeight = RealtimeCSG.CSGSettings.LinearStairsStepHeight; stairsWidth = RealtimeCSG.CSGSettings.LinearStairsStepWidth; totalSteps = Mathf.Max(1, RealtimeCSG.CSGSettings.LinearStairsTotalSteps); stairsDepth = RealtimeCSG.CSGSettings.LinearStairsLength; stairsHeight = RealtimeCSG.CSGSettings.LinearStairsHeight; extraDepth = RealtimeCSG.CSGSettings.LinearStairsLengthOffset; extraHeight = RealtimeCSG.CSGSettings.LinearStairsHeightOffset; stairsBottom = RealtimeCSG.CSGSettings.LinearStairsBottom; vertices = new Vector3[0]; extraDepth = 0; extraHeight = 0; bounds.Reset(); }
private bool GenerateStairs(CSGBrush[] stepBrushes, int totalSteps, float stepLength, float stepHeight, float stepDepth, float stairsDepth, float stairsWidth, float stairsHeight, float extraDepth, float extraHeight, StairsBottom stairsBottom) { //var currentModel = parentModel ? parentModel : SelectionUtility.LastUsedModel; //var modelRotation = Quaternion.Inverse(currentModel.transform.rotation); stairsDepth = Math.Max(0, stairsDepth); bool success = true; for (int stepIndex = 0; stepIndex < totalSteps; stepIndex++) { var brush = stepBrushes[stepIndex]; if (!brush) { continue; } float curStepDepth; float curStepHeight; float curStepY; Vector3 extraLength; Vector3 lengthPos; switch (stairsBottom) { default: case StairsBottom.Filled: { curStepHeight = Mathf.Min(stairsHeight, (stepIndex == 0) ? (extraHeight + stepHeight) : stepHeight); curStepY = (stepIndex == 0) ? (stepHeight * stepIndex) : (extraHeight + (stepHeight * stepIndex)); extraLength = lengthDirection * (stepLength * stepIndex); curStepDepth = stairsDepth; lengthPos = Vector3.zero; break; } case StairsBottom.Steps: { curStepHeight = stepHeight; curStepY = extraHeight + (stepHeight * stepIndex); extraLength = Vector3.zero; curStepDepth = (stepIndex == totalSteps - 1) ? (stepDepth + extraDepth) : stepDepth; lengthPos = (stepIndex == totalSteps - 1) ? Vector3.zero : (lengthDirection * Mathf.Max(0, ((totalSteps - (stepIndex + 1)) * stepDepth) + extraDepth)); break; } } var heightPos = heightDirection * curStepY; var widthSize = (widthDirection * stairsWidth); var lengthSize = (lengthDirection * curStepDepth) - extraLength; var heightSize = (heightDirection * curStepHeight); var size = widthSize + heightSize + lengthSize; var position = (totalSteps == 1) ? (heightPos + lengthPos + brushPosition) : (heightPos + lengthPos); ControlMesh newControlMesh; Shape newShape; if (!BrushFactory.CreateCubeControlMesh(out newControlMesh, out newShape, Vector3.zero, size)) { success = false; if (brush.gameObject.activeSelf) { brush.gameObject.SetActive(false); } continue; } if (!brush.gameObject.activeSelf) { brush.gameObject.SetActive(true); } brush.Shape = newShape; brush.ControlMesh = newControlMesh; if (totalSteps != 1) { brush.transform.localPosition = position; } //brush.transform.localRotation = Quaternion.identity; SurfaceUtility.TranslateSurfacesInWorldSpace(brush, -position); } return(success); }