public override bool SceneEdit(ref SplinePoint[] points, ref List <int> selected) { bool change = false; Camera editorCamera = SceneView.currentDrawingSceneView.camera; for (int i = 0; i < availableMergeComputers.Length; i++) { SplineEditor.DrawSplineComputer(availableMergeComputers[i], editorCamera, false, false); SplinePoint startPoint = availableMergeComputers[i].GetPoint(0); SplinePoint endPoint = availableMergeComputers[i].GetPoint(availableMergeComputers[i].pointCount - 1); Handles.color = availableMergeComputers[i].editorPathColor; if (Handles.Button(startPoint.position, Quaternion.LookRotation(editorCamera.transform.position - startPoint.position), HandleUtility.GetHandleSize(startPoint.position) * 0.15f, HandleUtility.GetHandleSize(startPoint.position) * 0.15f, Handles.CircleCap)) { Merge(i, mergeSide, MergeSide.Start, ref points); change = true; break; } if (Handles.Button(endPoint.position, Quaternion.LookRotation(editorCamera.transform.position - endPoint.position), HandleUtility.GetHandleSize(endPoint.position) * 0.15f, HandleUtility.GetHandleSize(endPoint.position) * 0.15f, Handles.CircleCap)) { Merge(i, mergeSide, MergeSide.End, ref points); change = true; break; } } Handles.color = Color.white; return(change); }
protected virtual void OnSceneGUI() { if (initGUI) { SplineEditorGUI.Initialize(); initGUI = false; } SplineUser user = (SplineUser)target; if (user.computer == null) { SplineUser root = user.rootUser; if (root == null) { return; } if (root.computer == null) { return; } List <SplineComputer> allComputers = root.computer.GetConnectedComputers(); for (int i = 0; i < allComputers.Count; i++) { if (allComputers[i] == root.computer) { continue; } SplineEditor.DrawSplineComputer(allComputers[i], SceneView.currentDrawingSceneView.camera, false, false, 0.4f); } for (int i = 0; i < root.address.depth; i++) { if (user.address.elements[i].computer == root.computer) { continue; } SplineEditor.DrawSplineComputer(root.address.elements[i].computer, SceneView.currentDrawingSceneView.camera, false, false, 1f, root.address.elements[i].startPercent, root.address.elements[i].endPercent, false); } } else { SplineComputer rootComputer = user.GetComponent <SplineComputer>(); List <SplineComputer> allComputers = user.computer.GetConnectedComputers(); for (int i = 0; i < allComputers.Count; i++) { if (allComputers[i] == rootComputer) { continue; } SplineEditor.DrawSplineComputer(allComputers[i], SceneView.currentDrawingSceneView.camera, false, false, 0.4f); } for (int i = 0; i < user.address.depth; i++) { if (user.address.elements[i].computer == rootComputer) { continue; } SplineEditor.DrawSplineComputer(user.address.elements[i].computer, SceneView.currentDrawingSceneView.camera, false, false, 1f, user.address.elements[i].startPercent, user.address.elements[i].endPercent, false); } } }
protected override void OnSceneGUI() { SurfaceGenerator user = (SurfaceGenerator)target; if (user.extrudeComputer != null) { SplineEditor.DrawSplineComputer(user.extrudeComputer, SceneView.currentDrawingSceneView.camera, false, false, 0.5f); } }
void OnSceneGUI() { Node node = (Node)target; Node.Connection[] connections = node.GetConnections(); for (int i = 0; i < connections.Length; i++) { SplineEditor.DrawSplineComputer(connections[i].computer, SceneView.currentDrawingSceneView.camera, false, false, 0.5f); } bool update = false; if (position != node.transform.position) { position = node.transform.position; update = true; } if (scale != node.transform.localScale) { scale = node.transform.localScale; update = true; } if (rotation != node.transform.rotation) { rotation = node.transform.rotation; update = true; } if (update) { node.UpdateConnectedComputers(); } if (addComp == null) { return; } SplinePoint[] points = addComp.GetPoints(); Transform camTransform = SceneView.currentDrawingSceneView.camera.transform; SplineEditor.DrawSplineComputer(addComp, SceneView.currentDrawingSceneView.camera, false, false, 0.5f); for (int i = 0; i < availablePoints.Length; i++) { if (addComp.isClosed && i == points.Length - 1) { break; } Handles.color = addComp.editorPathColor; if (Handles.Button(points[availablePoints[i]].position, Quaternion.LookRotation(-camTransform.forward, camTransform.up), HandleUtility.GetHandleSize(points[availablePoints[i]].position) * 0.1f, HandleUtility.GetHandleSize(points[availablePoints[i]].position) * 0.2f, Handles.CircleCap)) { AddConnection(addComp, availablePoints[i]); break; } } }
protected override void OnSceneGUI() { base.OnSceneGUI(); ObjectBender bender = (ObjectBender)target; if (drawTransform != null) { Handles.BeginGUI(); Vector2 screenPosition = HandleUtility.WorldToGUIPoint(drawTransform.position); SplineEditorGUI.Label(new Rect(screenPosition.x - 120 + drawTransform.name.Length * 4, screenPosition.y, 120, 25), drawTransform.name); Handles.EndGUI(); } for (int i = 0; i < bender.bendProperties.Length; i++) { if (bender.bendProperties[i].bendSpline && bender.bendProperties[i].splineComputer != null) { SplineEditor.DrawSplineComputer(bender.bendProperties[i].splineComputer, SceneView.lastActiveSceneView.camera, false, false, 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; } }