Button.cs 776 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using UnityEngine;
  3. namespace COM3D2.MeidoPhotoStudio.Plugin
  4. {
  5. internal class Button : BaseControl
  6. {
  7. public string Label { get; set; }
  8. public Button(string label)
  9. {
  10. this.Label = label;
  11. }
  12. public void Draw(GUIStyle buttonStyle, params GUILayoutOption[] layoutOptions)
  13. {
  14. if (!Visible) return;
  15. bool clicked = false;
  16. clicked = GUILayout.Button(Label, buttonStyle, layoutOptions);
  17. if (clicked) OnControlEvent(EventArgs.Empty);
  18. }
  19. public override void Draw(params GUILayoutOption[] layoutOptions)
  20. {
  21. GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
  22. Draw(buttonStyle, layoutOptions);
  23. }
  24. }
  25. }