void OnSceneGUI() { //reference to the class of object used to display gizmo VRBasics_Hinge hinge = (VRBasics_Hinge)target; //reference to the hinge joint the gizmo displays HingeJoint hingeJoint = hinge.GetComponent <HingeJoint> (); if (hingeJoint.useLimits != hinge.useLimits) { hingeJoint.useLimits = hinge.useLimits; } if (hingeJoint.limits.min < -179.9f) { hinge.limitMin = -179.9f; //adjust the limits of the hinge hinge.SetLimits(); } if (hingeJoint.limits.max < 0.0f) { hinge.limitMax = 0.0f; //adjust the limits of the hinge hinge.SetLimits(); } //this checks if the limits of the hinge joint were changed on the hinge joint itself if (hingeJoint.limits.max != hinge.limitMax || hingeJoint.limits.min != hinge.limitMin) { hinge.limitMax = hingeJoint.limits.max; hinge.limitMin = hingeJoint.limits.min; //adjust the limits of the hinge hinge.SetLimits(); } //in edit mode if (!Application.isPlaying) { //at runtime this is taken care of by the physics engine //prevent the hinge from moving away from the fulcrum of the lever during edit mode hinge.transform.localPosition = Vector3.zero; //prevents the hinge from rotating away from the fulcrum of the parent hinge.transform.localEulerAngles = Vector3.zero; } //reference to the parent class VRBasics_Lever lever = hinge.transform.parent.gameObject.GetComponent <VRBasics_Lever> (); //DRAW HINGE hinge.DrawGizmo(); //DRAW LEVER lever.DrawGizmo(); }
void OnSceneGUI() { //reference to the class of object used to display gizmo VRBasics_Lever lever = (VRBasics_Lever)target; VRBasics_Hinge hinge = lever.hinge.GetComponent <VRBasics_Hinge> (); //DRAW LEVER lever.DrawGizmo(); //DRAW HINGE hinge.DrawGizmo(); }