LimbSolver2DEditor.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using UnityEngine;
  2. using UnityEngine.U2D.IK;
  3. namespace UnityEditor.U2D.IK
  4. {
  5. /// <summary>
  6. /// Custom Inspector for LimbSolver2D.
  7. /// </summary>
  8. [CustomEditor(typeof(LimbSolver2D))]
  9. [CanEditMultipleObjects]
  10. public class LimbSolver2DEditor : Solver2DEditor
  11. {
  12. private static class Contents
  13. {
  14. public static readonly GUIContent effectorLabel = new GUIContent("Effector", "The last Transform of a hierarchy constrained by the target");
  15. public static readonly GUIContent targetLabel = new GUIContent("Target", "Transfrom which the effector will follow");
  16. public static readonly GUIContent flipLabel = new GUIContent("Flip", "Select between the two possible solutions of the solver");
  17. }
  18. private SerializedProperty m_ChainProperty;
  19. private SerializedProperty m_FlipProperty;
  20. private void OnEnable()
  21. {
  22. m_ChainProperty = serializedObject.FindProperty("m_Chain");
  23. m_FlipProperty = serializedObject.FindProperty("m_Flip");
  24. }
  25. /// <summary>
  26. /// Custom Inspector OnInspectorGUI override.
  27. /// </summary>
  28. public override void OnInspectorGUI()
  29. {
  30. serializedObject.Update();
  31. EditorGUILayout.PropertyField(m_ChainProperty.FindPropertyRelative("m_EffectorTransform"), Contents.effectorLabel);
  32. EditorGUILayout.PropertyField(m_ChainProperty.FindPropertyRelative("m_TargetTransform"), Contents.targetLabel);
  33. EditorGUILayout.PropertyField(m_FlipProperty, Contents.flipLabel);
  34. DrawCommonSolverInspector();
  35. serializedObject.ApplyModifiedProperties();
  36. }
  37. }
  38. }