WeightInspectorIMGUIPanel.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UIElements;
  4. namespace UnityEditor.U2D.Animation
  5. {
  6. internal class WeightInspectorIMGUIPanel : VisualElement
  7. {
  8. public class CustomUXMLFactor : UxmlFactory<WeightInspectorIMGUIPanel, UxmlTraits> {}
  9. private WeightInspector m_WeightInspector = new WeightInspector();
  10. public WeightInspector weightInspector
  11. {
  12. get { return m_WeightInspector; }
  13. }
  14. public event Action weightsChanged = () => {};
  15. public WeightInspectorIMGUIPanel()
  16. {
  17. name = "WeightInspectorIMGUIPanel";
  18. styleSheets.Add(ResourceLoader.Load<StyleSheet>("SkinningModule/WeightInspectorIMGUIPanelStyle.uss"));
  19. this.Add(new IMGUIContainer(OnGUI));
  20. this.pickingMode = PickingMode.Ignore;
  21. this.RegisterCallback<MouseDownEvent>((e) => { e.StopPropagation(); });
  22. this.RegisterCallback<MouseUpEvent>((e) => { e.StopPropagation(); });
  23. }
  24. protected void OnGUI()
  25. {
  26. var selectionCount = 0;
  27. if (weightInspector.selection != null)
  28. selectionCount = weightInspector.selection.Count;
  29. using (new EditorGUI.DisabledGroupScope(m_WeightInspector.spriteMeshData == null || selectionCount == 0))
  30. {
  31. GUILayout.Label(new GUIContent(TextContent.vertexWeight, TextContent.vertexWeightToolTip));
  32. EditorGUI.BeginChangeCheck();
  33. m_WeightInspector.OnInspectorGUI();
  34. if (EditorGUI.EndChangeCheck())
  35. weightsChanged();
  36. }
  37. }
  38. }
  39. }