public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            SerializedProperty jointTypeProp = property.FindPropertyRelative("jointType");
            JointType2D        jointType     = (JointType2D)jointTypeProp.intValue;

            if (jointType == JointType2D.DistanceJoint2D)
            {
                ClingyEditorUtils.DrawProperties(property, distanceJoint2DProps, rect);
            }
            else if (jointType == JointType2D.FrictionJoint2D)
            {
                ClingyEditorUtils.DrawProperties(property, frictionJoint2DProps, rect);
            }
            else if (jointType == JointType2D.HingeJoint2D)
            {
                ClingyEditorUtils.DrawProperties(property, hingeJoint2DProps, rect);
            }
            else if (jointType == JointType2D.RelativeJoint2D)
            {
                ClingyEditorUtils.DrawProperties(property, relativeJoint2DProps, rect);
            }
            else if (jointType == JointType2D.TargetJoint2D)
            {
                ClingyEditorUtils.DrawProperties(property, targetJoint2DProps, rect);
            }
            else if (jointType == JointType2D.SpringJoint2D)
            {
                ClingyEditorUtils.DrawProperties(property, springJoint2DProps, rect);
            }
            else if (jointType == JointType2D.FixedJoint2D)
            {
                ClingyEditorUtils.DrawProperties(property, fixedJoint2DProps, rect);
            }
            else if (jointType == JointType2D.WheelJoint2D)
            {
                ClingyEditorUtils.DrawProperties(property, wheelJoint2DProps, rect);
            }
            else if (jointType == JointType2D.SliderJoint2D)
            {
                ClingyEditorUtils.DrawProperties(property, sliderJoint2DProps, rect);
            }
            else
            {
                throw new System.NotImplementedException("Clingy: Unrecognized joint type");
            }
        }
Пример #2
0
 public virtual void Reset()
 {
     jointType = JointType2D.FixedJoint2D;
     motor.Reset();
     anchor = connectedAnchor = target = Vector2.zero;
     limits = new AngleLimits();
     autoConfigureDistance = true;
     autoConfigureOffset   = true;
     maxForce          = 10000;
     maxTorque         = 10000;
     maxFrictionForce  = 1;
     maxFrictionTorque = 1;
     correctionScale   = 0.3f;
     frequency         = 1;
     breakForce        = Mathf.Infinity;
     breakTorque       = Mathf.Infinity;
 }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            SerializedProperty jointTypeProp = property.FindPropertyRelative("jointType");
            JointType2D        jointType     = (JointType2D)jointTypeProp.intValue;

            if (jointType == JointType2D.DistanceJoint2D)
            {
                return(ClingyEditorUtils.GetPropertyHeight(property, distanceJoint2DProps));
            }
            else if (jointType == JointType2D.FrictionJoint2D)
            {
                return(ClingyEditorUtils.GetPropertyHeight(property, frictionJoint2DProps));
            }
            else if (jointType == JointType2D.HingeJoint2D)
            {
                return(ClingyEditorUtils.GetPropertyHeight(property, hingeJoint2DProps));
            }
            else if (jointType == JointType2D.RelativeJoint2D)
            {
                return(ClingyEditorUtils.GetPropertyHeight(property, relativeJoint2DProps));
            }
            else if (jointType == JointType2D.TargetJoint2D)
            {
                return(ClingyEditorUtils.GetPropertyHeight(property, targetJoint2DProps));
            }
            else if (jointType == JointType2D.SpringJoint2D)
            {
                return(ClingyEditorUtils.GetPropertyHeight(property, springJoint2DProps));
            }
            else if (jointType == JointType2D.FixedJoint2D)
            {
                return(ClingyEditorUtils.GetPropertyHeight(property, fixedJoint2DProps));
            }
            else if (jointType == JointType2D.WheelJoint2D)
            {
                return(ClingyEditorUtils.GetPropertyHeight(property, wheelJoint2DProps));
            }
            else if (jointType == JointType2D.SliderJoint2D)
            {
                return(ClingyEditorUtils.GetPropertyHeight(property, sliderJoint2DProps));
            }
            throw new System.NotImplementedException("Clingy: Unrecognized joint type");
        }