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();
        }
Exemple #2
0
        public void OnSceneGUI()
        {
            var angleJoint2D = (AngleJoint2DExt)target;

            if (!angleJoint2D.enabled)
            {
                return;
            }
            Vector3 vector  = angleJoint2D.transform.position;
            Vector3 vector2 = vector;
            Vector3 vector3 = vector;
            Vector3 vector4 = Joint2DExtInspector.RotateVector2(Vector3.right, -angleJoint2D.targetAngle);

            Handles.color = Color.green;
            vector4      *= HandleUtility.GetHandleSize(vector) * 0.6f;
            vector2      += vector4;
            Joint2DExtInspector.DrawAALine(vector2, vector3);
        }
Exemple #3
0
        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();
        }
        void DrawTick(Vector3 center, float radius, float angle, Vector3 up, float length)
        {
            Vector3 a          = Joint2DExtInspector.RotateVector2(up, angle).normalized;
            Vector3 vector     = center + a * radius;
            Vector3 vector2    = vector + (center - vector).normalized * radius * length;
            var     methodInfo = typeof(Handles).GetMethod("DrawAAPolyLine", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static, null, new System.Type[] { typeof(Color[]), typeof(Vector3[]) }, null);
            var     args       = new object[]
            {
                new Color[]
                {
                    new Color(0.0f, 1.0f, 0.0f, 0.7f),
                    new Color(0.0f, 1.0f, 0.0f, 0.0f)
                },
                new Vector3[] {
                    vector,
                    vector2
                }
            };

            methodInfo.Invoke(null, args);
        }
        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();
        }