private void Translate(int verticalOffset) { if (computer.hasMorph && !MorphWindow.editShapeMode) { return; } Rect barRect = new Rect(0f, verticalOffset, Screen.width, 35 * scale); if (barRect.Contains(Event.current.mousePosition)) { mouseHoversToolbar = true; } GUI.color = new Color(1f, 1f, 1f, 0.3f); GUI.Box(barRect, "", SplineEditorGUI.whiteBox); GUI.color = SplineEditorGUI.activeColor; DreamteckEditorGUI.Label(new Rect(110 * scale, verticalOffset + 5 * scale, 90 * scale, 25 * scale), "Grid snap", true); positionEditor.snap = GUI.Toggle(new Rect(200 * scale, verticalOffset + 10 * scale, 25 * scale, 25 * scale), positionEditor.snap, ""); if (positionEditor.snap) { DreamteckEditorGUI.Label(new Rect(220 * scale, verticalOffset + 5 * scale, 80 * scale, 30 * scale), "Grid size:", true); positionEditor.snapGridSize = SplineEditorGUI.FloatField(new Rect(300 * scale, verticalOffset + 5 * scale, 50 * scale, 25 * scale), positionEditor.snapGridSize); positionEditor.snapGridSize = SplineEditorGUI.FloatDrag(new Rect(220 * scale, verticalOffset + 5 * scale, 80 * scale, 25 * scale), positionEditor.snapGridSize); if (positionEditor.snapGridSize < 0.001f) { positionEditor.snapGridSize = 0.001f; } } EditSpaceMenu(verticalOffset); }
private void Merge(int verticalOffset) { if (computer.hasMorph && !MorphWindow.editShapeMode) { return; } Rect barRect = new Rect(0f, verticalOffset, Screen.width, 35 * scale); if (barRect.Contains(Event.current.mousePosition)) { mouseHoversToolbar = true; } GUI.color = new Color(1f, 1f, 1f, 0.3f); GUI.Box(barRect, "", SplineEditorGUI.whiteBox); GUI.color = SplineEditorGUI.activeColor; DreamteckEditorGUI.Label(new Rect(5 * scale, verticalOffset + 5 * scale, 120 * scale, 25 * scale), "Merge endpoints", true); mergeEditor.mergeEndpoints = GUI.Toggle(new Rect(130 * scale, verticalOffset + 10 * scale, 25 * scale, 25 * scale), mergeEditor.mergeEndpoints, ""); int mergeSide = (int)mergeEditor.mergeSide; DreamteckEditorGUI.Label(new Rect(120 * scale, verticalOffset + 5 * scale, 120 * scale, 25 * scale), "Merge side", true); bool hover = SplineEditorGUI.DropDown(new Rect(250, verticalOffset + 5 * scale, 100 * scale, 25 * scale), SplineEditorGUI.defaultButton, new string[] { "Start", "End" }, true, ref mergeSide); mergeEditor.mergeSide = (SplineComputerMergeEditor.MergeSide)mergeSide; if (hover) { mouseHoversToolbar = true; } }
private void Create2DToolbar(int verticalOffset) { Rect barRect = new Rect(0f, verticalOffset, Screen.width, 35 * scale); if (barRect.Contains(Event.current.mousePosition)) { mouseHoversToolbar = true; } GUI.color = new Color(1f, 1f, 1f, 0.3f); GUI.Box(barRect, "", SplineEditorGUI.whiteBox); GUI.color = SplineEditorGUI.activeColor; DreamteckEditorGUI.Label(new Rect(5 * scale, verticalOffset + 5 * scale, 105 * scale, 25 * scale), "Place method:", true); bool hover = SplineEditorGUI.DropDown(new Rect(110 * scale, verticalOffset + 5 * scale, 130 * scale, 25 * scale), SplineEditorGUI.defaultButton, new string[] { "Free", "Insert" }, true, ref createPointMode2D); if (hover) { mouseHoversToolbar = true; } DreamteckEditorGUI.Label(new Rect(230 * scale, verticalOffset + 5 * scale, 90 * scale, 25 * scale), "Add Node", true); createNodeOnCreatePoint = GUI.Toggle(new Rect(320 * scale, verticalOffset + 10 * scale, 25 * scale, 25 * scale), createNodeOnCreatePoint, ""); minWidth = 790; if (createPointMode != 1) { DreamteckEditorGUI.Label(new Rect(325 * scale, verticalOffset + 5 * scale, 80 * scale, 30 * scale), "Append:", true); if (SplineEditorGUI.DropDown(new Rect(405 * scale, verticalOffset + 5 * scale, 100 * scale, 25 * scale), SplineEditorGUI.defaultButton, new string[] { "End", "Beginning" }, true, ref appendMode)) { mouseHoversToolbar = true; } minWidth = 1100; } }
private void Mirror(int verticalOffset) { if (computer.hasMorph && !MorphWindow.editShapeMode) { return; } Rect barRect = new Rect(0f, verticalOffset, Screen.width, 35 * scale); if (barRect.Contains(Event.current.mousePosition)) { mouseHoversToolbar = true; } GUI.color = new Color(1f, 1f, 1f, 0.3f); GUI.Box(barRect, "", SplineEditorGUI.whiteBox); GUI.color = SplineEditorGUI.activeColor; if (SplineEditorGUI.Button(new Rect(5 * scale, verticalOffset + 5 * scale, 100 * scale, 25 * scale), "Cancel")) { ExitMirrorMode(); } if (SplineEditorGUI.Button(new Rect(115 * scale, verticalOffset + 5 * scale, 100 * scale, 25 * scale), "Save")) { SaveMirror(); } DreamteckEditorGUI.Label(new Rect(215 * scale, verticalOffset + 5 * scale, 50 * scale, 25 * scale), "Axis", true); int axis = (int)mirrorEditor.axis; bool hover = SplineEditorGUI.DropDown(new Rect(270 * scale, verticalOffset + 5 * scale, 60 * scale, 25 * scale), SplineEditorGUI.defaultButton, new string[] { "X", "Y", "Z" }, true, ref axis); mirrorEditor.axis = (SplinePointMirrorEditor.Axis)axis; if (hover) { mouseHoversToolbar = true; } DreamteckEditorGUI.Label(new Rect(315 * scale, verticalOffset + 5 * scale, 60 * scale, 25 * scale), "Flip", true); mirrorEditor.flip = GUI.Toggle(new Rect(380 * scale, verticalOffset + 10 * scale, 25 * scale, 25 * scale), mirrorEditor.flip, ""); DreamteckEditorGUI.Label(new Rect(390 * scale, verticalOffset + 5 * scale, 120 * scale, 25 * scale), "Weld Distance", true); mirrorEditor.weldDistance = SplineEditorGUI.FloatField(new Rect(525 * scale, verticalOffset + 5 * scale, 50 * scale, 25 * scale), mirrorEditor.weldDistance); mirrorEditor.weldDistance = SplineEditorGUI.FloatDrag(new Rect(390 * scale, verticalOffset + 5 * scale, 120 * scale, 25 * scale), mirrorEditor.weldDistance); if (mirrorEditor.weldDistance < 0f) { mirrorEditor.weldDistance = 0f; } DreamteckEditorGUI.Label(new Rect(570 * scale, verticalOffset + 5 * scale, 120 * scale, 25 * scale), "Center X:", true); mirrorEditor.center.x = SplineEditorGUI.FloatField(new Rect(700 * scale, verticalOffset + 5 * scale, 50 * scale, 25 * scale), mirrorEditor.center.x); DreamteckEditorGUI.Label(new Rect(720 * scale, verticalOffset + 5 * scale, 50 * scale, 25 * scale), "Y:", true); mirrorEditor.center.y = SplineEditorGUI.FloatField(new Rect(770 * scale, verticalOffset + 5 * scale, 50 * scale, 25 * scale), mirrorEditor.center.y); DreamteckEditorGUI.Label(new Rect(790 * scale, verticalOffset + 5 * scale, 50 * scale, 25 * scale), "Z:", true); mirrorEditor.center.z = SplineEditorGUI.FloatField(new Rect(840 * scale, verticalOffset + 5 * scale, 50 * scale, 25 * scale), mirrorEditor.center.z); }
void OnSceneGUI(SceneView sceneView) { Handles.BeginGUI(); for (int i = 0; i < pointIndices.Count; i++) { Vector2 screenPosition = HandleUtility.WorldToGUIPoint(currentComputer.GetPoint(pointIndices[i]).position); screenPosition.y -= 25f; string pointName = "P" + pointIndices[i]; DreamteckEditorGUI.Label(new Rect(screenPosition.x - 120 + pointName.Length * 4, screenPosition.y, 120, 25), pointName); } Handles.EndGUI(); }
private void Scale(int verticalOffset) { if (computer.hasMorph && !MorphWindow.editShapeMode) { return; } Rect barRect = new Rect(0f, verticalOffset, Screen.width, 35 * scale); if (barRect.Contains(Event.current.mousePosition)) { mouseHoversToolbar = true; } GUI.color = new Color(1f, 1f, 1f, 0.3f); GUI.Box(barRect, "", SplineEditorGUI.whiteBox); GUI.color = SplineEditorGUI.activeColor; EditSpaceMenu(verticalOffset); DreamteckEditorGUI.Label(new Rect(120 * scale, verticalOffset + 5 * scale, 90 * scale, 25 * scale), "Scale sizes", true); scaleEditor.scaleSize = GUI.Toggle(new Rect(210 * scale, verticalOffset + 10 * scale, 25 * scale, 25 * scale), scaleEditor.scaleSize, ""); DreamteckEditorGUI.Label(new Rect(235 * scale, verticalOffset + 5 * scale, 120 * scale, 25 * scale), "Scale tangents", true); scaleEditor.scaleTangents = GUI.Toggle(new Rect(355 * scale, verticalOffset + 10 * scale, 25 * scale, 25 * scale), scaleEditor.scaleTangents, ""); }
private void CreateToolbar(int verticalOffset) { Rect barRect = new Rect(0f, verticalOffset, Screen.width, 35 * scale); if (barRect.Contains(Event.current.mousePosition)) { mouseHoversToolbar = true; } GUI.color = new Color(1f, 1f, 1f, 0.3f); GUI.Box(barRect, "", SplineEditorGUI.whiteBox); GUI.color = SplineEditorGUI.activeColor; DreamteckEditorGUI.Label(new Rect(5 * scale, verticalOffset + 5 * scale, 105 * scale, 25 * scale), "Place method:", true); bool hover = SplineEditorGUI.DropDown(new Rect(110 * scale, verticalOffset + 5 * scale, 130 * scale, 25 * scale), SplineEditorGUI.defaultButton, new string[] { "Camera Plane", "Insert", "Surface", "X Plane", "Y Plane", "Z Plane" }, true, ref createPointMode); if (hover) { mouseHoversToolbar = true; } DreamteckEditorGUI.Label(new Rect(220 * scale, verticalOffset + 5 * scale, 100 * scale, 25 * scale), "Normal:", true); hover = SplineEditorGUI.DropDown(new Rect(320 * scale, verticalOffset + 5 * scale, 160 * scale, 25 * scale), SplineEditorGUI.defaultButton, new string[] { "Auto", "Look at Camera", "Align with Camera", "Calculate", "Left", "Right", "Up", "Down", "Forward", "Back" }, true, ref createNormalMode); if (hover) { mouseHoversToolbar = true; } DreamteckEditorGUI.Label(new Rect(800 * scale, verticalOffset + 5 * scale, 90 * scale, 25 * scale), "Add Node", true); createNodeOnCreatePoint = GUI.Toggle(new Rect(890 * scale, verticalOffset + 10 * scale, 25 * scale, 25 * scale), createNodeOnCreatePoint, ""); bool showNormalField = false; if (createPointMode >= 3 && createPointMode <= 5) { DreamteckEditorGUI.Label(new Rect(500 * scale, verticalOffset + 5 * scale, 80 * scale, 30 * scale), "Grid offset:", true); showNormalField = true; } else if (createPointMode == 2) { DreamteckEditorGUI.Label(new Rect(480 * scale, verticalOffset + 5 * scale, 100 * scale, 30 * scale), "Normal offset:", true); showNormalField = true; if (SplineEditorGUI.Button(new Rect(925 * scale, verticalOffset * scale + 5, 95 * scale, 25 * scale), "LayerMask")) { LayermaskWindow maskWindow = EditorWindow.GetWindow <LayermaskWindow>(true); maskWindow.position = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 10, 10); maskWindow.Init(this, new Vector2(150, 30), new Vector2(150, 30)); } } else if (createPointMode == 0) { DreamteckEditorGUI.Label(new Rect(500 * scale, verticalOffset + 5 * scale, 80 * scale, 30 * scale), "Far plane:", true); showNormalField = true; } if (showNormalField) { createPointOffset = SplineEditorGUI.FloatField(new Rect(580 * scale, verticalOffset + 5 * scale, 50 * scale, 25 * scale), createPointOffset); createPointOffset = SplineEditorGUI.FloatDrag(new Rect(500 * scale, verticalOffset + 5 * scale, 80 * scale, 25 * scale), createPointOffset); if (createPointOffset < 0f && createPointMode < 3) { createPointOffset = 0f; } } minWidth = 790; if (createPointMode != 1) { DreamteckEditorGUI.Label(new Rect(625 * scale, verticalOffset + 5 * scale, 80 * scale, 30 * scale), "Append:", true); if (SplineEditorGUI.DropDown(new Rect(705 * scale, verticalOffset + 5 * scale, 100 * scale, 25 * scale), SplineEditorGUI.defaultButton, new string[] { "End", "Beginning" }, true, ref appendMode)) { mouseHoversToolbar = true; } minWidth = 1100; } }
private void Main() { Rect barRect = new Rect(0f, 0f, Screen.width, 45 * scale); if (barRect.Contains(Event.current.mousePosition)) { mouseHoversToolbar = true; } GUI.color = new Color(1f, 1f, 1f, 0.3f); GUI.Box(barRect, "", SplineEditorGUI.whiteBox); GUI.color = SplineEditorGUI.activeColor; if (computer.hasMorph && !MorphWindow.editShapeMode) { DreamteckEditorGUI.Label(new Rect(Screen.width / 2f - 200f, 10, 400, 30), "Editing unavailable outside of morph states."); return; } if (computer.hasMorph) { if (tool == PointTool.Create || tool == PointTool.Delete) { tool = PointTool.None; } } else { if (SplineEditorGUI.BigButton(new Rect(5 * scale, 5 * scale, 35 * scale, 35 * scale), addButtonContent, true, tool == PointTool.Create)) { ToggleCreateTool(); } if (SplineEditorGUI.BigButton(new Rect(45 * scale, 5 * scale, 35 * scale, 35 * scale), removeButtonContent, computer.pointCount > 0, tool == PointTool.Delete)) { if (tool != PointTool.Delete) { tool = PointTool.Delete; } else { tool = PointTool.None; } } if (SplineEditorGUI.BigButton(new Rect(85 * scale, 5 * scale, 35 * scale, 35 * scale), presetButtonContent, true, presetWindow != null)) { if (presetWindow == null) { presetWindow = EditorWindow.GetWindow <PresetsWindow>(true); presetWindow.Init(this, Vector2.zero, new Vector2(350, 20 * 22)); } } } if (SplineEditorGUI.BigButton(new Rect(150 * scale, 5 * scale, 35 * scale, 35 * scale), moveButtonContent, true, tool == PointTool.Move)) { if (tool != PointTool.Move) { ToggleMoveTool(); } else { tool = PointTool.None; } } if (SplineEditorGUI.BigButton(new Rect(190 * scale, 5 * scale, 35 * scale, 35 * scale), rotateButtonContent, true, tool == PointTool.Rotate)) { if (tool != PointTool.Rotate) { ToggleRotateTool(); } else { tool = PointTool.None; } } if (SplineEditorGUI.BigButton(new Rect(230 * scale, 5 * scale, 35 * scale, 35 * scale), scaleButtonContent, true, tool == PointTool.Scale)) { if (tool != PointTool.Scale) { ToggleScaleTool(); } else { tool = PointTool.None; } } if (SplineEditorGUI.BigButton(new Rect(270 * scale, 5 * scale, 35 * scale, 35 * scale), normalsButtonContent, !computer.is2D, tool == PointTool.NormalEdit)) { if (tool != PointTool.NormalEdit) { tool = PointTool.NormalEdit; } else { tool = PointTool.None; } } if (SplineEditorGUI.BigButton(new Rect(330 * scale, 5 * scale, 35 * scale, 35 * scale), mirrorButtonContent, computer.pointCount > 0 || InMirrorMode(), InMirrorMode())) { if (InMirrorMode()) { ExitMirrorMode(); } else { EnterMirrorMode(); } } if (SplineEditorGUI.BigButton(new Rect(370 * scale, 5 * scale, 35 * scale, 35 * scale), mergeButtonContent, computer.pointCount > 0 && !computer.isClosed, InMergeMode())) { if (InMergeMode()) { ExitMergeMode(); } else { EnterMergeMode(); } } if (SplineEditorGUI.BigButton(new Rect(410 * scale, 5 * scale, 35 * scale, 35 * scale), splitButtonContent, computer.pointCount > 0 && !computer.isClosed, InSplitMode())) { if (InSplitMode()) { ExitSplitMode(); } else { EnterSplitMode(); } } int operation = 0; float operationsPosition = Screen.width - (190 * scale + 100); #if UNITY_EDITOR_OSX operationsPosition = 430 * scale; #endif bool hover = SplineEditorGUI.DropDown(new Rect(operationsPosition, 10 * scale, 150 * scale, 25 * scale), SplineEditorGUI.defaultButton, operations, HasSelection(), ref operation); if (hover) { mouseHoversToolbar = true; } if (selectedPointsCount > 0) { switch (operation) { case 1: CenterSelection(); break; case 2: MoveTransformToSelection(); break; case 3: FlatSelection(0); break; case 4: FlatSelection(1); break; case 5: FlatSelection(2); break; case 6: MirrorSelection(0); break; case 7: MirrorSelection(1); break; case 8: MirrorSelection(2); break; case 9: DistributeEvenly(); break; case 10: EditorWindow.GetWindow <RelaxWindow>(true).Init(this, new Vector2(250, 90)); break; } } GUI.color = SplineEditorGUI.activeColor; ((SplineComputer)target).editorPathColor = EditorGUI.ColorField(new Rect(operationsPosition + 160 * scale, 13 * scale, 40 * scale, 20 * scale), ((SplineComputer)target).editorPathColor); }
public override void DrawScene() { base.DrawScene(); if (drawComputer) { for (int i = 0; i < splines.Length; i++) { DSSplineDrawer.DrawSplineComputer(splines[i]); } } if (drawConnectedComputers) { for (int i = 0; i < splines.Length; i++) { List <SplineComputer> computers = splines[i].GetConnectedComputers(); for (int j = 1; j < computers.Count; j++) { DSSplineDrawer.DrawSplineComputer(computers[j], 0.0, 1.0, 0.5f); } } } if (pathEditor.currentModule == null) { switch (transformTool) { case 1: for (int i = 0; i < splines.Length; i++) { Vector3 position = splines[i].transform.position; position = Handles.PositionHandle(position, splines[i].transform.rotation); if (position != splines[i].transform.position) { RecordUndo("Move spline computer"); Undo.RecordObject(splines[i].transform, "Move spline computer"); splines[i].transform.position = position; splines[i].SetPoints(pathEditor.points); pathEditor.Refresh(); } } break; case 2: for (int i = 0; i < splines.Length; i++) { Quaternion rotation = splines[i].transform.rotation; rotation = Handles.RotationHandle(rotation, splines[i].transform.position); if (rotation != splines[i].transform.rotation) { RecordUndo("Rotate spline computer"); Undo.RecordObject(splines[i].transform, "Rotate spline computer"); splines[i].transform.rotation = rotation; splines[i].SetPoints(pathEditor.points); pathEditor.Refresh(); } } break; case 3: for (int i = 0; i < splines.Length; i++) { Vector3 scale = splines[i].transform.localScale; scale = Handles.ScaleHandle(scale, splines[i].transform.position, splines[i].transform.rotation, HandleUtility.GetHandleSize(splines[i].transform.position)); if (scale != splines[i].transform.localScale) { RecordUndo("Scale spline computer"); Undo.RecordObject(splines[i].transform, "Scale spline computer"); splines[i].transform.localScale = scale; splines[i].SetPoints(pathEditor.points); pathEditor.Refresh(); } } break; } if (transformTool > 0) { for (int i = 0; i < splines.Length; i++) { Vector2 screenPosition = HandleUtility.WorldToGUIPoint(splines[i].transform.position); screenPosition.y += 20f; Handles.BeginGUI(); DreamteckEditorGUI.Label(new Rect(screenPosition.x - 120 + splines[i].name.Length * 4, screenPosition.y, 120, 25), splines[i].name); Handles.EndGUI(); } } } if (module >= 0 && module < modules.Length) { modules[module].DrawScene(); } }
public override void DrawScene() { HandleEditModeToggle(); if (!editMode) { return; } base.DrawScene(); Event e = Event.current; if (Tools.current != Tool.None) { lastEditorTool = Tools.current; Tools.current = Tool.None; } int controlID = GUIUtility.GetControlID(FocusType.Passive); if (e.GetTypeForControl(controlID) == EventType.Layout) { HandleUtility.AddDefaultControl(controlID); } if (eventModule.mouseLeftDown) { lastClickPoint = e.mousePosition; } EditorGUI.BeginChangeCheck(); mainModule.DrawScene(); if (currentModule != null) { currentModule.DrawScene(); if (currentModule is CreatePointModule) { if (eventModule.mouseLeftDown && eventModule.mouseRight) { GUIUtility.hotControl = -1; ToggleModule(0); } } } if (eventModule.mouseLeftDown) { emptyClick = GUIUtility.hotControl == 0; } if (emptyClick) { if (eventModule.mouseLeft && !mainModule.isDragging && Vector2.Distance(lastClickPoint, e.mousePosition) >= mainModule.minimumRectSize && !eventModule.alt) { mainModule.StartDrag(lastClickPoint); emptyClick = false; } } if (eventModule.mouseLeftUp) { if (mainModule.isDragging) { mainModule.FinishDrag(); } else { if (emptyClick) { if (selectedPoints.Count > 0) { mainModule.ClearSelection(); } else if (editMode) { if (Time.realtimeSinceStartup - lastEmptyClickTime <= 0.3f) { editMode = false; } else { editLabelAlpha = 1f; editLabelPosition = e.mousePosition; lastEmptyClickTime = Time.realtimeSinceStartup; } } } } } if (!eventModule.mouseRight && !eventModule.mouseLeft && e.type == EventType.KeyDown && !e.control) { switch (e.keyCode) { case KeyCode.Q: if (module == 0) { ToggleModule(1); } else { ToggleModule(0); } e.Use(); break; case KeyCode.W: ToggleModule(2); e.Use(); break; case KeyCode.E: ToggleModule(3); e.Use(); break; case KeyCode.R: ToggleModule(4); e.Use(); break; case KeyCode.T: ToggleModule(5); e.Use(); break; case KeyCode.Y: ToggleModule(6); e.Use(); break; } } if (editLabelAlpha > 0f) { Handles.BeginGUI(); GUI.contentColor = new Color(1f, 1f, 1f, editLabelAlpha); DreamteckEditorGUI.Label(new Rect(editLabelPosition, new Vector2(140, 50)), "Click Again To Exit"); Handles.EndGUI(); editLabelAlpha = Mathf.MoveTowards(editLabelAlpha, 0f, Time.deltaTime * 0.05f); Repaint(); } }
protected override void OnSceneGUI() { base.OnSceneGUI(); ObjectBender bender = (ObjectBender)target; if (selected.Count > 0) { Handles.BeginGUI(); for (int i = 0; i < selected.Count; i++) { Vector2 screenPosition = HandleUtility.WorldToGUIPoint(bender.bendProperties[selected[i]].transform.transform.position); DreamteckEditorGUI.Label(new Rect(screenPosition.x - 120 + bender.bendProperties[selected[i]].transform.transform.name.Length * 4, screenPosition.y, 120, 25), bender.bendProperties[selected[i]].transform.transform.name); } Handles.EndGUI(); } for (int i = 0; i < bender.bendProperties.Length; i++) { if (bender.bendProperties[i].bendSpline && bender.bendProperties[i].splineComputer != null) { DSSplineDrawer.DrawSplineComputer(bender.bendProperties[i].splineComputer, 0.0, 1.0, 0.2f); } } //Draw bounds if (bender.bend) { return; } TS_Bounds bound = bender.GetBounds(); Vector3 a = bender.transform.TransformPoint(bound.min); Vector3 b = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.min.y, bound.min.z)); Vector3 c = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.min.y, bound.max.z)); Vector3 d = bender.transform.TransformPoint(new Vector3(bound.min.x, bound.min.y, bound.max.z)); Vector3 e = bender.transform.TransformPoint(new Vector3(bound.min.x, bound.max.y, bound.min.z)); Vector3 f = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.max.y, bound.min.z)); Vector3 g = bender.transform.TransformPoint(new Vector3(bound.max.x, bound.max.y, bound.max.z)); Vector3 h = bender.transform.TransformPoint(new Vector3(bound.min.x, bound.max.y, bound.max.z)); Handles.color = Color.gray; Handles.DrawLine(a, b); Handles.DrawLine(b, c); Handles.DrawLine(c, d); Handles.DrawLine(d, a); Handles.DrawLine(e, f); Handles.DrawLine(f, g); Handles.DrawLine(g, h); Handles.DrawLine(h, e); Handles.DrawLine(a, e); Handles.DrawLine(b, f); Handles.DrawLine(c, g); Handles.DrawLine(d, h); Vector3 r = bender.transform.right; Vector3 fr = bender.transform.forward; switch (bender.axis) { case ObjectBender.Axis.Z: Handles.color = Color.blue; Handles.DrawLine(r + b, r + c); break; case ObjectBender.Axis.X: Handles.color = Color.red; Handles.DrawLine(b - fr, a - fr); break; case ObjectBender.Axis.Y: Handles.color = Color.green; Handles.DrawLine(b - fr + r, f - fr + r); break; } }
void OnSceneGUI() { #if DREAMTECK_SPLINES for (int i = 0; i < splines.Length; i++) { if (splines[i] != null) { DSSplineDrawer.DrawSplineComputer(splines[i]); } } #endif if (Application.isPlaying) { for (int i = 0; i < sceneSegments.Length; i++) { if (sceneSegments[i].drawCustomPaths) { LevelSegmentDebug.DrawCustomPaths(sceneSegments[i]); } if (sceneSegments[i].drawGeneratedSpline) { LevelSegmentDebug.DrawGeneratedSpline(sceneSegments[i]); } if (sceneSegments[i].drawGeneratedSamples) { LevelSegmentDebug.DrawGeneratedSamples(sceneSegments[i]); } } } else { for (int i = 0; i < sceneSegments.Length; i++) { if (sceneSegments[i].drawCustomPaths) { LevelSegmentDebug.DrawCustomPaths(sceneSegments[i]); } if (sceneSegments[i].type == LevelSegment.Type.Custom) { continue; } if (sceneSegments[i].drawBounds) { LevelSegmentDebug.DrawBounds(sceneSegments[i]); } } if (sceneSegments.Length == 1 && selectedProperties.Count > 0) { Handles.BeginGUI(); for (int i = 0; i < selectedProperties.Count; i++) { Vector2 screenPosition = HandleUtility.WorldToGUIPoint(sceneSegments[0].objectProperties[selectedProperties[i]].transform.transform.position); DreamteckEditorGUI.Label(new Rect(screenPosition.x - 120 + sceneSegments[0].objectProperties[selectedProperties[i]].transform.transform.name.Length * 4, screenPosition.y, 120, 25), sceneSegments[0].objectProperties[selectedProperties[i]].transform.transform.name); } Handles.EndGUI(); } } if (pathEditor != null) { pathEditor.DrawScene(); } for (int i = 0; i < sceneSegments.Length; i++) { if (!sceneSegments[i].drawEntranceAndExit) { continue; } if (sceneSegments[i].type == LevelSegment.Type.Custom) { if (sceneSegments[i].customEntrance != null) { float handleSize = HandleUtility.GetHandleSize(sceneSegments[i].customEntrance.position); Handles.color = ForeverPrefs.entranceColor; Handles.DrawSolidDisc(sceneSegments[i].customEntrance.position, Camera.current.transform.position - sceneSegments[i].customEntrance.position, handleSize * 0.1f); Handles.ArrowHandleCap(0, sceneSegments[i].customEntrance.position, sceneSegments[i].customEntrance.rotation, handleSize * 0.5f, EventType.Repaint); Handles.Label(sceneSegments[i].customEntrance.position + Camera.current.transform.up * handleSize * 0.3f, "Entrance"); } if (sceneSegments[i].customExit != null) { Handles.color = ForeverPrefs.exitColor; float handleSize = HandleUtility.GetHandleSize(sceneSegments[i].customExit.position); Handles.DrawSolidDisc(sceneSegments[i].customExit.position, Camera.current.transform.position - sceneSegments[i].customExit.position, handleSize * 0.1f); Handles.ArrowHandleCap(0, sceneSegments[i].customExit.position, sceneSegments[i].customExit.rotation, handleSize * 0.5f, EventType.Repaint); Handles.Label(sceneSegments[i].customExit.position + Camera.current.transform.up * HandleUtility.GetHandleSize(sceneSegments[i].customExit.position) * 0.3f, "Exit"); } } } }
public static bool Slider(SplineUser user, ref double percent, Color color, string text = "", SplineSliderGizmo gizmo = SplineSliderGizmo.Rectangle, float buttonSize = 1f) { Camera cam = SceneView.currentDrawingSceneView.camera; SplineResult result = user.Evaluate(percent); float size = HandleUtility.GetHandleSize(result.position); Handles.color = new Color(color.r, color.g, color.b, 0.4f); Handles.DrawSolidDisc(result.position, cam.transform.position - result.position, size * 0.2f * buttonSize); Handles.color = Color.white; if ((color.r + color.g + color.b + color.a) / 4f >= 0.9f) { Handles.color = Color.black; } Vector3 center = result.position; Vector2 screenPosition = HandleUtility.WorldToGUIPoint(center); screenPosition.y += 20f; Vector3 localPos = cam.transform.InverseTransformPoint(center); if (text != "" && localPos.z > 0f) { Handles.BeginGUI(); DreamteckEditorGUI.Label(new Rect(screenPosition.x - 120 + text.Length * 4, screenPosition.y, 120, 25), text); Handles.EndGUI(); } bool buttonClick = SliderButton(center, false, Color.white, 0.3f); Vector3 lookAtCamera = (cam.transform.position - result.position).normalized; Vector3 right = Vector3.Cross(lookAtCamera, result.direction).normalized *size * 0.1f * buttonSize; Vector3 front = Vector3.forward; switch (gizmo) { case SplineSliderGizmo.BackwardTriangle: center += result.direction * size * 0.06f * buttonSize; front = center - result.direction * size * 0.2f * buttonSize; Handles.DrawLine(center + right, front); Handles.DrawLine(front, center - right); Handles.DrawLine(center - right, center + right); break; case SplineSliderGizmo.ForwardTriangle: center -= result.direction * size * 0.06f * buttonSize; front = center + result.direction * size * 0.2f * buttonSize; Handles.DrawLine(center + right, front); Handles.DrawLine(front, center - right); Handles.DrawLine(center - right, center + right); break; case SplineSliderGizmo.DualArrow: center += result.direction * size * 0.025f * buttonSize; front = center + result.direction * size * 0.17f * buttonSize; Handles.DrawLine(center + right, front); Handles.DrawLine(front, center - right); Handles.DrawLine(center - right, center + right); center -= result.direction * size * 0.05f * buttonSize; front = center - result.direction * size * 0.17f * buttonSize; Handles.DrawLine(center + right, front); Handles.DrawLine(front, center - right); Handles.DrawLine(center - right, center + right); break; case SplineSliderGizmo.Rectangle: break; case SplineSliderGizmo.Circle: Handles.DrawWireDisc(center, lookAtCamera, 0.13f * size * buttonSize); break; } Vector3 lastPos = result.position; Handles.color = Color.clear; #if UNITY_5_5_OR_NEWER result.position = Handles.FreeMoveHandle(result.position, Quaternion.LookRotation(cam.transform.position - result.position), size * 0.2f * buttonSize, Vector3.zero, Handles.CircleHandleCap); #else result.position = Handles.FreeMoveHandle(result.position, Quaternion.LookRotation(cam.transform.position - result.position), size * 0.2f * buttonSize, Vector3.zero, Handles.CircleCap); #endif if (result.position != lastPos) { percent = user.Project(result.position).percent; } Handles.color = Color.white; return(buttonClick); }