ReadOnlyControl.cs 699 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using SRF;
  3. using UnityEngine.UI;
  4. namespace SRDebugger.UI.Controls.Data
  5. {
  6. public class ReadOnlyControl : DataBoundControl
  7. {
  8. protected override void Start()
  9. {
  10. base.Start();
  11. }
  12. protected override void OnBind(string propertyName, Type t)
  13. {
  14. base.OnBind(propertyName, t);
  15. this.Title.text = propertyName;
  16. }
  17. protected override void OnValueUpdated(object newValue)
  18. {
  19. this.ValueText.text = Convert.ToString(newValue);
  20. }
  21. public override bool CanBind(Type type, bool isReadOnly)
  22. {
  23. return type == typeof(string) && isReadOnly;
  24. }
  25. [RequiredField]
  26. public Text ValueText;
  27. [RequiredField]
  28. public Text Title;
  29. }
  30. }