VFXStringFieldPushButton.cs 882 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.UIElements;
  4. using UnityEditor.UIElements;
  5. namespace UnityEditor.VFX.UI
  6. {
  7. class VFXStringFieldPushButton : VFXStringField
  8. {
  9. Action<string> m_fnOnClicked;
  10. public Action<string> pushButtonProvider
  11. {
  12. get { return m_fnOnClicked; }
  13. }
  14. public VFXStringFieldPushButton(string label, Action<string> fnClicked, string buttonName) : base(label)
  15. {
  16. m_fnOnClicked = fnClicked;
  17. Add(new Button(() => m_fnOnClicked(m_TextField.text)) { text = buttonName });
  18. }
  19. public VFXStringFieldPushButton(Label existingLabel, Action<string> fnClicked, string buttonName) : base(existingLabel)
  20. {
  21. m_fnOnClicked = fnClicked;
  22. Add(new Button(() => m_fnOnClicked(m_TextField.text)) { text = buttonName });
  23. }
  24. }
  25. }