private void DrawJoint(KinematicJoint joint) { Vector3 connection = joint.GetAnchorInWorldSpace(); //DrawSphere(connection, JointSize, JointColor); DrawCube(connection, joint.transform.rotation * Quaternion.Euler(joint.GetOrientation()), JointSize, JointColor); DrawLine(joint.transform.position, joint.GetAnchorInWorldSpace(), JointColor); //GUIStyle style = new GUIStyle(); //style.normal.textColor = Color.black; //Handles.Label(connection, joint.name, style); if (joint.GetXMotion().IsEnabled()) { Handles.color = Color.red; Handles.ArrowCap(0, connection, joint.transform.rotation * Quaternion.LookRotation(joint.GetXMotion().Axis), ArrowSize); } if (joint.GetYMotion().IsEnabled()) { Handles.color = Color.green; Handles.ArrowCap(0, connection, joint.transform.rotation * Quaternion.LookRotation(joint.GetYMotion().Axis), ArrowSize); } if (joint.GetZMotion().IsEnabled()) { Handles.color = Color.blue; Handles.ArrowCap(0, connection, joint.transform.rotation * Quaternion.LookRotation(joint.GetZMotion().Axis), ArrowSize); } }
public override void OnInspectorGUI() { Undo.RecordObject(Target, Target.name); using (var scope = new EditorGUILayout.VerticalScope("Button")) { EditorGUILayout.HelpBox("Geometry", MessageType.None); Target.SetJointType((JointType)EditorGUILayout.EnumPopup("Joint Type", Target.GetJointType())); Target.SetAnchor(EditorGUILayout.Vector3Field("Anchor", Target.GetAnchor())); Target.SetOrientation(EditorGUILayout.Vector3Field("Orientation", Target.GetOrientation())); } using (var scope = new EditorGUILayout.VerticalScope("Button")) { EditorGUILayout.HelpBox("Motion", MessageType.None); Target.SetMotionType((MotionType)EditorGUILayout.EnumPopup("Motion Type", Target.GetMotionType())); Target.SetSmoothing(EditorGUILayout.Slider("Smoothing", Target.GetSmoothing(), 0f, 1f)); if (Target.GetMotionType() == MotionType.Realistic) { Target.SetMaximumVelocity(EditorGUILayout.FloatField("Max Velocity", Target.GetMaximumVelocity())); Target.SetMaximumAcceleration(EditorGUILayout.FloatField("Max Acceleration", Target.GetMaximumAcceleration())); if (Target.GetMaximumVelocity() == 0f || Target.GetMaximumAcceleration() == 0f) { EditorGUILayout.HelpBox("Velocity and Acceleration must be assigned, or nothing will move.", MessageType.Warning); } } DrawMotionInspector(Target.GetXMotion(), "X"); DrawMotionInspector(Target.GetYMotion(), "Y"); DrawMotionInspector(Target.GetZMotion(), "Z"); } /* * EditorGUILayout.HelpBox( * "Current Value: " + Target.GetCurrentValue().ToString("F3") + "\n" + * "Current Error: " + Target.GetCurrentError().ToString("F3") + "\n" + * "Current Velocity: " + Target.GetCurrentVelocity().ToString("F3") + "\n" + * "Current Acceleration: " + Target.GetCurrentAcceleration().ToString("F3"), MessageType.None); */ EditorUtility.SetDirty(Target); /* * using (var scope = new EditorGUILayout.VerticalScope ("Button")) { * EditorGUILayout.HelpBox("Debug", MessageType.None); * EditorGUILayout.Vector3Field("Anchor", Target.GetAnchor()); * EditorGUILayout.Vector3Field("World Anchor", Target.GetAnchorInWorldSpace()); * EditorGUILayout.Vector3Field("Orientation", Target.GetOrientation()); * EditorGUILayout.Vector3Field("X Axis", Target.GetXMotion().Axis); * EditorGUILayout.Vector3Field("Y Axis", Target.GetYMotion().Axis); * EditorGUILayout.Vector3Field("Z Axis", Target.GetZMotion().Axis); * EditorGUILayout.Vector3Field("Default Reference Position", Target.GetDefaultReferencePosition()); * EditorGUILayout.Vector3Field("Default Reference Rotation", Target.GetDefaultReferenceRotation().eulerAngles); * } */ }