コード例 #1
0
        public new void OnSceneGUI()
        {
            SliderJoint2D sliderJoint2D = (SliderJoint2D)this.target;

            if (!sliderJoint2D.enabled)
            {
                return;
            }
            Vector3 vector  = Joint2DEditor.TransformPoint(sliderJoint2D.transform, sliderJoint2D.anchor);
            Vector3 vector2 = vector;
            Vector3 vector3 = vector;
            Vector3 vector4 = Joint2DEditor.RotateVector2(Vector3.right, -sliderJoint2D.angle - sliderJoint2D.transform.eulerAngles.z);

            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;
                Joint2DEditor.DrawAALine(vector2 + a * d, vector2 - a * d);
                Joint2DEditor.DrawAALine(vector3 + a * d2, vector3 - a * d2);
            }
            else
            {
                vector4 *= HandleUtility.GetHandleSize(vector) * 0.3f;
                vector2 += vector4;
                vector3 -= vector4;
            }
            Joint2DEditor.DrawAALine(vector2, vector3);
            base.OnSceneGUI();
        }
コード例 #2
0
        public new void OnSceneGUI()
        {
            HingeJoint2D target = (HingeJoint2D)this.target;

            if (!target.enabled)
            {
                return;
            }
            if (target.useLimits)
            {
                Vector3 vector3_1 = Joint2DEditor.TransformPoint(target.transform, (Vector3)target.anchor);
                float   num1      = Mathf.Min(target.limits.min, target.limits.max);
                float   num2      = Mathf.Max(target.limits.min, target.limits.max);
                float   angle     = num2 - num1;
                float   radius    = HandleUtility.GetHandleSize(vector3_1) * 0.8f;
                float   rotation  = target.GetComponent <Rigidbody2D>().rotation;
                Vector3 vector3_2 = (Vector3)Joint2DEditor.RotateVector2((Vector2)Vector3.right, -num2 - rotation);
                Vector3 end       = vector3_1 + (Vector3)(Joint2DEditor.RotateVector2((Vector2)Vector3.right, -target.jointAngle - rotation) * radius);
                Handles.color = new Color(0.0f, 1f, 0.0f, 0.7f);
                Joint2DEditor.DrawAALine(vector3_1, end);
                Handles.color = new Color(0.0f, 1f, 0.0f, 0.03f);
                Handles.DrawSolidArc(vector3_1, Vector3.back, vector3_2, angle, radius);
                Handles.color = new Color(0.0f, 1f, 0.0f, 0.7f);
                Handles.DrawWireArc(vector3_1, Vector3.back, vector3_2, angle, radius);
                this.DrawTick(vector3_1, radius, 0.0f, vector3_2, 1f);
                this.DrawTick(vector3_1, radius, angle, vector3_2, 1f);
            }
            base.OnSceneGUI();
        }
コード例 #3
0
        public void OnSceneGUI()
        {
            RelativeJoint2D relativeJoint2D = (RelativeJoint2D)this.target;

            if (!relativeJoint2D.enabled)
            {
                return;
            }
            Vector3 vector  = relativeJoint2D.target;
            Vector3 vector2 = (!relativeJoint2D.connectedBody) ? Vector3.zero : relativeJoint2D.connectedBody.transform.position;

            Handles.color = Color.green;
            Joint2DEditor.DrawAALine(vector, vector2);
            float   d  = HandleUtility.GetHandleSize(vector2) * 0.16f;
            Vector3 b  = Vector3.left * d;
            Vector3 b2 = Vector3.up * d;

            Joint2DEditor.DrawAALine(vector2 - b, vector2 + b);
            Joint2DEditor.DrawAALine(vector2 - b2, vector2 + b2);
            float   d2 = HandleUtility.GetHandleSize(vector) * 0.16f;
            Vector3 b3 = Vector3.left * d2;
            Vector3 b4 = Vector3.up * d2;

            Joint2DEditor.DrawAALine(vector - b3, vector + b3);
            Joint2DEditor.DrawAALine(vector - b4, vector + b4);
        }
コード例 #4
0
 public void OnSceneGUI()
 {
     this.anchorJoint2D = (AnchoredJoint2D)this.target;
     if (this.anchorJoint2D.enabled)
     {
         Vector3 position        = Joint2DEditor.TransformPoint(this.anchorJoint2D.transform, (Vector3)this.anchorJoint2D.anchor);
         Vector3 connectedAnchor = (Vector3)this.anchorJoint2D.connectedAnchor;
         if (this.anchorJoint2D.connectedBody != null)
         {
             connectedAnchor = Joint2DEditor.TransformPoint(this.anchorJoint2D.connectedBody.transform, connectedAnchor);
         }
         Vector3 vector4 = connectedAnchor - position;
         Vector3 vector3 = position + ((Vector3)((vector4.normalized * HandleUtility.GetHandleSize(position)) * 0.1f));
         Handles.color = Color.green;
         Vector3[] points = new Vector3[] { vector3, connectedAnchor };
         Handles.DrawAAPolyLine(points);
         if (base.HandleAnchor(ref connectedAnchor, true))
         {
             connectedAnchor = Joint2DEditor.SnapToPoint(this.SnapToSprites(connectedAnchor), position, 0.13f);
             if (this.anchorJoint2D.connectedBody != null)
             {
                 connectedAnchor = Joint2DEditor.InverseTransformPoint(this.anchorJoint2D.connectedBody.transform, connectedAnchor);
             }
             Undo.RecordObject(this.anchorJoint2D, "Move Connected Anchor");
             this.anchorJoint2D.connectedAnchor = connectedAnchor;
         }
         if (base.HandleAnchor(ref position, false))
         {
             position = Joint2DEditor.SnapToPoint(this.SnapToSprites(position), connectedAnchor, 0.13f);
             Undo.RecordObject(this.anchorJoint2D, "Move Anchor");
             this.anchorJoint2D.anchor = Joint2DEditor.InverseTransformPoint(this.anchorJoint2D.transform, position);
         }
     }
 }
コード例 #5
0
        public void OnSceneGUI()
        {
            SliderJoint2D target = (SliderJoint2D)this.target;

            if (target.enabled)
            {
                Vector3 position = Joint2DEditor.TransformPoint(target.transform, (Vector3)target.anchor);
                Vector3 vector2  = position;
                Vector3 vector3  = position;
                Vector3 lhs      = (Vector3)Joint2DEditor.RotateVector2(Vector3.right, -target.angle - target.transform.eulerAngles.z);
                Handles.color = Color.green;
                if (target.useLimits)
                {
                    vector2 = position + ((Vector3)(lhs * target.limits.max));
                    vector3 = position + ((Vector3)(lhs * target.limits.min));
                    Vector3 vector5 = Vector3.Cross(lhs, Vector3.forward);
                    float   num     = HandleUtility.GetHandleSize(vector2) * 0.16f;
                    float   num2    = HandleUtility.GetHandleSize(vector3) * 0.16f;
                    Joint2DEditor.DrawAALine(vector2 + ((Vector3)(vector5 * num)), vector2 - ((Vector3)(vector5 * num)));
                    Joint2DEditor.DrawAALine(vector3 + ((Vector3)(vector5 * num2)), vector3 - ((Vector3)(vector5 * num2)));
                }
                else
                {
                    lhs      = (Vector3)(lhs * (HandleUtility.GetHandleSize(position) * 0.3f));
                    vector2 += lhs;
                    vector3 -= lhs;
                }
                Joint2DEditor.DrawAALine(vector2, vector3);
                base.OnSceneGUI();
            }
        }
コード例 #6
0
        public new void OnSceneGUI()
        {
            HingeJoint2D hingeJoint2D = (HingeJoint2D)base.target;

            if (hingeJoint2D.enabled)
            {
                if (hingeJoint2D.useLimits)
                {
                    Vector3 vector   = Joint2DEditor.TransformPoint(hingeJoint2D.transform, hingeJoint2D.anchor);
                    float   num      = Mathf.Min(hingeJoint2D.limits.min, hingeJoint2D.limits.max);
                    float   num2     = Mathf.Max(hingeJoint2D.limits.min, hingeJoint2D.limits.max);
                    float   angle    = num2 - num;
                    float   num3     = HandleUtility.GetHandleSize(vector) * 0.8f;
                    float   rotation = hingeJoint2D.GetComponent <Rigidbody2D>().rotation;
                    Vector3 vector2  = Joint2DEditor.RotateVector2(Vector3.right, -num2 - rotation);
                    Vector3 end      = vector + Joint2DEditor.RotateVector2(Vector3.right, -hingeJoint2D.jointAngle - rotation) * num3;
                    Handles.color = new Color(0f, 1f, 0f, 0.7f);
                    Joint2DEditor.DrawAALine(vector, end);
                    Handles.color = new Color(0f, 1f, 0f, 0.03f);
                    Handles.DrawSolidArc(vector, Vector3.back, vector2, angle, num3);
                    Handles.color = new Color(0f, 1f, 0f, 0.7f);
                    Handles.DrawWireArc(vector, Vector3.back, vector2, angle, num3);
                    this.DrawTick(vector, num3, 0f, vector2, 1f);
                    this.DrawTick(vector, num3, angle, vector2, 1f);
                }
                base.OnSceneGUI();
            }
        }
コード例 #7
0
        public void OnSceneGUI()
        {
            TargetJoint2D targetJoint2D = (TargetJoint2D)base.target;

            if (targetJoint2D.enabled)
            {
                Vector3 vector  = Joint2DEditor.TransformPoint(targetJoint2D.transform, targetJoint2D.anchor);
                Vector3 vector2 = targetJoint2D.target;
                Handles.color = Color.green;
                Handles.DrawDottedLine(vector, vector2, 5f);
                if (base.HandleAnchor(ref vector, false))
                {
                    Undo.RecordObject(targetJoint2D, "Move Anchor");
                    targetJoint2D.anchor = Joint2DEditor.InverseTransformPoint(targetJoint2D.transform, vector);
                }
                float   d  = HandleUtility.GetHandleSize(vector2) * 0.3f;
                Vector3 b  = Vector3.left * d;
                Vector3 b2 = Vector3.up * d;
                Joint2DEditor.DrawAALine(vector2 - b, vector2 + b);
                Joint2DEditor.DrawAALine(vector2 - b2, vector2 + b2);
                if (base.HandleAnchor(ref vector2, true))
                {
                    Undo.RecordObject(targetJoint2D, "Move Target");
                    targetJoint2D.target = vector2;
                }
            }
        }
コード例 #8
0
        public void OnSceneGUI()
        {
            HingeJoint2D target = (HingeJoint2D)base.target;

            if (target.enabled)
            {
                if (target.useLimits)
                {
                    Vector3 position = Joint2DEditor.TransformPoint(target.transform, (Vector3)target.anchor);
                    float   num      = Mathf.Min(target.limits.min, target.limits.max);
                    float   num2     = Mathf.Max(target.limits.min, target.limits.max);
                    float   angle    = num2 - num;
                    float   radius   = HandleUtility.GetHandleSize(position) * 0.8f;
                    float   rotation = target.GetComponent <Rigidbody2D>().rotation;
                    Vector3 from     = (Vector3)Joint2DEditor.RotateVector2(Vector3.right, -num2 - rotation);
                    Vector3 end      = position + ((Vector3)(Joint2DEditor.RotateVector2(Vector3.right, -target.jointAngle - rotation) * radius));
                    Handles.color = new Color(0f, 1f, 0f, 0.7f);
                    Joint2DEditor.DrawAALine(position, end);
                    Handles.color = new Color(0f, 1f, 0f, 0.03f);
                    Handles.DrawSolidArc(position, Vector3.back, from, angle, radius);
                    Handles.color = new Color(0f, 1f, 0f, 0.7f);
                    Handles.DrawWireArc(position, Vector3.back, from, angle, radius);
                    this.DrawTick(position, radius, 0f, from, 1f);
                    this.DrawTick(position, radius, angle, from, 1f);
                }
                base.OnSceneGUI();
            }
        }
コード例 #9
0
        public void OnSceneGUI()
        {
            TargetJoint2D target = (TargetJoint2D)this.target;

            if (target.enabled)
            {
                Vector3 vector  = Joint2DEditor.TransformPoint(target.transform, (Vector3)target.anchor);
                Vector3 vector2 = (Vector3)target.target;
                Handles.color = Color.green;
                Handles.DrawDottedLine(vector, vector2, 5f);
                if (base.HandleAnchor(ref vector, false))
                {
                    Undo.RecordObject(target, "Move Anchor");
                    target.anchor = Joint2DEditor.InverseTransformPoint(target.transform, vector);
                }
                float   num     = HandleUtility.GetHandleSize(vector2) * 0.3f;
                Vector3 vector3 = (Vector3)(Vector3.left * num);
                Vector3 vector4 = (Vector3)(Vector3.up * num);
                Joint2DEditor.DrawAALine(vector2 - vector3, vector2 + vector3);
                Joint2DEditor.DrawAALine(vector2 - vector4, vector2 + vector4);
                if (base.HandleAnchor(ref vector2, true))
                {
                    Undo.RecordObject(target, "Move Target");
                    target.target = vector2;
                }
            }
        }
コード例 #10
0
        public void OnSceneGUI()
        {
            TargetJoint2D target1 = (TargetJoint2D)this.target;

            if (!target1.enabled)
            {
                return;
            }
            Vector3 position = Joint2DEditor.TransformPoint(target1.transform, (Vector3)target1.anchor);
            Vector3 target2  = (Vector3)target1.target;

            Handles.color = Color.green;
            Handles.DrawDottedLine(position, target2, 5f);
            if (this.HandleAnchor(ref position, false))
            {
                Undo.RecordObject((Object)target1, "Move Anchor");
                target1.anchor = (Vector2)Joint2DEditor.InverseTransformPoint(target1.transform, position);
            }
            float   num       = HandleUtility.GetHandleSize(target2) * 0.3f;
            Vector3 vector3_1 = Vector3.left * num;
            Vector3 vector3_2 = Vector3.up * num;

            Joint2DEditor.DrawAALine(target2 - vector3_1, target2 + vector3_1);
            Joint2DEditor.DrawAALine(target2 - vector3_2, target2 + vector3_2);
            if (!this.HandleAnchor(ref target2, true))
            {
                return;
            }
            Undo.RecordObject((Object)target1, "Move Target");
            target1.target = (Vector2)target2;
        }
コード例 #11
0
        public void OnSceneGUI()
        {
            RelativeJoint2D target1 = (RelativeJoint2D)this.target;

            if (!target1.enabled)
            {
                return;
            }
            Vector3 target2   = (Vector3)target1.target;
            Vector3 vector3_1 = !(bool)((Object)target1.connectedBody) ? Vector3.zero : target1.connectedBody.transform.position;

            Handles.color = Color.green;
            Joint2DEditor.DrawAALine(target2, vector3_1);
            float   num1      = HandleUtility.GetHandleSize(vector3_1) * 0.16f;
            Vector3 vector3_2 = Vector3.left * num1;
            Vector3 vector3_3 = Vector3.up * num1;

            Joint2DEditor.DrawAALine(vector3_1 - vector3_2, vector3_1 + vector3_2);
            Joint2DEditor.DrawAALine(vector3_1 - vector3_3, vector3_1 + vector3_3);
            float   num2      = HandleUtility.GetHandleSize(target2) * 0.16f;
            Vector3 vector3_4 = Vector3.left * num2;
            Vector3 vector3_5 = Vector3.up * num2;

            Joint2DEditor.DrawAALine(target2 - vector3_4, target2 + vector3_4);
            Joint2DEditor.DrawAALine(target2 - vector3_5, target2 + vector3_5);
        }
コード例 #12
0
        internal override Bounds GetWorldBoundsOfTarget(UnityEngine.Object targetObject)
        {
            Bounds       worldBoundsOfTarget = base.GetWorldBoundsOfTarget(targetObject);
            HingeJoint2D hingeJoint2D        = (HingeJoint2D)targetObject;

            worldBoundsOfTarget.Encapsulate(Joint2DEditor.TransformPoint(hingeJoint2D.transform, hingeJoint2D.anchor));
            return(worldBoundsOfTarget);
        }
コード例 #13
0
 private Vector3 SnapToSprites(Vector3 position)
 {
     position = Joint2DEditor.SnapToSprite(this.anchorJoint2D.GetComponent <SpriteRenderer>(), position, 0.13f);
     if (this.anchorJoint2D.connectedBody != null)
     {
         position = Joint2DEditor.SnapToSprite(this.anchorJoint2D.connectedBody.GetComponent <SpriteRenderer>(), position, 0.13f);
     }
     return(position);
 }
コード例 #14
0
        public new void OnSceneGUI()
        {
            HingeJoint2D hingeJoint2D = (HingeJoint2D)base.target;

            if (hingeJoint2D.enabled)
            {
                this.m_AngularLimitHandle.xMotion = ((!hingeJoint2D.useLimits) ? ConfigurableJointMotion.Free : ConfigurableJointMotion.Limited);
                JointAngleLimits2D limits = hingeJoint2D.limits;
                this.m_AngularLimitHandle.xMin = limits.min;
                this.m_AngularLimitHandle.xMax = limits.max;
                bool flag = EditMode.editMode == EditMode.SceneViewEditMode.JointAngularLimits && EditMode.IsOwner(this);
                if (flag)
                {
                    this.m_AngularLimitHandle.angleHandleDrawFunction = null;
                }
                else
                {
                    this.m_AngularLimitHandle.angleHandleDrawFunction = new Handles.CapFunction(this.NonEditableHandleDrawFunction);
                }
                Rigidbody2D rigidbody2D  = hingeJoint2D.attachedRigidbody;
                Vector3     point        = Vector3.right;
                Vector2     v            = hingeJoint2D.anchor;
                Rigidbody2D rigidbody2D2 = hingeJoint2D.connectedBody;
                Quaternion  rhs          = HingeJoint2DEditor.s_RightHandedHandleOrientationOffset;
                if (rigidbody2D.bodyType != RigidbodyType2D.Dynamic && hingeJoint2D.connectedBody != null && hingeJoint2D.connectedBody.bodyType == RigidbodyType2D.Dynamic)
                {
                    rigidbody2D  = hingeJoint2D.connectedBody;
                    point        = Vector3.left;
                    v            = hingeJoint2D.connectedAnchor;
                    rigidbody2D2 = hingeJoint2D.attachedRigidbody;
                    rhs          = HingeJoint2DEditor.s_LeftHandedHandleOrientationOffset;
                }
                Vector3    vector = Joint2DEditor.TransformPoint(rigidbody2D.transform, v);
                Quaternion q      = ((!(rigidbody2D2 == null)) ? Quaternion.LookRotation(Vector3.forward, rigidbody2D2.transform.rotation * Vector3.up) : Quaternion.identity) * rhs;
                Vector3    point2 = vector + Quaternion.LookRotation(Vector3.forward, rigidbody2D.transform.rotation * Vector3.up) * point;
                Matrix4x4  matrix = Matrix4x4.TRS(vector, q, Vector3.one);
                EditorGUI.BeginChangeCheck();
                using (new Handles.DrawingScope(HingeJoint2DEditor.Styles.handleColor, matrix))
                {
                    float num = HandleUtility.GetHandleSize(Vector3.zero) * HingeJoint2DEditor.Styles.handleRadius;
                    this.m_AngularLimitHandle.radius = num;
                    Handles.DrawLine(Vector3.zero, matrix.inverse.MultiplyPoint3x4(point2).normalized *num);
                    this.m_AngularLimitHandle.DrawHandle();
                }
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(hingeJoint2D, HingeJoint2DEditor.Styles.editAngularLimitsUndoMessage);
                    limits              = hingeJoint2D.limits;
                    limits.min          = this.m_AngularLimitHandle.xMin;
                    limits.max          = this.m_AngularLimitHandle.xMax;
                    hingeJoint2D.limits = limits;
                    rigidbody2D.WakeUp();
                }
                base.OnSceneGUI();
            }
        }
コード例 #15
0
ファイル: Joint2DEditor.cs プロジェクト: wensincai/Unity5.4
 public static void ConnectedAnchorCap(int controlID, Vector3 position, Quaternion rotation, float size)
 {
     if (controlID == GUIUtility.keyboardControl)
     {
         Joint2DEditor.DrawCap(controlID, position, Joint2DEditor.s_Styles.connectedAnchorActive);
     }
     else
     {
         Joint2DEditor.DrawCap(controlID, position, Joint2DEditor.s_Styles.connectedAnchor);
     }
 }
コード例 #16
0
        private void DrawTick(Vector3 center, float radius, float angle, Vector3 up, float length)
        {
            Vector3 normalized = (Vector3)Joint2DEditor.RotateVector2(up, angle).normalized;
            Vector3 vector3    = center + ((Vector3)(normalized * radius));
            Vector3 vector5    = center - vector3;
            Vector3 vector4    = vector3 + ((Vector3)((vector5.normalized * radius) * length));

            Color[]   colors = new Color[] { new Color(0f, 1f, 0f, 0.7f), new Color(0f, 1f, 0f, 0f) };
            Vector3[] points = new Vector3[] { vector3, vector4 };
            Handles.DrawAAPolyLine(colors, points);
        }
コード例 #17
0
        public static void DrawDistanceGizmo(Vector3 anchor, Vector3 connectedAnchor, float distance)
        {
            Vector3 normalized = (anchor - connectedAnchor).normalized;
            Vector3 end        = connectedAnchor + normalized * distance;
            Vector3 vector3    = Vector3.Cross(normalized, Vector3.forward) * (HandleUtility.GetHandleSize(connectedAnchor) * 0.16f);

            Handles.color = Color.green;
            Joint2DEditor.DrawAALine(anchor, end);
            Joint2DEditor.DrawAALine(connectedAnchor + vector3, connectedAnchor - vector3);
            Joint2DEditor.DrawAALine(end + vector3, end - vector3);
        }
コード例 #18
0
 public static void ConnectedAnchorHandleCap(int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType)
 {
     if (controlID == GUIUtility.keyboardControl)
     {
         Joint2DEditor.HandleCap(controlID, position, Joint2DEditor.s_Styles.connectedAnchorActive, eventType);
     }
     else
     {
         Joint2DEditor.HandleCap(controlID, position, Joint2DEditor.s_Styles.connectedAnchor, eventType);
     }
 }
コード例 #19
0
        public new void OnSceneGUI()
        {
            SpringJoint2D springJoint2D = (SpringJoint2D)base.target;

            if (springJoint2D.enabled)
            {
                Vector3 anchor = Joint2DEditor.TransformPoint(springJoint2D.transform, springJoint2D.anchor);
                Vector3 vector = springJoint2D.connectedAnchor;
                if (springJoint2D.connectedBody)
                {
                    vector = Joint2DEditor.TransformPoint(springJoint2D.connectedBody.transform, vector);
                }
                Joint2DEditor.DrawDistanceGizmo(anchor, vector, springJoint2D.distance);
                base.OnSceneGUI();
            }
        }
コード例 #20
0
        public void OnSceneGUI()
        {
            DistanceJoint2D target = (DistanceJoint2D)base.target;

            if (target.enabled)
            {
                Vector3 anchor          = Joint2DEditor.TransformPoint(target.transform, (Vector3)target.anchor);
                Vector3 connectedAnchor = (Vector3)target.connectedAnchor;
                if (target.connectedBody != null)
                {
                    connectedAnchor = Joint2DEditor.TransformPoint(target.connectedBody.transform, connectedAnchor);
                }
                Joint2DEditor.DrawDistanceGizmo(anchor, connectedAnchor, target.distance);
                base.OnSceneGUI();
            }
        }
コード例 #21
0
        private void DrawTick(Vector3 center, float radius, float angle, Vector3 up, float length)
        {
            Vector3 normalized = (Vector3)Joint2DEditor.RotateVector2((Vector2)up, angle).normalized;
            Vector3 vector3_1  = center + normalized * radius;
            Vector3 vector3_2  = vector3_1 + (center - vector3_1).normalized * radius * length;

            Handles.DrawAAPolyLine(new Color[2]
            {
                new Color(0.0f, 1f, 0.0f, 0.7f),
                new Color(0.0f, 1f, 0.0f, 0.0f)
            }, new Vector3[2]
            {
                vector3_1,
                vector3_2
            });
        }
コード例 #22
0
        private void DrawTick(Vector3 center, float radius, float angle, Vector3 up, float length)
        {
            Vector3 a       = Joint2DEditor.RotateVector2(up, angle).normalized;
            Vector3 vector  = center + a * radius;
            Vector3 vector2 = vector + (center - vector).normalized * radius * length;

            Handles.DrawAAPolyLine(new Color[]
            {
                new Color(0f, 1f, 0f, 0.7f),
                new Color(0f, 1f, 0f, 0f)
            }, new Vector3[]
            {
                vector,
                vector2
            });
        }
コード例 #23
0
        public void OnSceneGUI()
        {
            WheelJoint2D target = (WheelJoint2D)this.target;

            if (target.enabled)
            {
                Vector3 position = Joint2DEditor.TransformPoint(target.transform, (Vector3)target.anchor);
                Vector3 start    = position;
                Vector3 end      = position;
                Vector3 vector4  = (Vector3)Joint2DEditor.RotateVector2(Vector3.right, -target.suspension.angle - target.transform.eulerAngles.z);
                Handles.color = Color.green;
                vector4       = (Vector3)(vector4 * (HandleUtility.GetHandleSize(position) * 0.3f));
                start        += vector4;
                end          -= vector4;
                Joint2DEditor.DrawAALine(start, end);
                base.OnSceneGUI();
            }
        }
コード例 #24
0
        public new void OnSceneGUI()
        {
            WheelJoint2D wheelJoint2D = (WheelJoint2D)base.target;

            if (wheelJoint2D.enabled)
            {
                Vector3 vector  = Joint2DEditor.TransformPoint(wheelJoint2D.transform, wheelJoint2D.anchor);
                Vector3 vector2 = vector;
                Vector3 vector3 = vector;
                Vector3 vector4 = Joint2DEditor.RotateVector2(Vector3.right, -wheelJoint2D.suspension.angle - wheelJoint2D.transform.eulerAngles.z);
                Handles.color = Color.green;
                vector4      *= HandleUtility.GetHandleSize(vector) * 0.3f;
                vector2      += vector4;
                vector3      -= vector4;
                Joint2DEditor.DrawAALine(vector2, vector3);
                base.OnSceneGUI();
            }
        }
コード例 #25
0
        public new void OnSceneGUI()
        {
            DistanceJoint2D distanceJoint2D = (DistanceJoint2D)this.target;

            if (!distanceJoint2D.enabled)
            {
                return;
            }
            Vector3 anchor = Joint2DEditor.TransformPoint(distanceJoint2D.transform, distanceJoint2D.anchor);
            Vector3 vector = distanceJoint2D.connectedAnchor;

            if (distanceJoint2D.connectedBody)
            {
                vector = Joint2DEditor.TransformPoint(distanceJoint2D.connectedBody.transform, vector);
            }
            Joint2DEditor.DrawDistanceGizmo(anchor, vector, distanceJoint2D.distance);
            base.OnSceneGUI();
        }
コード例 #26
0
        public new void OnSceneGUI()
        {
            SpringJoint2D target = (SpringJoint2D)this.target;

            if (!target.enabled)
            {
                return;
            }
            Vector3 anchor  = Joint2DEditor.TransformPoint(target.transform, (Vector3)target.anchor);
            Vector3 vector3 = (Vector3)target.connectedAnchor;

            if ((bool)((Object)target.connectedBody))
            {
                vector3 = Joint2DEditor.TransformPoint(target.connectedBody.transform, vector3);
            }
            Joint2DEditor.DrawDistanceGizmo(anchor, vector3, target.distance);
            base.OnSceneGUI();
        }
コード例 #27
0
        public new void OnSceneGUI()
        {
            WheelJoint2D target = (WheelJoint2D)this.target;

            if (!target.enabled)
            {
                return;
            }
            Vector3 position  = Joint2DEditor.TransformPoint(target.transform, (Vector3)target.anchor);
            Vector3 vector3_1 = position;
            Vector3 vector3_2 = position;
            Vector3 vector3_3 = (Vector3)Joint2DEditor.RotateVector2((Vector2)Vector3.right, -target.suspension.angle - target.transform.eulerAngles.z);

            Handles.color = Color.green;
            Vector3 vector3_4 = vector3_3 * (HandleUtility.GetHandleSize(position) * 0.3f);

            Joint2DEditor.DrawAALine(vector3_1 + vector3_4, vector3_2 - vector3_4);
            base.OnSceneGUI();
        }
コード例 #28
0
        public void OnSceneGUI()
        {
            this.anchorJoint2D = (AnchoredJoint2D)this.target;
            if (!this.anchorJoint2D.enabled)
            {
                return;
            }
            Vector3 position1 = Joint2DEditor.TransformPoint(this.anchorJoint2D.transform, (Vector3)this.anchorJoint2D.anchor);
            Vector3 position2 = (Vector3)this.anchorJoint2D.connectedAnchor;

            if ((bool)((Object)this.anchorJoint2D.connectedBody))
            {
                position2 = Joint2DEditor.TransformPoint(this.anchorJoint2D.connectedBody.transform, position2);
            }
            Vector3 vector3 = position1 + (position2 - position1).normalized * HandleUtility.GetHandleSize(position1) * 0.1f;

            Handles.color = Color.green;
            Handles.DrawAAPolyLine(new Vector3[2]
            {
                vector3,
                position2
            });
            if (this.HandleAnchor(ref position2, true))
            {
                position2 = this.SnapToSprites(position2);
                position2 = Joint2DEditor.SnapToPoint(position2, position1, 0.13f);
                if ((bool)((Object)this.anchorJoint2D.connectedBody))
                {
                    position2 = Joint2DEditor.InverseTransformPoint(this.anchorJoint2D.connectedBody.transform, position2);
                }
                Undo.RecordObject((Object)this.anchorJoint2D, "Move Connected Anchor");
                this.anchorJoint2D.connectedAnchor = (Vector2)position2;
            }
            if (!this.HandleAnchor(ref position1, false))
            {
                return;
            }
            Vector3 point = Joint2DEditor.SnapToPoint(this.SnapToSprites(position1), position2, 0.13f);

            Undo.RecordObject((Object)this.anchorJoint2D, "Move Anchor");
            this.anchorJoint2D.anchor = (Vector2)Joint2DEditor.InverseTransformPoint(this.anchorJoint2D.transform, point);
        }
コード例 #29
0
        public void OnSceneGUI()
        {
            this.anchorJoint2D = (AnchoredJoint2D)this.target;
            if (!this.anchorJoint2D.enabled)
            {
                return;
            }
            Vector3 vector  = Joint2DEditor.TransformPoint(this.anchorJoint2D.transform, this.anchorJoint2D.anchor);
            Vector3 vector2 = this.anchorJoint2D.connectedAnchor;

            if (this.anchorJoint2D.connectedBody)
            {
                vector2 = Joint2DEditor.TransformPoint(this.anchorJoint2D.connectedBody.transform, vector2);
            }
            Vector3 vector3 = vector + (vector2 - vector).normalized * HandleUtility.GetHandleSize(vector) * 0.1f;

            Handles.color = Color.green;
            Handles.DrawAAPolyLine(new Vector3[]
            {
                vector3,
                vector2
            });
            if (base.HandleAnchor(ref vector2, true))
            {
                vector2 = this.SnapToSprites(vector2);
                vector2 = Joint2DEditor.SnapToPoint(vector2, vector, 0.13f);
                if (this.anchorJoint2D.connectedBody)
                {
                    vector2 = Joint2DEditor.InverseTransformPoint(this.anchorJoint2D.connectedBody.transform, vector2);
                }
                Undo.RecordObject(this.anchorJoint2D, "Move Connected Anchor");
                this.anchorJoint2D.connectedAnchor = vector2;
            }
            if (base.HandleAnchor(ref vector, false))
            {
                vector = this.SnapToSprites(vector);
                vector = Joint2DEditor.SnapToPoint(vector, vector2, 0.13f);
                Undo.RecordObject(this.anchorJoint2D, "Move Anchor");
                this.anchorJoint2D.anchor = Joint2DEditor.InverseTransformPoint(this.anchorJoint2D.transform, vector);
            }
        }
コード例 #30
0
        public void OnSceneGUI()
        {
            RelativeJoint2D target = (RelativeJoint2D)this.target;

            if (target.enabled)
            {
                Vector3 start = (Vector3)target.target;
                Vector3 end   = (target.connectedBody == null) ? Vector3.zero : target.connectedBody.transform.position;
                Handles.color = Color.green;
                Joint2DEditor.DrawAALine(start, end);
                float   num     = HandleUtility.GetHandleSize(end) * 0.16f;
                Vector3 vector3 = (Vector3)(Vector3.left * num);
                Vector3 vector4 = (Vector3)(Vector3.up * num);
                Joint2DEditor.DrawAALine(end - vector3, end + vector3);
                Joint2DEditor.DrawAALine(end - vector4, end + vector4);
                float   num2    = HandleUtility.GetHandleSize(start) * 0.16f;
                Vector3 vector5 = (Vector3)(Vector3.left * num2);
                Vector3 vector6 = (Vector3)(Vector3.up * num2);
                Joint2DEditor.DrawAALine(start - vector5, start + vector5);
                Joint2DEditor.DrawAALine(start - vector6, start + vector6);
            }
        }