Skip to content

Commit 9bd1e8e

Browse files
- Implemented first debug menu items (bool and float) in the player
- Implemented inputs for changing active menu item and modifying them.
1 parent 4b30272 commit 9bd1e8e

14 files changed

Lines changed: 659 additions & 149 deletions

Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/HDRenderPipelineDebug.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ public class GlobalDebugSettings
1717
public LightingDebugSettings lightingDebugSettings = new LightingDebugSettings();
1818
public RenderingDebugSettings renderingDebugSettings = new RenderingDebugSettings();
1919

20+
public void RegisterDebug()
21+
{
22+
DebugMenuManager.instance.AddDebugItem<LightingDebugMenu, bool>("Enable Shadows", () => lightingDebugSettings.enableShadows, (value) => lightingDebugSettings.enableShadows = (bool)value);
23+
DebugMenuManager.instance.AddDebugItem<LightingDebugMenu, bool>("Display Sky Reflection", () => lightingDebugSettings.displaySkyReflection, (value) => lightingDebugSettings.displaySkyReflection = (bool)value);
24+
DebugMenuManager.instance.AddDebugItem<LightingDebugMenu, float>("Sky Reflection Mipmap", () => lightingDebugSettings.skyReflectionMipmap, (value) => lightingDebugSettings.skyReflectionMipmap = (float)value);
25+
}
26+
2027
public void OnValidate()
2128
{
2229
lightingDebugSettings.OnValidate();

Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.asset

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ MonoBehaviour:
1717
debugOverlayRatio: 0.33
1818
displayMaterialDebug: 1
1919
displayRenderingDebug: 1
20-
displayLightingDebug: 0
20+
displayLightingDebug: 1
2121
materialDebugSettings:
2222
debugViewMaterial: 0
2323
lightingDebugSettings:
@@ -40,17 +40,15 @@ MonoBehaviour:
4040
useDepthPrepass: 0
4141
sssSettings:
4242
numProfiles: 0
43-
texturingMode: 0
44-
transmissionFlags: 0
4543
profiles: []
4644
m_ShadowSettings:
4745
enabled: 1
4846
shadowAtlasWidth: 4096
4947
shadowAtlasHeight: 4096
50-
maxShadowDistance: 1000
48+
maxShadowDistance: 800
5149
directionalLightCascadeCount: 4
5250
directionalLightCascades: {x: 0.05, y: 0.2, z: 0.3}
53-
directionalLightNearPlaneOffset: 5
51+
directionalLightNearPlaneOffset: 10
5452
m_TextureSettings:
5553
spotCookieSize: 128
5654
pointCookieSize: 512

Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ public void OnValidate()
145145
globalDebugSettings.OnValidate();
146146
sssSettings.OnValidate();
147147
}
148+
149+
void OnEnable()
150+
{
151+
globalDebugSettings.RegisterDebug();
152+
}
148153
}
149154

150155
[Serializable]

Assets/ScriptableRenderPipeline/common/Debugging/DebugActionManager.cs

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,20 @@ static public DebugActionManager instance
2222
private static string kEnableDebugBtn2 = "Enable Debug Button 2";
2323
private static string kDebugPreviousBtn = "Debug Previous";
2424
private static string kDebugNextBtn = "Debug Next";
25-
private string[] m_RequiredInputButtons = { kEnableDebugBtn1, kEnableDebugBtn2, kDebugPreviousBtn, kDebugNextBtn };
25+
private static string kValidateBtn = "Fire1";
26+
private static string kDPadVertical = "D-Pad Vertical";
27+
private static string kDPadHorizontal = "D-Pad Horizontal";
28+
private string[] m_RequiredInputButtons = { kEnableDebugBtn1, kEnableDebugBtn2, kDebugPreviousBtn, kDebugNextBtn, kValidateBtn, kDPadVertical, kDPadHorizontal };
2629

2730

2831
public enum DebugAction
2932
{
3033
EnableDebugMenu,
3134
PreviousDebugMenu,
3235
NextDebugMenu,
36+
Validate,
37+
MoveVertical,
38+
MoveHorizontal,
3339
DebugActionCount
3440
}
3541

@@ -42,6 +48,7 @@ enum DebugActionRepeatMode
4248
class DebugActionDesc
4349
{
4450
public List<string[]> buttonTriggerList = new List<string[]>();
51+
public string axisTrigger = "";
4552
public List<KeyCode[]> keyTriggerList = new List<KeyCode[]>();
4653
public DebugActionRepeatMode repeatMode = DebugActionRepeatMode.Never;
4754
public float repeatDelay = 0.0f;
@@ -52,24 +59,26 @@ class DebugActionState
5259
enum DebugActionKeyType
5360
{
5461
Button,
62+
Axis,
5563
Key
5664
}
5765

5866
DebugActionKeyType m_Type;
5967
string[] m_PressedButtons;
68+
string m_PressedAxis = "";
6069
KeyCode[] m_PressedKeys;
6170
bool[] m_TriggerPressedUp = null;
6271
float m_Timer;
6372
bool m_RunningAction = false;
64-
bool m_Actiontriggered = false;
73+
float m_ActionState = 0.0f;
6574

6675
public bool runningAction { get { return m_RunningAction; } }
67-
public bool actionTriggered { get { return m_Actiontriggered; } }
76+
public float actionState { get { return m_ActionState; } }
6877
public float timer{ get { return m_Timer; } }
6978

70-
private void Trigger(int triggerCount)
79+
private void Trigger(int triggerCount, float state)
7180
{
72-
m_Actiontriggered = true;
81+
m_ActionState = state;
7382
m_RunningAction = true;
7483
m_Timer = 0.0f;
7584

@@ -78,18 +87,27 @@ private void Trigger(int triggerCount)
7887
m_TriggerPressedUp[i] = false;
7988
}
8089

81-
public void Trigger(string[] buttons)
90+
public void TriggerWithButton(string[] buttons, float state)
8291
{
8392
m_Type = DebugActionKeyType.Button;
8493
m_PressedButtons = buttons;
85-
Trigger(buttons.Length);
94+
m_PressedAxis = "";
95+
Trigger(buttons.Length, state);
8696
}
8797

88-
public void Trigger(KeyCode[] keys)
98+
public void TriggerWithAxis(string axis, float state)
99+
{
100+
m_Type = DebugActionKeyType.Axis;
101+
m_PressedAxis = axis;
102+
Trigger(1, state);
103+
}
104+
105+
public void TriggerWithKey(KeyCode[] keys, float state)
89106
{
90107
m_Type = DebugActionKeyType.Key;
91108
m_PressedKeys = keys;
92-
Trigger(keys.Length);
109+
m_PressedAxis = "";
110+
Trigger(keys.Length, state);
93111
}
94112

95113
private void Reset()
@@ -102,7 +120,7 @@ private void Reset()
102120
public void Update(DebugActionDesc desc)
103121
{
104122
// Always reset this so that the action can only be caught once until repeat/reset
105-
m_Actiontriggered = false;
123+
m_ActionState = 0.0f;
106124

107125
if (m_TriggerPressedUp != null)
108126
{
@@ -112,6 +130,8 @@ public void Update(DebugActionDesc desc)
112130
{
113131
if (m_Type == DebugActionKeyType.Button)
114132
m_TriggerPressedUp[i] |= Input.GetButtonUp(m_PressedButtons[i]);
133+
else if(m_Type == DebugActionKeyType.Axis)
134+
m_TriggerPressedUp[i] |= (Input.GetAxis(m_PressedAxis) == 0.0f);
115135
else
116136
m_TriggerPressedUp[i] |= Input.GetKeyUp(m_PressedKeys[i]);
117137
}
@@ -143,7 +163,6 @@ public void Update(DebugActionDesc desc)
143163
enableDebugMenu.buttonTriggerList.Add(new[] { kEnableDebugBtn1, kEnableDebugBtn2 });
144164
enableDebugMenu.keyTriggerList.Add(new[] { KeyCode.LeftControl, KeyCode.Backspace });
145165
enableDebugMenu.repeatMode = DebugActionRepeatMode.Never;
146-
147166
AddAction(DebugAction.EnableDebugMenu, enableDebugMenu);
148167

149168
DebugActionDesc nextDebugMenu = new DebugActionDesc();
@@ -155,6 +174,15 @@ public void Update(DebugActionDesc desc)
155174
previousDebugMenu.buttonTriggerList.Add(new[] { kDebugPreviousBtn });
156175
previousDebugMenu.repeatMode = DebugActionRepeatMode.Never;
157176
AddAction(DebugAction.PreviousDebugMenu, previousDebugMenu);
177+
178+
DebugActionDesc validate = new DebugActionDesc();
179+
validate.buttonTriggerList.Add(new[] { kValidateBtn });
180+
validate.repeatMode = DebugActionRepeatMode.Delay;
181+
validate.repeatDelay = 0.25f;
182+
AddAction(DebugAction.Validate, validate);
183+
184+
AddAction(DebugAction.MoveVertical, new DebugActionDesc { axisTrigger = kDPadVertical, repeatMode = DebugActionRepeatMode.Delay, repeatDelay = 0.2f } );
185+
AddAction(DebugAction.MoveHorizontal, new DebugActionDesc { axisTrigger = kDPadHorizontal, repeatMode = DebugActionRepeatMode.Delay, repeatDelay = 0.2f } );
158186
}
159187

160188
void AddAction(DebugAction action, DebugActionDesc desc)
@@ -186,11 +214,21 @@ void SampleAction(int actionIndex)
186214

187215
if (allButtonPressed)
188216
{
189-
state.Trigger(buttons);
217+
state.TriggerWithButton(buttons, 1.0f);
190218
break;
191219
}
192220
}
193221

222+
// Check axis triggers
223+
if(desc.axisTrigger != "")
224+
{
225+
float axisValue = Input.GetAxis(desc.axisTrigger);
226+
if(axisValue != 0.0f)
227+
{
228+
state.TriggerWithAxis(desc.axisTrigger, axisValue);
229+
}
230+
}
231+
194232
// Check key triggers
195233
for (int keyListIndex = 0; keyListIndex < desc.keyTriggerList.Count; ++keyListIndex)
196234
{
@@ -205,7 +243,7 @@ void SampleAction(int actionIndex)
205243

206244
if (allKeyPressed)
207245
{
208-
state.Trigger(keys);
246+
state.TriggerWithKey(keys, 1.0f);
209247
break;
210248
}
211249
}
@@ -235,9 +273,9 @@ public void Update()
235273
}
236274
}
237275

238-
public bool GetAction(DebugAction action)
276+
public float GetAction(DebugAction action)
239277
{
240-
return m_DebugActionStates[(int)action].actionTriggered;
278+
return m_DebugActionStates[(int)action].actionState;
241279
}
242280
}
243281
}

0 commit comments

Comments
 (0)