浏览代码

First implementation of debug items UI in editor.

/Branch_Batching2
Julien Ignace 8 年前
当前提交
06b7a0fb
共有 2 个文件被更改,包括 54 次插入3 次删除
  1. 9
      Assets/ScriptableRenderPipeline/common/Debugging/DebugMenu.cs
  2. 48
      Assets/ScriptableRenderPipeline/common/Debugging/Editor/DebugMenuEditor.cs

9
Assets/ScriptableRenderPipeline/common/Debugging/DebugMenu.cs


public class DebugMenu
{
public string name { get { return m_Name; } }
public int itemCount { get { return m_Items.Count; } }
protected string m_Name = "Unknown Debug Menu";

private int m_SelectedItem = -1;
public DebugMenuItem GetDebugMenuItem(int index)
{
if (index >= m_Items.Count || index < 0)
return null;
return m_Items[index];
}
// TODO: Move this to UI classes
public GameObject BuildGUI(GameObject parent)

menuVLRectTransform.anchorMax = new Vector2(1.0f, 1.0f);
DebugMenuUI.CreateTextDebugElement(string.Format("{0} Title", m_Name), m_Name, 14, TextAnchor.MiddleLeft, m_Root);
m_ItemsUI.Clear();
foreach(DebugMenuItem menuItem in m_Items)

48
Assets/ScriptableRenderPipeline/common/Debugging/Editor/DebugMenuEditor.cs


m_DebugMenu = DebugMenuManager.instance;
}
void DrawBoolItem(DebugMenuItem item)
{
EditorGUI.BeginChangeCheck();
bool value = EditorGUILayout.Toggle(item.name, (bool)item.GetValue());
if(EditorGUI.EndChangeCheck())
{
item.SetValue(value);
}
}
void DrawFloatItem(DebugMenuItem item)
{
EditorGUI.BeginChangeCheck();
float value = EditorGUILayout.FloatField(item.name, (float)item.GetValue());
if (EditorGUI.EndChangeCheck())
{
item.SetValue(value);
}
}
void OnMenuItemGUI(DebugMenuItem item)
{
if(item.GetItemType() == typeof(bool))
{
DrawBoolItem(item);
}
else if(item.GetItemType() == typeof(float))
{
DrawFloatItem(item);
}
}
void OnGUI()
{
if (m_DebugMenu == null)

EditorGUI.BeginChangeCheck();
int debugMenuCount = m_DebugMenu.menuCount;
int activeMenuIndex = m_DebugMenu.activeMenuIndex;
using (new EditorGUILayout.HorizontalScope())

activeMenuIndex = i;
}
}
m_DebugMenu.activeMenuIndex = activeMenuIndex;
if(EditorGUI.EndChangeCheck())
{
m_DebugMenu.activeMenuIndex = activeMenuIndex;
}
using(new EditorGUILayout.VerticalScope())
{
DebugMenu activeMenu = m_DebugMenu.GetDebugMenu(m_DebugMenu.activeMenuIndex);
for (int i = 0; i < activeMenu.itemCount; ++i)
{
OnMenuItemGUI(activeMenu.GetDebugMenuItem(i));
}
}
}
}
正在加载...
取消
保存