private void OnDrawGizmos() { if (!Selected()) { return; } var length = 0.2f; Gizmos.color = Color.red; Gizmos.DrawRay(transform.position, transform.right * length); Gizmos.color = Color.green; Gizmos.DrawRay(transform.position, transform.up * length); Gizmos.color = Color.blue; Gizmos.DrawRay(transform.position, transform.forward * length); Gizmos.color = Color.magenta; Gizmos.DrawSphere(transform.position, length / 25f); Handles.color = Color.red; Handles.ConeHandleCap(0, transform.position + transform.right * length, Quaternion.LookRotation(transform.right), length / 25f, EventType.Repaint); Handles.color = Color.green; Handles.ConeHandleCap(0, transform.position + transform.up * length, Quaternion.LookRotation(transform.up), length / 25f, EventType.Repaint); Handles.color = Color.blue; Handles.ConeHandleCap(0, transform.position + transform.forward * length, Quaternion.LookRotation(transform.forward), length / 25f, EventType.Repaint); }
public static void DrawPoint(RoadCreatorSettings.PointShape pointShape, Vector3 position, float size, bool showMoveHandle = true) { if (pointShape == RoadCreatorSettings.PointShape.Cube) { Handles.CubeHandleCap(0, position, Quaternion.Euler(-90, 0, 0), size, EventType.Repaint); } else if (pointShape == RoadCreatorSettings.PointShape.Cylinder) { Handles.CylinderHandleCap(0, position, Quaternion.Euler(-90, 0, 0), size, EventType.Repaint); } else if (pointShape == RoadCreatorSettings.PointShape.Sphere) { Handles.SphereHandleCap(0, position, Quaternion.Euler(-90, 0, 0), size, EventType.Repaint); } else if (pointShape == RoadCreatorSettings.PointShape.Cone) { Handles.ConeHandleCap(0, position, Quaternion.Euler(-90, 0, 0), size, EventType.Repaint); } /*if (showMoveHandle == true) * { * Handles.Slider(15, position, Vector3.forward, size * 3, Handles.ArrowHandleCap, 1); * return position;// Handles.FreeMoveHandle(position, Quaternion.Euler(0, 90, 0), size * 10, Vector3.one, Handles.ArrowHandleCap); * //return Handles.PositionHandle(position + new Vector3(0, size, 0), Quaternion.identity) - new Vector3(0, size, 0); * } * else * { * return position; * }*/ }
/// <summary> /// Draws an arrow in the scene. /// Useful for actions that set a direction. /// </summary> public static void DrawArrow(Vector3 fromPos, Vector3 toPos, Color color, float arrowScale = 0.2f) { var direction = toPos - fromPos; if (direction.sqrMagnitude < 0.0001f) { return; } var lookAtRotation = Quaternion.LookRotation(direction); var distance = Vector3.Distance(fromPos, toPos); var handleSize = HandleUtility.GetHandleSize(toPos); var arrowSize = handleSize * arrowScale; var originalColor = Handles.color; Handles.color = color; Handles.DrawLine(fromPos, toPos); #if UNITY_5_5_OR_NEWER Handles.ConeHandleCap(0, fromPos + direction.normalized * (distance - arrowSize), lookAtRotation, arrowSize, EventType.Repaint); // fudge factor to position cap correctly #else Handles.ConeCap(0, fromPos + direction.normalized * (distance - arrowSize), lookAtRotation, arrowSize); // fudge factor to position cap correctly #endif Handles.color = originalColor; }
private void DrawArrow(Vector3 from, Vector3 to) { Handles.color = Gizmos.color; Handles.DrawLine(from, to); float s = .05f; Handles.ConeHandleCap(0, from * s + to * (1f - s), Quaternion.LookRotation(to - from), (to - from).magnitude * s, EventType.Repaint); }
public static void ConeCap(int controlID, Vector3 position, Quaternion rotation, float size) { #if UNITY_5_6_OR_NEWER Handles.ConeHandleCap(controlID, position, rotation, size, EventType.Repaint); #else Handles.ConeCap(controlID, position, rotation, size); #endif }
private void OnDrawGizmos() { container.nodes = GetComponentsInChildren <Transform>(); nodes = container.nodes; path.Clear(); foreach (Transform node in nodes) { path.Add(node); } Errors = 0; for (int i = 0; i < nodes.Length - 1; i++) { if (Vector3.Distance(nodes [i].position, nodes [i + 1].position) <= speed) { Handles.color = new Color(1F, 0F, 0F); Errors++; } else if (Vector3.Distance(nodes [i].position, nodes [i + 1].position) <= (speed * 1.5) && Vector3.Distance(nodes [i].position, nodes [i + 1].position) >= speed) { Handles.color = new Color(1F, 0.4F, 0F); Errors++; } else if (Vector3.Distance(nodes [i].position, nodes [i + 1].position) >= (speed * 1.5)) { Handles.color = new Color(0F, 1F, 0F); } if (DrawPathLinear) { Handles.DrawDottedLine(nodes [i].position, nodes [i + 1].position, 3.0f); } if (DrawCones) { Handles.ConeHandleCap(0, nodes [i].position, nodes [i].rotation, 1f, EventType.Repaint); if (i == nodes.Length - 2) { Handles.ConeHandleCap(0, nodes [i + 1].position, nodes [i + 1].rotation, 1f, EventType.Repaint); } } } if (DrawPathCatmull) { //Transform[] tempPath = new Transform[] var sequence = Interpolate.NewCatmullRom(nodes, 20, false); var firstPoint = nodes [0].position; var segmentStart = firstPoint; foreach (var segmentEnd in sequence) { Gizmos.DrawLine(segmentStart, segmentEnd); segmentStart = segmentEnd; } } }
public static void DrawNormal(RaycastHit hit) { Gizmos.color = normalColor; Handles.color = normalColor; var normalEnd = hit.point + hit.normal * 0.5f; Gizmos.DrawLine(hit.point, hit.point + hit.normal * 0.5f); Handles.ConeHandleCap(0, normalEnd, Quaternion.LookRotation(hit.normal), 0.1f, Event.current.type); }
protected override void OnToolGUI(DirectionalField field) { Handles.DrawLine(field.Start, field.End); Handles.CubeHandleCap(0, field.Start, Quaternion.identity, HandleUtility.GetHandleSize(field.Start) * 0.1f, EventType.Repaint); Handles.ConeHandleCap(0, field.End, Quaternion.LookRotation(field.End - field.Start), HandleUtility.GetHandleSize(field.End) * 0.2f, EventType.Repaint); field.Start = Handles.PositionHandle(field.Start, Quaternion.identity); field.End = Handles.PositionHandle(field.End, Quaternion.identity); }
private static void DrawAxis(Color axisColor, float width, Vector3 worldPosition, Vector3 direction, float scale, float size) { Handles.color = axisColor; Handles.DrawAAPolyLine(width, worldPosition, worldPosition + direction * scale); if (size > 0) { Handles.ConeHandleCap(-1, worldPosition + direction, Quaternion.LookRotation(direction), size, EventType.Repaint); } }
protected void DrawConnections(LEGOBehaviour source, IEnumerable <LEGOBehaviour> destinations, bool fromSourceToDestination, Color color, LEGOBehaviour focusedDestination = null) { if (!source) { return; } Bounds sourceBounds = source.GetBrickBounds(); foreach (var destination in destinations) { if (!destination) { continue; } Handles.color = (destination == focusedDestination ? Color.yellow : color); Bounds destinationBounds = destination.GetBrickBounds(); var sourceToDestinationRay = new Ray(sourceBounds.center, destinationBounds.center - sourceBounds.center); var destinationToSourceRay = new Ray(destinationBounds.center, sourceBounds.center - destinationBounds.center); float destinationToSourceDistance; float sourceToDestinationToDistance; sourceBounds.IntersectRay(destinationToSourceRay, out destinationToSourceDistance); destinationBounds.IntersectRay(sourceToDestinationRay, out sourceToDestinationToDistance); var sourceEnd = destinationToSourceRay.origin + destinationToSourceRay.direction * destinationToSourceDistance; var destinationEnd = sourceToDestinationRay.origin + sourceToDestinationRay.direction * sourceToDestinationToDistance; var diff = destinationEnd - sourceEnd; if (diff.sqrMagnitude > 0.8f * 0.8f) { var sourceTangent = sourceEnd + diff * 0.25f + Vector3.up * diff.magnitude * 0.2f; var destinationTangent = destinationEnd - diff * 0.25f + Vector3.up * diff.magnitude * 0.2f; var bezierPoints = Handles.MakeBezierPoints(sourceEnd, destinationEnd, sourceTangent, destinationTangent, 8); Handles.DrawPolyLine(bezierPoints); if (fromSourceToDestination) { var arrowDirection = (bezierPoints[7] - bezierPoints[6]).normalized; Handles.ConeHandleCap(0, destinationEnd - arrowDirection * 0.16f, Quaternion.LookRotation(arrowDirection), 0.32f, EventType.Repaint); } else { var arrowDirection = (bezierPoints[0] - bezierPoints[1]).normalized; Handles.ConeHandleCap(0, sourceEnd - arrowDirection * 0.16f, Quaternion.LookRotation(arrowDirection), 0.32f, EventType.Repaint); } } } }
public override void Draw() { base.Draw(); var dir = (InterruptPos - Position).normalized; if (dir.sqrMagnitude > 0) { Handles.ConeHandleCap(0, InterruptPos - dir * HeadSize * 0.5f, Quaternion.LookRotation(dir), HeadSize, EventType.Repaint); } }
private void OnSceneGUI() { SkinnedMeshRenderer skinnedMeshRenderer = (SkinnedMeshRenderer)target; foreach (Transform bone in skinnedMeshRenderer.bones) { var direction = bone.transform.position - bone.parent.transform.position; Handles.ConeHandleCap(0, bone.transform.parent.position, Quaternion.LookRotation(direction), direction.magnitude, Event.current.type); Handles.DrawLine(bone.transform.position, bone.parent.transform.position); } }
private void DrawArrowFor(int wpIndex, float handleSize, Vector3 arrowPointsAt) { Handles.color = this._arrowsColor; Vector3 vector = this._src.wps[wpIndex]; Vector3 vector2 = arrowPointsAt - vector; if (vector2.magnitude >= (handleSize * 1.75f)) { Handles.ConeHandleCap(wpIndex, vector + Vector3.ClampMagnitude(vector2, handleSize), Quaternion.LookRotation(vector2), handleSize * 0.65f, EventType.Used); //Handles.ConeCap(wpIndex, vector + Vector3.ClampMagnitude(vector2, handleSize), Quaternion.LookRotation(vector2), handleSize * 0.65f); } Handles.color = Handles.color; }
void DrawDirArrow(Vector3 sourcePoint, Vector3 endPoint) { var dist = Vector3.Distance(endPoint, sourcePoint); if (dist < 0.0001f) { return; } var maxSize = 0.1f; var size = Mathf.Min(maxSize, dist / 10); Handles.DrawLine(sourcePoint, endPoint); Handles.ConeHandleCap(0, endPoint - (endPoint - sourcePoint).SetLen(size) * 0.7f, Quaternion.LookRotation(endPoint - sourcePoint), size, EventType.Repaint); }
/// <summary> /// 既に選択されているオブジェクトの矢印描画 /// </summary> private void AlReadySelectEventDraw() { if (newEventList == null) { return; } bool isalreadyDrawSelf = false; foreach (var x in newEventList) { if (x == null) { newEventList.Remove(x); continue; } if (x.gameObject == targetScript.gameObject) { if (isalreadyDrawSelf) { continue; } Handles.BeginGUI(); EditorGUI.TextArea(new Rect(HandleUtility.WorldToGUIPoint(targetScript.transform.position), new Vector2(40, 20)), "Self"); Handles.EndGUI(); isalreadyDrawSelf = true; continue; } //固定の色分け if (x is OnceEvent) { Handles.color = Color.red; } else if (x is SwitchEvent) { Handles.color = Color.yellow; } else if (x is TriggerEvent) { Handles.color = Color.blue; } else { Handles.color = Color.green; } Handles.ConeHandleCap(EditorGUIUtility.GetControlID(FocusType.Passive), x.transform.position, Quaternion.LookRotation(x.transform.position - targetScript.transform.position), 0.5f, EventType.Repaint); Handles.DrawLine(targetScript.transform.position, x.transform.position); //Handles.SelectionFrame(GUIUtility.GetControlID(FocusType.Passive), x.transform.position, Quaternion.identity, 1); } }
private void OnSceneGUI() { if (bcontrol && bcontrol.boneSnappingList.Count > 0) { if (bcontrol.transform.parent) { bcontrol.transform.localPosition = Vector3.zero; bcontrol.transform.rotation = bcontrol.transform.parent.rotation; } var color = Handles.color; if (!Application.isPlaying) { for (int i = 0; i < bcontrol.boneSnappingList.Count; i++) { var bn = bcontrol.boneSnappingList[i]; if (bn.bone && bn.target) { Handles.color = Color.green * handlesAlpha; if (Handles.Button(bn.target.position, Quaternion.identity, sphereSize, sphereSize, Handles.SphereHandleCap)) { EditorGUIUtility.PingObject(bn.target); } Handles.color = Color.blue * handlesAlpha; Handles.DrawLine(bn.target.position, bn.target.position + bn.target.forward * lineSize); Handles.ConeHandleCap(0, bn.target.position + bn.target.forward * lineSize, Quaternion.LookRotation(bn.target.forward), coneSize, EventType.Repaint); Handles.color = Color.red * handlesAlpha; Handles.DrawLine(bn.target.position, bn.target.position + bn.target.right * lineSize); Handles.ConeHandleCap(0, bn.target.position + bn.target.right * lineSize, Quaternion.LookRotation(bn.target.right), coneSize, EventType.Repaint); Handles.color = Color.green * handlesAlpha; Handles.DrawLine(bn.target.position, bn.target.position + bn.target.up * lineSize); Handles.ConeHandleCap(0, bn.target.position + bn.target.up * lineSize, Quaternion.LookRotation(bn.target.up), coneSize, EventType.Repaint); if (bcontrol.showLabels) { float zoom = Vector3.Distance(bn.bone.position, SceneView.currentDrawingSceneView.camera.transform.position); int fontSize = 25; fontLabelStyle.fontSize = Mathf.FloorToInt(fontSize / zoom); fontLabelStyle.normal.textColor = Color.white; fontLabelStyle.alignment = TextAnchor.MiddleCenter; GUI.color = Color.white; Handles.Label(bn.bone.position + Vector3.up * lineSize, bn.target.gameObject.name, fontLabelStyle); } bn.Snap(); } } } } }
public bool OnSceneGUIPoint(int _index, int _lastIndex) { var _inst = target as FlowPath; var _tran = _inst.transform; var _pt = _inst.points[_index]; _pt = _tran.TransformPoint(_pt); float _scale = HandleUtility.GetHandleSize(_pt); Handles.color = m_ConeColor; // draw the flow direction if (_index != _lastIndex) { var _pt2 = _inst.points[_lastIndex]; _pt2 = _tran.TransformPoint(_pt2); var _dir = _pt - _pt2; Handles.ConeHandleCap(0, _pt2 + _dir * 0.75f, Quaternion.FromToRotation(Vector3.forward, _dir), 0.25f * _scale, EventType.Repaint); } Handles.color = m_LineColor; // check for selection _scale = _index == 0 ? 2 * _scale : _scale; if (Handles.Button(_pt, Quaternion.identity, m_HandleSize * _scale, m_PickSize * _scale, Handles.DotHandleCap)) { m_SelectedIndex = _index; } Tools.hidden = m_SelectedIndex != -1; // enable translation if selected if (_index == m_SelectedIndex) { EditorGUI.BeginChangeCheck(); _pt = Handles.DoPositionHandle(_pt, _tran.rotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Flow Move Point"); _inst.points[_index] = _tran.InverseTransformPoint(_pt); return(true); } } return(false); }
//private Texture2D arrow; public void DrawCap(Vector3 pos, Vector3 startPos, Vector3 endPos, Quaternion rot, Color shadowColor, Color lineColor) { if (FlowSystem.GetZoom() < 1f) { return; } //if (this.arrow == null) this.arrow = UnityEngine.Resources.Load<Texture2D>("UI.Windows/Flow/Arrow"); var size = 12f; size /= FlowSystem.GetZoom(); //pos = this.editor.zoomDrawer.ConvertScreenCoordsToZoomCoords(pos, topLeft: true); var scrollPos = -FlowSystem.GetScrollPosition(); var offset = -8f; if (this.editor.scrollRect.Contains(new Vector3(pos.x - scrollPos.x + FlowSystemEditorWindow.GetSettingsWidth() + offset, pos.y - scrollPos.y + FlowSystemEditorWindow.TOOLBAR_HEIGHT + offset, 0f)) == false) { return; } var shadowOffset = Vector3.one * 1f; shadowOffset.z = 0f; /*var v1 = startPos - endPos; * v1.x = -v1.x; * var v2 = Vector3.left; * * var angle = Mathf.Atan2( * Vector3.Dot(Vector3.back, Vector3.Cross(v1, v2)), * Vector3.Dot(v1, v2)) * Mathf.Rad2Deg; * * var oldColor = GUI.color; * * GUI.color = shadowColor; * GUIExt.DrawTextureRotated(new Rect(pos.x - size * 0.5f + shadowOffset.x, pos.y - size * 0.5f + shadowOffset.y, size, size), arrow, -angle + 180f); * GUI.color = lineColor; * GUIExt.DrawTextureRotated(new Rect(pos.x - size * 0.5f, pos.y - size * 0.5f, size, size), arrow, -angle + 180f); * * GUI.color = oldColor;*/ Handles.color = shadowColor; Handles.ConeHandleCap(-1, pos + shadowOffset, rot, 15f, EventType.Repaint); Handles.color = lineColor; Handles.ConeHandleCap(-1, pos, rot, 15f, EventType.Repaint); }
static void OnSceneGUI(SceneView sceneView) { // Selection позволяет работать с выбранными в текущий момент объектами var curr = Selection.activeGameObject; if (curr != null) { //Handles.DrawWireCube(curr.transform.position, Vector3.one); //On EventType.Repaint event, draws the handle shape. Handles.ConeHandleCap(999, curr.transform.position + Vector3.up * 2, Quaternion.Euler(90, 0, 0), .5f, EventType.Repaint); Handles.Label(curr.transform.position + Vector3.up * 2.5f, "Это надпись и стрелка\nнад выбранным\nобъектом", EditorStyles.boldLabel); } }
// OnSceneGUI draws to the scene window void OnSceneGUI() { // Get the Panorama controller CameraPanorama cameraPanorama = (CameraPanorama)target; // If there exists Panoramas if (cameraPanorama.Panoramas.Count > 0) { // If the scene should be redrawn if (Event.current.type == EventType.Repaint) { Vector3 startPosition; Vector3 endPosition; Vector3 lookPosition; // Iterate through all Panoramas for (int i = 0; i < cameraPanorama.Panoramas.Count; i++) { startPosition = cameraPanorama.Panoramas[i].startPosition; // Get the start position endPosition = cameraPanorama.Panoramas[i].endPosition; // Get the end position lookPosition = cameraPanorama.Panoramas[i].lookPosition; // Get the look position // Draw a line between the start and end positions Handles.DrawLine(startPosition, endPosition); // Draw a line and a cone pointing from the start position to the look position Handles.DrawLine(startPosition, startPosition + (lookPosition - startPosition).normalized * 5); Handles.ConeHandleCap(0, startPosition + (lookPosition - startPosition).normalized * 5, Quaternion.LookRotation((lookPosition - startPosition).normalized), 1f, EventType.Repaint); // Draw a line and a cone pointing from the end position to the look position Handles.DrawLine(endPosition, endPosition + (lookPosition - endPosition).normalized * 5); Handles.ConeHandleCap(0, endPosition + (lookPosition - endPosition).normalized * 5, Quaternion.LookRotation((lookPosition - endPosition).normalized), 1f, EventType.Repaint); } } // Load the Panorama values LoadPanoramaValues(cameraPanorama); // Update the start, end and look positions from input (position handles) currentStartPosition = Handles.PositionHandle(currentStartPosition, Quaternion.identity); currentEndPosition = Handles.PositionHandle(currentEndPosition, Quaternion.identity); currentLookPosition = Handles.PositionHandle(currentLookPosition, Quaternion.identity); // Save the Panorama values SavePanoramaValues(cameraPanorama); } }
public static void ConeHandleCap(int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType) { #if UNITY_5_6_OR_NEWER Handles.ConeHandleCap(controlID, position, rotation, size, eventType); #else switch (eventType) { case (EventType.Layout): HandleUtility.AddControl(controlID, HandleUtility.DistanceToCircle(position, size)); break; case (EventType.Repaint): Handles.ConeCap(controlID, position, rotation, size); break; } #endif }
static void DrawHandleCap(HandleCaps capType, int controlID, Vector3 position, Quaternion rotation, float size) { #if UNITY_5_5_OR_NEWER switch (capType) { case HandleCaps.Cube: Handles.CubeHandleCap(controlID, position, rotation, size, EventType.Repaint); break; case HandleCaps.Cone: Handles.ConeHandleCap(controlID, position, rotation, size, EventType.Repaint); break; case HandleCaps.Circle: Handles.CircleHandleCap(controlID, position, rotation, size, EventType.Repaint); break; } #else switch (capType) { case HandleCaps.Cube: Handles.CubeCap(controlID, position, rotation, size); break; case HandleCaps.Cone: Handles.ConeCap(controlID, position, rotation, size); break; case HandleCaps.Circle: Handles.CircleCap(controlID, position, rotation, size); break; } #endif }
private void DrawArrowBetweenBoxes(SystemViewData fromView, SystemViewData toView) { var arrowDirection = toView.Center - fromView.Center; if (arrowDirection == Vector3.zero) { return; } Handles.color = EditorStyles.label.normal.textColor; var startPos = ExteriorPointFromOtherPoint(fromView.position, toView.Center); var endPos = ExteriorPointFromOtherPoint(toView.position, fromView.Center); endPos -= (endPos - startPos).normalized * 0.6f * kArrowSize; Handles.DrawAAPolyLine(lineTexture, EditorGUIUtility.pixelsPerPoint * kLineWidth, startPos, endPos); var rotation = Quaternion.LookRotation(arrowDirection, Vector3.forward); Handles.ConeHandleCap(0, endPos, rotation, kArrowSize, Event.current.type); }
protected override void Animate(BGTransition.SwayTransition swayTransition, Vector3 point, float distanceToCamera, Plane plane) { var verts = GetVertsByPlaneAndDistance(new Vector3(swayTransition.Value, swayTransition.Value, swayTransition.Value), point, distanceToCamera, plane); var size = swayTransition.Value * ScalePreviewPoint * distanceToCamera / 5; BGEditorUtility.SwapHandlesColor(PointersColor, () => { foreach (var position in verts) { #if UNITY_5_6_OR_NEWER Handles.ConeHandleCap(0, position, Quaternion.LookRotation(point - position), size, EventType.Repaint); #else Handles.ConeCap(0, position, Quaternion.LookRotation(point - position), size); #endif } }); }
/// <summary> /// Curve drawn between nodes /// </summary> /// <param name="start"></param> /// <param name="end"></param> public static void DrawNodeCurve(Rect start, Rect end) { Vector2 startPos = new Vector3(start.x + start.width / 2, start.y + start.height / 2); Vector2 endPos = new Vector3(end.x + end.width / 2, end.y + end.height / 2); Vector2 startTan = startPos + Vector2.right * 50; Vector2 endTan = endPos + Vector2.left * 50; float angle = Mathf.Acos(Vector2.Dot(startPos.normalized, endPos.normalized)); Color shadowCol = new Color(0, 0, 0, .06f); for (int i = 0; i < 3; i++) { Handles.DrawBezier(startPos, endPos, startTan, endTan, shadowCol, null, (i + 1) * 5); } Handles.DrawBezier(startPos, endPos, startTan, endTan, Color.green, null, 1); // TODO: Make Arrow (Not necessary but please do) Handles.ConeHandleCap(0, endPos, Quaternion.Euler(0, 90, angle), 200, EventType.Repaint); }
protected virtual void DrawStepOffset() { var dir = Vector3.Lerp(tp.transform.forward, tp.moveDirection.normalized, tp.inputSmooth.magnitude); Ray stepRay = new Ray((tp.transform.position + tp.transform.up * tp.stepOffsetMaxHeight) + dir.normalized * (_capsuleCollider.radius + tp.stepOffsetDistance), Vector3.down); var pDown = stepRay.GetPoint((tp.stepOffsetMaxHeight - tp.stepOffsetMinHeight - 0.025f)); Handles.DrawLine(stepRay.origin, stepRay.GetPoint((tp.stepOffsetMaxHeight - tp.stepOffsetMinHeight))); dir = pDown - stepRay.origin; if (dir.magnitude < 0.001f) { dir = Vector3.down; } var pHit = pDown; if (tp.applyingStepOffset) { pHit.y = tp.stepOffsetHit.point.y; } var stepConePosition = pHit + Vector3.up * 0.025f; Handles.DrawLine(stepRay.origin, stepConePosition); Handles.DrawSolidDisc(stepRay.origin, tp.transform.up, 0.05f); Handles.color = Color.grey * 0.5f; Handles.ConeHandleCap(0, pDown, Quaternion.LookRotation(dir), 0.05f, EventType.Repaint); Handles.color = tp.applyingStepOffset ? Color.red * 0.5f : Color.green * 0.5f; Handles.DrawSolidDisc(pHit, tp.transform.up, 0.05f); if (tp.applyingStepOffset) { DrawLabel(pHit, "StepHit"); } Handles.color = tp.applyingStepOffset ? Color.red : Color.green; Handles.color = Color.green; Handles.ConeHandleCap(0, stepConePosition, Quaternion.LookRotation(dir), 0.045f, EventType.Repaint); Handles.color = Color.white; DrawLabel(stepRay.origin, "StepMaxHeight"); DrawLabel(pDown, "StepMinHeight"); }
static public void DrawPoweredBy(this GFGear gear1) { if (gear1.DrivenBy != null) { #if UNITY_EDITOR Handles.color = Color.yellow; Quaternion q = new Quaternion(); Vector3 v = gear1.DrivenBy.transform.position - gear1.transform.position; if (v != Vector3.zero) { q = Quaternion.LookRotation(v); Handles.DrawLine(gear1.transform.position, gear1.DrivenBy.transform.position); Vector3 conePos = gear1.transform.position + ((gear1.DrivenBy.transform.position - gear1.transform.position) / 2.0f); Handles.ConeHandleCap(0, conePos, q, HandleUtility.GetHandleSize(conePos) / 4.0f, EventType.Repaint); } #else Debug.DrawLine(gear1.transform.position, gear1.DrivenBy.transform.position, Color.yellow, 3, false); #endif } }
void OnSceneGUI() { if (!_fadeControl.targetObject) { return; } var tpos = (_fadeControl.targetObject.position + _fadeControl.offset); Handles.color = new Color(1, 1, 1, 0.5f); Handles.SphereHandleCap(0, tpos, Quaternion.identity, 0.1f, EventType.Ignore); Ray ray = new Ray(tpos, _fadeControl.cameraTransform.position - tpos); Handles.DrawLine(tpos, ray.GetPoint(_fadeControl.distanceToEndFade)); Handles.color = (_fadeControl.distanceToEndFade < _fadeControl.distanceToStartFade) ? Color.green : Color.red; Handles.DrawAAPolyLine(10f, new Vector3[] { ray.GetPoint(_fadeControl.distanceToEndFade), ray.GetPoint(_fadeControl.distanceToStartFade) }); Handles.CubeHandleCap(0, ray.GetPoint(_fadeControl.distanceToEndFade), Quaternion.LookRotation(_fadeControl.cameraTransform.position - ray.GetPoint(_fadeControl.distanceToEndFade)), 0.05f, EventType.Ignore); Handles.ConeHandleCap(0, ray.GetPoint(_fadeControl.distanceToStartFade), Quaternion.LookRotation(ray.GetPoint(_fadeControl.distanceToStartFade) - _fadeControl.cameraTransform.position), 0.1f, EventType.Ignore); Handles.color = new Color(1, 1, 1, 0.5f); Handles.DrawLine(ray.GetPoint(_fadeControl.distanceToStartFade), _fadeControl.cameraTransform.position); Handles.DrawPolyLine(new Vector3[] { ray.GetPoint(_fadeControl.distanceToEndFade), ray.GetPoint(_fadeControl.distanceToStartFade) }); }
void OnSceneGUI(SceneView sceneView) { Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); // Camera.current.ScreenPointToRay(Event.current.mousePosition); // RaycastHit newHit; if (Physics.Raycast(ray, out newHit, 1000, MaskLayer)) { var view = Camera.current.WorldToViewportPoint(newHit.point); if (view.x < 1 && view.x > 0 && view.y < 1 && view.y > 0 && view.z > 0) { LastHit = newHit; Handles.color = HandleColor; Handles.ConeHandleCap(0, LastHit.point, Quaternion.LookRotation(LastHit.normal), HandleSize, EventType.Repaint); } sceneView.Repaint(); } if (!IsPainting) { return; } if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { if (Prefab) { GameObject go = Instantiate(Prefab, LastHit.point, Quaternion.LookRotation(Vector3.forward, LastHit.normal)); if (Parent) { go.transform.SetParent(Parent, true); } Undo.RegisterCreatedObjectUndo(go, "Instantiaded prefab"); Event.current.Use(); } } }
private void OnSceneGUI() { if (m_target.m_bPreviewInScene) { Vector3 cubeCenter = m_target.GetBounds().center; Vector3 cubeExtend = m_target.GetBounds().extents; Vector3 conePos = cubeCenter; Quaternion coneRot = Quaternion.identity; float coneSize = cubeExtend.magnitude / 2; switch (m_target.m_projectionAxis) { case 0: Handles.color = Handles.xAxisColor; coneRot = Quaternion.LookRotation(m_target.m_bProjectionDirection ? Vector3.right : Vector3.left); conePos.x += m_target.m_bProjectionDirection ? -(coneSize * 2) : (coneSize * 2); break; case 1: Handles.color = Handles.yAxisColor; coneRot = Quaternion.LookRotation(m_target.m_bProjectionDirection ? Vector3.up : Vector3.down); conePos.y += m_target.m_bProjectionDirection ? -(coneSize * 2) : (coneSize * 2); break; case 2: Handles.color = Handles.zAxisColor; coneRot = Quaternion.LookRotation(m_target.m_bProjectionDirection ? Vector3.forward : Vector3.back); conePos.z += m_target.m_bProjectionDirection ? -(coneSize * 2) : (coneSize * 2); break; default: break; } Handles.ConeHandleCap(0, conePos, coneRot, coneSize, EventType.Repaint); Handles.DrawWireCube(cubeCenter, cubeExtend * 2); } }