using UnityEngine.UI; namespace UnityEngine.Rendering.UI { /// /// DebugUIHandler for value widgets. /// public class DebugUIHandlerValue : DebugUIHandlerWidget { /// Name of the value field. public Text nameLabel; /// Value of the value field. public Text valueLabel; DebugUI.Value m_Field; float m_Timer; /// /// OnEnable implementation. /// protected override void OnEnable() { m_Timer = 0f; } internal override void SetWidget(DebugUI.Widget widget) { base.SetWidget(widget); m_Field = CastWidget(); nameLabel.text = m_Field.displayName; } /// /// OnSelection implementation. /// /// True if the selection wrapped around. /// Previous widget. /// True if the selection is allowed. public override bool OnSelection(bool fromNext, DebugUIHandlerWidget previous) { nameLabel.color = colorSelected; valueLabel.color = colorSelected; return true; } /// /// OnDeselection implementation. /// public override void OnDeselection() { nameLabel.color = colorDefault; valueLabel.color = colorDefault; } void Update() { if (m_Timer >= m_Field.refreshRate) { valueLabel.text = m_Field.GetValue().ToString(); m_Timer -= m_Field.refreshRate; } m_Timer += Time.deltaTime; } } }