ISkeletonView.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using UnityEngine;
  2. namespace UnityEditor.U2D.Animation
  3. {
  4. internal enum SkeletonAction
  5. {
  6. None = 0,
  7. Select = 1 << 0,
  8. RotateBone = 1 << 2,
  9. MoveBone = 1 << 3,
  10. FreeMoveBone = 1 << 4,
  11. MoveEndPosition = 1 << 5,
  12. MoveJoint = 1 << 6,
  13. ChangeLength = 1 << 7,
  14. CreateBone = 1 << 8,
  15. SplitBone = 1 << 9,
  16. Remove = 1 << 10,
  17. }
  18. internal enum SkeletonMode
  19. {
  20. Disabled = SkeletonAction.None,
  21. Selection = SkeletonAction.Select,
  22. EditPose = Selection | SkeletonAction.RotateBone | SkeletonAction.MoveBone,
  23. EditJoints = Selection | SkeletonAction.FreeMoveBone | SkeletonAction.MoveEndPosition | SkeletonAction.MoveJoint | SkeletonAction.Remove,
  24. CreateBone = Selection | SkeletonAction.MoveJoint | SkeletonAction.Remove | SkeletonAction.CreateBone,
  25. SplitBone = Selection | SkeletonAction.MoveEndPosition | SkeletonAction.MoveJoint | SkeletonAction.Remove | SkeletonAction.SplitBone,
  26. }
  27. internal interface ISkeletonView
  28. {
  29. int InvalidID { get; set; }
  30. SkeletonMode mode { get; set; }
  31. int defaultControlID { get; set; }
  32. int hoveredBoneID { get; }
  33. int hoveredJointID { get; }
  34. int hoveredBodyID { get; }
  35. int hoveredTailID { get; }
  36. int hotBoneID { get; }
  37. void BeginLayout();
  38. void EndLayout();
  39. bool CanLayout();
  40. Vector3 GetMouseWorldPosition(Vector3 planeNormal, Vector3 planePosition);
  41. void LayoutBone(int id, Vector3 position, Vector3 endPosition, Vector3 forward, Vector3 up, Vector3 right, bool isChainEnd);
  42. bool DoSelectBone(out int id, out bool additive);
  43. bool DoRotateBone(Vector3 pivot, Vector3 normal, out float deltaAngle);
  44. bool DoMoveBone(out Vector3 deltaPosition);
  45. bool DoFreeMoveBone(out Vector3 deltaPosition);
  46. bool DoMoveJoint(out Vector3 deltaPosition);
  47. bool DoMoveEndPosition(out Vector3 endPosition);
  48. bool DoChangeLength(out Vector3 endPosition);
  49. bool DoCreateBoneStart(out Vector3 position);
  50. bool DoCreateBone(out Vector3 position);
  51. bool DoSplitBone(out int id, out Vector3 position);
  52. bool DoRemoveBone();
  53. bool DoCancelMultistepAction(bool force);
  54. bool IsActionActive(SkeletonAction action);
  55. bool IsActionHot(SkeletonAction action);
  56. bool IsActionTriggering(SkeletonAction action);
  57. bool IsActionFinishing(SkeletonAction action);
  58. bool IsRepainting();
  59. void DrawBone(Vector3 position, Vector3 right, Vector3 forward, float length, Color color, bool isChained, bool isSelected, bool isJointHovered, bool isTailHovered, bool isHot);
  60. void DrawBoneParentLink(Vector3 parentPosition, Vector3 position, Vector3 forward, Color color);
  61. void DrawBoneOutline(Vector3 position, Vector3 right, Vector3 forward, float length, Color color, float outlineScale);
  62. void DrawCursors(bool canBeActive);
  63. }
  64. }