public override sealed void OnSceneGUI() { DistanceJointBase2DExt distanceJoint2D = (DistanceJointBase2DExt)this.target; if (!distanceJoint2D.enabled) { return; } Vector3 anchor = Joint2DExtInspector.TransformPoint(distanceJoint2D.transform, distanceJoint2D.anchor); Vector3 vector = distanceJoint2D.connectedAnchor; if (distanceJoint2D.connectedBody) { vector = Joint2DExtInspector.TransformPoint(distanceJoint2D.connectedBody.transform, vector); } Joint2DExtInspector.DrawDistanceGizmo(anchor, vector, distanceJoint2D.distance); bool autoConfigure = distanceJoint2D.autoConfigureConnectedAnchor; base.OnSceneGUI(); if (autoConfigure && !distanceJoint2D.autoConfigureConnectedAnchor) { distanceJoint2D.autoConfigureDistance = false; EditorUtility.SetDirty(distanceJoint2D); } }
public override sealed void OnSceneGUI() { var sliderJoint2D = (SliderJoint2DExt)target; if (!sliderJoint2D.enabled) { return; } Vector3 vector = Joint2DExtInspector.TransformPoint(sliderJoint2D.transform, sliderJoint2D.anchor); Vector3 vector2 = vector; Vector3 vector3 = vector; Vector3 vector4 = Joint2DExtInspector.RotateVector2(Vector3.right, sliderJoint2D.transform.eulerAngles.z); vector4 = Joint2DExtInspector.RotateVector2(vector4, -sliderJoint2D.angle); Handles.color = Color.green; if (sliderJoint2D.useLimits) { vector2 = vector + vector4 * sliderJoint2D.limits.max; vector3 = vector + vector4 * sliderJoint2D.limits.min; Vector3 a = Vector3.Cross(vector4, Vector3.forward); float d = HandleUtility.GetHandleSize(vector2) * 0.16f; float d2 = HandleUtility.GetHandleSize(vector3) * 0.16f; Joint2DExtInspector.DrawAALine(vector2 + a * d, vector2 - a * d); Joint2DExtInspector.DrawAALine(vector3 + a * d2, vector3 - a * d2); } else { vector4 *= HandleUtility.GetHandleSize(vector) * 0.3f; vector2 += vector4; vector3 -= vector4; } Joint2DExtInspector.DrawAALine(vector2, vector3); base.OnSceneGUI(); }
public override void OnSceneGUI() { var pulleyJoint2D = (PulleyJoint2DExt)target; anchorJoint2D = pulleyJoint2D; pulleyJoint2D.SetConnectedAnchorEditor(); Vector3 vector = Joint2DExtInspector.TransformPoint(pulleyJoint2D.transform, pulleyJoint2D.anchor); Vector3 vector2 = pulleyJoint2D.groundAnchorA ? pulleyJoint2D.groundAnchorA.position : Vector3.zero; Vector3 vector3 = pulleyJoint2D.groundAnchorB ? pulleyJoint2D.groundAnchorB.position : Vector3.zero; Vector3 vector4 = pulleyJoint2D.connectedAnchor; bool twoPoints = !pulleyJoint2D.groundAnchorA || !pulleyJoint2D.groundAnchorB; if (pulleyJoint2D.connectedBody) { vector4 = Joint2DExtInspector.TransformPoint(pulleyJoint2D.connectedBody.transform, vector4); } Vector3 vector5 = vector + (vector2 - vector).normalized * HandleUtility.GetHandleSize(vector) * 0.1f; Handles.color = Color.green; if (twoPoints) { Handles.DrawAAPolyLine(new Vector3[] { vector5, vector4 }); } else { Handles.DrawAAPolyLine(new Vector3[] { vector5, vector2, vector3, vector4 }); } if (HandleAnchor(ref vector4, true)) { vector4 = SnapToSprites(vector4); vector4 = Joint2DExtInspector.SnapToPoint(vector4, vector, k_SnapDistance); if (pulleyJoint2D.connectedBody) { vector4 = Joint2DExtInspector.InverseTransformPoint(pulleyJoint2D.connectedBody.transform, vector4); } pulleyJoint2D.autoConfigureConnectedAnchor = false; pulleyJoint2D.connectedAnchor = vector4; EditorUtility.SetDirty(pulleyJoint2D); } if (HandleAnchor(ref vector, false)) { vector = SnapToSprites(vector); vector = Joint2DExtInspector.SnapToPoint(vector, vector4, k_SnapDistance); pulleyJoint2D.anchor = Joint2DExtInspector.InverseTransformPoint(pulleyJoint2D.transform, vector); EditorUtility.SetDirty(pulleyJoint2D); } }
public virtual void OnSceneGUI() { anchorJoint2D = (AnchoredJoint2DExt)target; anchorJoint2D.SetConnectedAnchorEditor(); Vector3 vector = Joint2DExtInspector.TransformPoint(anchorJoint2D.transform, anchorJoint2D.anchor); Vector3 vector2 = anchorJoint2D.connectedAnchor; bool hideConnectedAnchor = false; if (anchorJoint2D.connectedBody) { vector2 = Joint2DExtInspector.TransformPoint(anchorJoint2D.connectedBody.transform, vector2); } else { hideConnectedAnchor = anchorJoint2D.autoConfigureConnectedAnchor; } Vector3 vector3 = vector + (vector2 - vector).normalized * HandleUtility.GetHandleSize(vector) * 0.1f; Handles.color = Color.green; if (!hideConnectedAnchor) { Handles.DrawAAPolyLine(new Vector3[] { vector3, vector2 }); } if (!hideConnectedAnchor) { if (HandleAnchor(ref vector2, true)) { vector2 = SnapToSprites(vector2); vector2 = Joint2DExtInspector.SnapToPoint(vector2, vector, k_SnapDistance); if (anchorJoint2D.connectedBody) { vector2 = Joint2DExtInspector.InverseTransformPoint(anchorJoint2D.connectedBody.transform, vector2); } anchorJoint2D.autoConfigureConnectedAnchor = false; anchorJoint2D.connectedAnchor = vector2; EditorUtility.SetDirty(anchorJoint2D); } } if (HandleAnchor(ref vector, false)) { vector = SnapToSprites(vector); vector = Joint2DExtInspector.SnapToPoint(vector, vector2, k_SnapDistance); anchorJoint2D.anchor = Joint2DExtInspector.InverseTransformPoint(anchorJoint2D.transform, vector); EditorUtility.SetDirty(anchorJoint2D); } }
public override sealed void OnSceneGUI() { var wheelJoint2D = (WheelJoint2DExt)this.target; if (!wheelJoint2D.enabled) { return; } Vector3 vector = Joint2DExtInspector.TransformPoint(wheelJoint2D.transform, wheelJoint2D.anchor); Vector3 vector2 = vector; Vector3 vector3 = vector; Vector3 vector4 = Joint2DExtInspector.RotateVector2(Vector3.right, -wheelJoint2D.suspension.angle); Handles.color = Color.green; vector4 *= HandleUtility.GetHandleSize(vector) * 0.3f; vector2 += vector4; vector3 -= vector4; Joint2DExtInspector.DrawAALine(vector2, vector3); base.OnSceneGUI(); }
public override sealed void OnSceneGUI() { HingeJoint2DExt hingeJoint2D = (HingeJoint2DExt)target; if (!hingeJoint2D.enabled) { return; } if (hingeJoint2D.useLimits) { Vector3 vector = Joint2DExtInspector.TransformPoint(hingeJoint2D.transform, hingeJoint2D.anchor); Vector3 vector2 = Vector2.up; if (Application.isPlaying) { vector2 = Joint2DExtInspector.RotateVector2(Vector2.up, hingeJoint2D.referenceAngle + hingeJoint2D.limits.min); } else { vector2 = Joint2DExtInspector.RotateVector2(hingeJoint2D.transform.up, hingeJoint2D.limits.min); } float angle = hingeJoint2D.limits.max - hingeJoint2D.limits.min; float num = HandleUtility.GetHandleSize(vector) * 0.8f; float d = HandleUtility.GetHandleSize(vector) * 0.1f; Vector3 vector3 = vector + hingeJoint2D.transform.up * num; Vector3 start = vector + (vector3 - vector).normalized * d; Handles.color = new Color(0.0f, 1.0f, 0.0f, 0.7f); Joint2DExtInspector.DrawAALine(start, vector3); Handles.color = new Color(0.0f, 1.0f, 0.0f, 0.03f); Handles.DrawSolidArc(vector, Vector3.back, vector2, angle, num); Handles.color = new Color(0.0f, 1.0f, 0.0f, 0.7f); Handles.DrawWireArc(vector, Vector3.back, vector2, angle, num); DrawTick(vector, num, 0.0f, vector2, 1.0f); DrawTick(vector, num, angle, vector2, 1.0f); } base.OnSceneGUI(); }