PropertySheet.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Linq;
  2. using UnityEditorInternal;
  3. using UnityEngine;
  4. using UnityEngine.UIElements;
  5. namespace UnityEditor.ShaderGraph.Drawing
  6. {
  7. class PropertySheet : VisualElement
  8. {
  9. VisualElement m_ContentContainer;
  10. VisualElement m_HeaderContainer;
  11. Label m_Header;
  12. public override VisualElement contentContainer
  13. {
  14. get { return m_ContentContainer; }
  15. }
  16. public VisualElement headerContainer
  17. {
  18. get { return m_HeaderContainer.Children().FirstOrDefault(); }
  19. set
  20. {
  21. var first = m_HeaderContainer.Children().FirstOrDefault();
  22. if (first != null)
  23. first.RemoveFromHierarchy();
  24. m_HeaderContainer.Add(value);
  25. }
  26. }
  27. public PropertySheet(Label header = null)
  28. {
  29. styleSheets.Add(Resources.Load<StyleSheet>("Styles/PropertySheet"));
  30. m_ContentContainer = new VisualElement { name = "content" };
  31. m_HeaderContainer = new VisualElement { name = "header" };
  32. if (header != null)
  33. m_HeaderContainer.Add(header);
  34. m_ContentContainer.Add(m_HeaderContainer);
  35. hierarchy.Add(m_ContentContainer);
  36. }
  37. }
  38. }