暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SkeletonToolView.cs 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using UnityEditor.U2D.Common;
  3. using UnityEditor.U2D.Layout;
  4. using UnityEngine;
  5. namespace UnityEditor.U2D.Animation
  6. {
  7. internal class SkeletonToolView
  8. {
  9. private BoneInspectorPanel m_BoneInspectorPanel;
  10. public event Action<BoneCache, string> onBoneNameChanged = (b, s) => {};
  11. public event Action<BoneCache, int> onBoneDepthChanged = (b, i) => {};
  12. public event Action<BoneCache, float> onBoneRotationChanged = (b, i) => {};
  13. public event Action<BoneCache, Vector2> onBonePositionChanged = (b, i) => {};
  14. public event Action<BoneCache, Color32> onBoneColorChanged = (b, i) => {};
  15. public SkeletonToolView()
  16. {
  17. m_BoneInspectorPanel = BoneInspectorPanel.GenerateFromUXML();
  18. m_BoneInspectorPanel.onBoneNameChanged += (b, n) => onBoneNameChanged(b, n);
  19. m_BoneInspectorPanel.onBoneDepthChanged += (b, d) => onBoneDepthChanged(b, d);
  20. m_BoneInspectorPanel.onBoneRotationChanged += (b, n) => onBoneRotationChanged(b, n);
  21. m_BoneInspectorPanel.onBonePositionChanged += (b, d) => onBonePositionChanged(b, d);
  22. m_BoneInspectorPanel.onBoneColorChanged += (b, d) => onBoneColorChanged(b, d);
  23. Hide();
  24. }
  25. public void Initialize(LayoutOverlay layout)
  26. {
  27. layout.rightOverlay.Add(m_BoneInspectorPanel);
  28. }
  29. public void Show(BoneCache target, bool isReadOnly)
  30. {
  31. m_BoneInspectorPanel.target = target;
  32. m_BoneInspectorPanel.SetHiddenFromLayout(false);
  33. var readOnlyProperty = BoneInspectorPanel.PropertyReadOnly.None;
  34. if (isReadOnly)
  35. readOnlyProperty = BoneInspectorPanel.PropertyReadOnly.Name |
  36. BoneInspectorPanel.PropertyReadOnly.Depth |
  37. BoneInspectorPanel.PropertyReadOnly.Color;
  38. m_BoneInspectorPanel.SetReadOnly(readOnlyProperty);
  39. }
  40. public BoneCache target => m_BoneInspectorPanel.target;
  41. public void Hide()
  42. {
  43. m_BoneInspectorPanel.HidePanel();
  44. m_BoneInspectorPanel.target = null;
  45. }
  46. public void Update(string name, int depth, Vector2 position, float rotation, Color32 color)
  47. {
  48. m_BoneInspectorPanel.boneName = name;
  49. m_BoneInspectorPanel.boneDepth = depth;
  50. m_BoneInspectorPanel.bonePosition = position;
  51. m_BoneInspectorPanel.boneRotation = rotation;
  52. m_BoneInspectorPanel.boneColor = color;
  53. }
  54. }
  55. }