浏览代码

Added Color debug item (readonly at runtime for now)

/Branch_Batching2
Julien Ignace 7 年前
当前提交
ef9383f3
共有 7 个文件被更改,包括 169 次插入20 次删除
  1. 1
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs
  2. 6
      Assets/ScriptableRenderPipeline/common/Debugging/DebugActionManager.cs
  3. 18
      Assets/ScriptableRenderPipeline/common/Debugging/DebugItemDrawer.cs
  4. 2
      Assets/ScriptableRenderPipeline/common/Debugging/DebugMenu.cs
  5. 77
      Assets/ScriptableRenderPipeline/common/Debugging/DebugMenuItemUI.cs
  6. 33
      Assets/ScriptableRenderPipeline/common/Debugging/DebugMenuUI.cs
  7. 52
      ProjectSettings/InputManager.asset

1
Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs


DebugMenuManager.instance.AddDebugItem<LightingDebugMenu, LightingDebugMode>("Lighting Debug Mode", () => lightingDebugSettings.lightingDebugMode, (value) => lightingDebugSettings.lightingDebugMode = (LightingDebugMode)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugMenu, bool>("Override Smoothness", () => lightingDebugSettings.overrideSmoothness, (value) => lightingDebugSettings.overrideSmoothness = (bool)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugMenu, float>("Override Smoothness Value", () => lightingDebugSettings.overrideSmoothnessValue, (value) => lightingDebugSettings.overrideSmoothnessValue = (float)value, new DebugItemDrawFloatMinMax(0.0f, 1.0f));
DebugMenuManager.instance.AddDebugItem<LightingDebugMenu, Color>("Debug Lighting Albedo", () => lightingDebugSettings.debugLightingAlbedo, (value) => lightingDebugSettings.debugLightingAlbedo = (Color)value);
DebugMenuManager.instance.AddDebugItem<bool>("Lighting", "Display Sky Reflection", () => lightingDebugSettings.displaySkyReflection, (value) => lightingDebugSettings.displaySkyReflection = (bool)value);
DebugMenuManager.instance.AddDebugItem<LightingDebugMenu, float>("Sky Reflection Mipmap", () => lightingDebugSettings.skyReflectionMipmap, (value) => lightingDebugSettings.skyReflectionMipmap = (float)value, new DebugItemDrawFloatMinMax(0.0f, 1.0f));

6
Assets/ScriptableRenderPipeline/common/Debugging/DebugActionManager.cs


private static string kEnableDebugBtn2 = "Enable Debug Button 2";
private static string kDebugPreviousBtn = "Debug Previous";
private static string kDebugNextBtn = "Debug Next";
private static string kValidateBtn = "Fire1";
private static string kDPadVertical = "D-Pad Vertical";
private static string kDPadHorizontal = "D-Pad Horizontal";
private static string kValidateBtn = "Debug Validate";
private static string kDPadVertical = "Debug Vertical";
private static string kDPadHorizontal = "Debug Horizontal";
private string[] m_RequiredInputButtons = { kEnableDebugBtn1, kEnableDebugBtn2, kDebugPreviousBtn, kDebugNextBtn, kValidateBtn, kDPadVertical, kDPadHorizontal };

18
Assets/ScriptableRenderPipeline/common/Debugging/DebugItemDrawer.cs


{
newItemUI = new DebugMenuFloatItemUI(parent, menuItem, m_Label.text);
}
else if (menuItem.GetItemType() == typeof(Color))
{
newItemUI = new DebugMenuColorItemUI(parent, menuItem, m_Label.text);
}
else if (m_MenuItem.GetItemType().BaseType == typeof(System.Enum))
{
newItemUI = new DebugMenuEnumItemUI(parent, menuItem, m_Label.text, m_EnumStrings, m_EnumValues);

}
}
void DrawColorItem()
{
EditorGUI.BeginChangeCheck();
Color value = EditorGUILayout.ColorField(m_Label, (Color)m_MenuItem.GetValue());
if (EditorGUI.EndChangeCheck())
{
m_MenuItem.SetValue(value);
}
}
void DrawEnumItem()
{
EditorGUI.BeginChangeCheck();

else if (m_MenuItem.GetItemType() == typeof(float))
{
DrawFloatItem();
}
else if (m_MenuItem.GetItemType() == typeof(Color))
{
DrawColorItem();
}
else if (m_MenuItem.GetItemType().BaseType == typeof(System.Enum))
{

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


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

77
Assets/ScriptableRenderPipeline/common/Debugging/DebugMenuItemUI.cs


protected GameObject m_Root = null;
protected DebugMenuItem m_MenuItem = null;
protected DebugMenuItemUI(DebugMenuItem menuItem)
{
m_MenuItem = menuItem;
}
public abstract void SetSelected(bool value);
public abstract void OnValidate();
public abstract void OnIncrement();

protected GameObject m_Value = null;
protected DebugMenuSimpleItemUI(GameObject parent, DebugMenuItem menuItem, string name)
: base(menuItem)
m_MenuItem = menuItem;
m_Root = new GameObject();
m_Root.transform.SetParent(parent.transform, false);
UI.HorizontalLayoutGroup horizontalLayout = m_Root.AddComponent<UI.HorizontalLayoutGroup>();
horizontalLayout.childControlHeight = true;
horizontalLayout.childControlWidth = true;
horizontalLayout.childForceExpandHeight = false;
horizontalLayout.childForceExpandWidth = false;
m_Name = DebugMenuUI.CreateTextDebugElement(m_MenuItem.name, name, 10, TextAnchor.MiddleLeft, m_Root);
m_Root = DebugMenuUI.CreateHorizontalLayoutGroup("", true, true, false, false, parent);
m_Name = DebugMenuUI.CreateTextElement(m_MenuItem.name, name, 10, TextAnchor.MiddleLeft, m_Root);
m_Value = DebugMenuUI.CreateTextDebugElement(string.Format("{0} value", name), "", 10, TextAnchor.MiddleLeft, m_Root);
m_Value = DebugMenuUI.CreateTextElement(string.Format("{0} value", name), "", 10, TextAnchor.MiddleLeft, m_Root);
}
public override void SetSelected(bool value)

m_MenuItem.SetValue(m_CurrentValueIndex);
UpdateText();
}
}
public class DebugMenuColorItemUI : DebugMenuItemUI
{
protected GameObject m_Name = null;
protected GameObject m_ColorRect = null;
public DebugMenuColorItemUI(GameObject parent, DebugMenuItem menuItem, string name)
: base(menuItem)
{
m_MenuItem = menuItem;
m_Root = DebugMenuUI.CreateHorizontalLayoutGroup(name, true, true, false, false, parent);
m_Name = DebugMenuUI.CreateTextElement(m_MenuItem.name, name, 10, TextAnchor.MiddleLeft, m_Root);
var layoutElemName = m_Name.AddComponent<UI.LayoutElement>();
layoutElemName.minWidth = DebugMenuUI.kDebugItemNameWidth;
// Force layout because we need the right height for the color rect element afterward.
UI.LayoutRebuilder.ForceRebuildLayoutImmediate(m_Root.GetComponent<RectTransform>());
RectTransform nameRect = m_Name.GetComponent<RectTransform>();
m_ColorRect = new GameObject();
m_ColorRect.transform.SetParent(m_Root.transform, false);
m_ColorRect.AddComponent<UI.Image>();
UI.LayoutElement layoutElem = m_ColorRect.AddComponent<UI.LayoutElement>();
// We need to set min width/height because without an image, the size would be zero.
layoutElem.minHeight = nameRect.rect.height;
layoutElem.minWidth = 40.0f;
Update();
}
void Update()
{
Color currentValue = (Color)m_MenuItem.GetValue();
UI.Image image = m_ColorRect.GetComponent<UI.Image>();
image.color = currentValue;
}
public override void SetSelected(bool value)
{
m_Name.GetComponent<UI.Text>().color = value ? DebugMenuUI.kColorSelected : DebugMenuUI.kColorUnSelected;
}
// TODO: Edit mode!
public override void OnValidate()
{
}
public override void OnIncrement()
{
}
public override void OnDecrement()
{
}
}
}

33
Assets/ScriptableRenderPipeline/common/Debugging/DebugMenuUI.cs


{
public static Color kColorSelected = new Color(1.0f, 1.0f, 1.0f, 1.0f);
public static Color kColorUnSelected = new Color(0.25f, 0.25f, 0.25f, 1.0f);
public static Color kBackgroundColor = new Color(0.5f, 0.5f, 0.5f, 0.4f);
public static float kDebugItemNameWidth = 150.0f;
GameObject m_Root = null;

image.rectTransform.anchorMax = new Vector2(1.0f, 1.0f);
image.rectTransform.anchoredPosition = new Vector2(kBorderSize, kBorderSize);
image.rectTransform.sizeDelta = new Vector2(-(kBorderSize * 2.0f), -(kBorderSize * 2.0f));
image.color = new Color(0.5f, 0.5f, 0.5f, 0.4f);
image.color = kBackgroundColor;
GameObject goVL = new GameObject("DebugMenu VLayout");
goVL.transform.SetParent(go.transform, false);

menuVL.childForceExpandWidth = true;
menuVL.childForceExpandHeight = false;
DebugMenuUI.CreateTextDebugElement("DebugMenuTitle", "Debug Menu", 14, TextAnchor.MiddleCenter, goVL);
DebugMenuUI.CreateTextElement("DebugMenuTitle", "Debug Menu", 14, TextAnchor.MiddleCenter, goVL);
int menuCount = m_DebugMenuManager.menuCount;
m_MenuRoots = new GameObject[menuCount];

}
}
public static GameObject CreateTextDebugElement(string elementName, string text, int size = 14, TextAnchor alignment = TextAnchor.MiddleLeft, GameObject parent = null)
public static GameObject CreateVerticalLayoutGroup(string name, bool controlWidth, bool controlHeight, bool forceExpandWidth, bool forceExpandHeight, GameObject parent = null )
{
GameObject go = new GameObject(name);
go.transform.SetParent(parent.transform, false);
UI.VerticalLayoutGroup horizontalLayout = go.AddComponent<UI.VerticalLayoutGroup>();
horizontalLayout.childControlHeight = controlHeight;
horizontalLayout.childControlWidth = controlWidth;
horizontalLayout.childForceExpandHeight = forceExpandHeight;
horizontalLayout.childForceExpandWidth = forceExpandWidth;
return go;
}
public static GameObject CreateHorizontalLayoutGroup(string name, bool controlWidth, bool controlHeight, bool forceExpandWidth, bool forceExpandHeight, GameObject parent = null)
{
GameObject go = new GameObject(name);
go.transform.SetParent(parent.transform, false);
UI.HorizontalLayoutGroup horizontalLayout = go.AddComponent<UI.HorizontalLayoutGroup>();
horizontalLayout.childControlHeight = controlHeight;
horizontalLayout.childControlWidth = controlWidth;
horizontalLayout.childForceExpandHeight = forceExpandHeight;
horizontalLayout.childForceExpandWidth = forceExpandWidth;
return go;
}
public static GameObject CreateTextElement(string elementName, string text, int size = 14, TextAnchor alignment = TextAnchor.MiddleLeft, GameObject parent = null)
{
GameObject goText = new GameObject(elementName);
goText.transform.SetParent(parent.transform, false);

52
ProjectSettings/InputManager.asset


axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: D-Pad Horizontal
m_Name: Debug Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton: left

axis: 5
joyNum: 0
- serializedVersion: 3
m_Name: D-Pad Vertical
m_Name: Debug Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton: down

type: 2
axis: 6
joyNum: 0
- serializedVersion: 3
m_Name: Debug Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton: left
positiveButton: right
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 6
joyNum: 0
- serializedVersion: 3
m_Name: Debug Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton: down
positiveButton: up
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 6
joyNum: 0
- serializedVersion: 3
m_Name: Debug Validate
descriptiveName:
descriptiveNegativeName:
negativeButton: return
positiveButton:
altNegativeButton: joystick button 0
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 6
joyNum: 0
正在加载...
取消
保存