using UnityEngine.UI;
namespace UnityEngine.Rendering.UI
{
///
/// DebugUIHandler for group widget.
///
public class DebugUIHandlerGroup : DebugUIHandlerWidget
{
/// Name of the group.
public Text nameLabel;
/// Header of the group.
public Transform header;
DebugUI.Container m_Field;
DebugUIHandlerContainer m_Container;
internal override void SetWidget(DebugUI.Widget widget)
{
base.SetWidget(widget);
m_Field = CastWidget();
m_Container = GetComponent();
if (string.IsNullOrEmpty(m_Field.displayName))
header.gameObject.SetActive(false);
else
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)
{
if (!fromNext && !m_Container.IsDirectChild(previous))
{
var lastItem = m_Container.GetLastItem();
DebugManager.instance.ChangeSelection(lastItem, false);
return true;
}
return false;
}
///
/// Next implementation.
///
/// Next widget UI handler, parent if there is none.
public override DebugUIHandlerWidget Next()
{
if (m_Container == null)
return base.Next();
var firstChild = m_Container.GetFirstItem();
if (firstChild == null)
return base.Next();
return firstChild;
}
}
}