Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

129 行
3.7 KiB

namespace UnityEngine.Rendering
{
public partial class DebugUI
{
// Base class for "container" type widgets, although it can be used on its own (if a display
// name is set then it'll behave as a group with a header)
public class Container : Widget, IContainer
{
public ObservableList<Widget> children { get; private set; }
public override Panel panel
{
get { return m_Panel; }
internal set
{
m_Panel = value;
// Bubble down
foreach (var child in children)
child.panel = value;
}
}
public Container()
{
displayName = "";
children = new ObservableList<Widget>();
children.ItemAdded += OnItemAdded;
children.ItemRemoved += OnItemRemoved;
}
public Container(string displayName, ObservableList<Widget> children)
{
this.displayName = displayName;
this.children = children;
children.ItemAdded += OnItemAdded;
children.ItemRemoved += OnItemRemoved;
}
internal override void GenerateQueryPath()
{
base.GenerateQueryPath();
foreach (var child in children)
child.GenerateQueryPath();
}
protected virtual void OnItemAdded(ObservableList<Widget> sender, ListChangedEventArgs<Widget> e)
{
if (e.item != null)
{
e.item.panel = m_Panel;
e.item.parent = this;
}
if (m_Panel != null)
m_Panel.SetDirty();
}
protected virtual void OnItemRemoved(ObservableList<Widget> sender, ListChangedEventArgs<Widget> e)
{
if (e.item != null)
{
e.item.panel = null;
e.item.parent = null;
}
if (m_Panel != null)
m_Panel.SetDirty();
}
public override int GetHashCode()
{
int hash = 17;
hash = hash * 23 + queryPath.GetHashCode();
foreach (var child in children)
hash = hash * 23 + child.GetHashCode();
return hash;
}
}
// Unity-like foldout that can be collapsed
public class Foldout : Container, IValueField
{
public bool isReadOnly { get { return false; } }
public bool opened;
public string[] columnLabels { get; set; } = null;
public Foldout() : base() { }
public Foldout(string displayName, ObservableList<Widget> children, string[] columnLabels = null)
: base(displayName, children)
{
this.columnLabels = columnLabels;
}
public bool GetValue() => opened;
object IValueField.GetValue() => GetValue();
public void SetValue(object value) => SetValue((bool)value);
public object ValidateValue(object value) => value;
public void SetValue(bool value) => opened = value;
}
// Horizontal layout
public class HBox : Container
{
public HBox()
{
displayName = "HBox";
}
}
// Vertical layout
public class VBox : Container
{
public VBox()
{
displayName = "VBox";
}
}
}
}