2 using UnityEngine.Assertions;
4 namespace UnityEngine.Experimental.Rendering
6 public partial class DebugUI
14 EditorForceUpdate = 1 << 3
17 // Base class for all debug UI widgets
18 public abstract class Widget
20 // Set to null until it's added to a panel, be careful
21 protected Panel m_Panel;
22 public virtual Panel panel
24 get { return m_Panel; }
25 internal set { m_Panel = value; }
28 protected IContainer m_Parent;
29 public virtual IContainer parent
31 get { return m_Parent; }
32 internal set { m_Parent = value; }
35 public Flags flags { get; set; }
36 public string displayName { get; set; }
38 public string queryPath { get; private set; }
40 public bool isEditorOnly { get { return (flags & Flags.EditorOnly) != 0; } }
41 public bool isRuntimeOnly { get { return (flags & Flags.RuntimeOnly) != 0; } }
42 public bool isInactiveInEditor { get { return (isRuntimeOnly && !Application.isPlaying); } }
44 internal virtual void GenerateQueryPath()
46 queryPath = displayName.Trim();
49 queryPath = m_Parent.queryPath + " -> " + queryPath;
52 public override int GetHashCode()
54 return queryPath.GetHashCode();
57 public void RemoveSelf()
60 parent.children.Remove(this);
64 // Any widget that can holds other widgets must implement this interface
65 public interface IContainer
67 ObservableList<Widget> children { get; }
68 string displayName { get; set; }
69 string queryPath { get; }
72 // Any widget that implements this will be considered for serialization (only if the setter
73 // is set and thus is not read-only)
74 public interface IValueField
77 void SetValue(object value);
78 object ValidateValue(object value);
82 public class Button : Widget
84 public Action action { get; set; }
87 public class Value : Widget
89 public Func<object> getter { get; set; }
92 public float refreshRate = 0.1f;
94 public object GetValue()
96 Assert.IsNotNull(getter);