Beispiel #1
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;
                }
            }
        }
 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);
         }
     }
 }
        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;
                }
            }
        }
Beispiel #4
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;
        }
Beispiel #5
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);
        }
        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);
            }
        }