SkeletonToolView.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using UnityEditor.U2D.Layout;
  3. namespace UnityEditor.U2D.Animation
  4. {
  5. internal class SkeletonToolView
  6. {
  7. private BoneInspectorPanel m_BoneInspectorPanel;
  8. public event Action<BoneCache, string> onBoneNameChanged = (b, s) => {};
  9. public event Action<BoneCache, int> onBoneDepthChanged = (b, i) => {};
  10. public SkeletonToolView()
  11. {
  12. m_BoneInspectorPanel = BoneInspectorPanel.GenerateFromUXML();
  13. m_BoneInspectorPanel.onBoneNameChanged += (b, n) => onBoneNameChanged(b, n);
  14. m_BoneInspectorPanel.onBoneDepthChanged += (b, d) => onBoneDepthChanged(b, d);
  15. Hide();
  16. }
  17. public void Initialize(LayoutOverlay layout)
  18. {
  19. layout.rightOverlay.Add(m_BoneInspectorPanel);
  20. }
  21. public void Show(BoneCache target)
  22. {
  23. m_BoneInspectorPanel.target = target;
  24. m_BoneInspectorPanel.SetHiddenFromLayout(false);
  25. }
  26. public BoneCache target => m_BoneInspectorPanel.target;
  27. public void Hide()
  28. {
  29. m_BoneInspectorPanel.HidePanel();
  30. m_BoneInspectorPanel.target = null;
  31. }
  32. public void Update(string name, int depth)
  33. {
  34. m_BoneInspectorPanel.boneName = name;
  35. m_BoneInspectorPanel.boneDepth = depth;
  36. }
  37. }
  38. }