ReadOnlyControl.cs 818 B

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