Toolbar.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using UnityEngine;
  2. using UnityEngine.U2D.Common;
  3. using UnityEngine.UIElements;
  4. namespace UnityEditor.U2D.Animation
  5. {
  6. internal class Toolbar : VisualElement
  7. {
  8. public class ToolbarFactory : UxmlFactory<Toolbar, ToolbarUxmlTraits> {}
  9. public class ToolbarUxmlTraits : UxmlTraits {}
  10. public Toolbar()
  11. {
  12. AddToClassList("Toolbar");
  13. styleSheets.Add(ResourceLoader.Load<StyleSheet>("SkinningModule/ToolbarStyle.uss"));
  14. if (EditorGUIUtility.isProSkin)
  15. AddToClassList("Dark");
  16. }
  17. public void SetButtonChecked(Button toCheck)
  18. {
  19. var buttons = this.Query<Button>();
  20. buttons.ForEach((button) => { button.SetChecked(button == toCheck); });
  21. }
  22. protected void SetButtonChecked(Button button, bool check)
  23. {
  24. if (button.IsChecked() != check)
  25. {
  26. if (check)
  27. button.AddToClassList("Checked");
  28. else
  29. button.RemoveFromClassList("Checked");
  30. button.SetChecked(check);
  31. }
  32. }
  33. public void CollapseToolBar(bool collapse)
  34. {
  35. if (collapse)
  36. AddToClassList("Collapse");
  37. else
  38. RemoveFromClassList("Collapse");
  39. }
  40. }
  41. }