Skip to content

Commit 66979b0

Browse files
arttu-peltonenEvergreen
authored andcommitted
Remove uGUI dependency from RP Core package
1 parent c3084bc commit 66979b0

File tree

52 files changed

+457
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+457
-83
lines changed

Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugUIHandlerCanvasEditor.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#if ENABLE_UGUI_PACKAGE && (UNITY_EDITOR || DEVELOPMENT_BUILD)
2+
#define ENABLE_RENDERING_DEBUGGER_UI
3+
#endif
4+
5+
#if ENABLE_RENDERING_DEBUGGER_UI
6+
17
using System;
28
using System.Linq;
39
using UnityEditor;
@@ -77,3 +83,5 @@ public override void OnInspectorGUI()
7783
}
7884
}
7985
}
86+
87+
#endif

Packages/com.unity.render-pipelines.core/Editor/Debugging/UIFoldoutEditor.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#if ENABLE_UGUI_PACKAGE && (UNITY_EDITOR || DEVELOPMENT_BUILD)
2+
#define ENABLE_RENDERING_DEBUGGER_UI
3+
#endif
4+
5+
#if ENABLE_RENDERING_DEBUGGER_UI
6+
17
using UnityEngine.Rendering.UI;
28

39
namespace UnityEditor.Rendering.UI
@@ -32,3 +38,5 @@ public override void OnInspectorGUI()
3238
}
3339
}
3440
}
41+
42+
#endif

Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugManager.UIState.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
#if ENABLE_UGUI_PACKAGE && (UNITY_EDITOR || DEVELOPMENT_BUILD)
2+
#define ENABLE_RENDERING_DEBUGGER_UI
3+
#endif
4+
15
using System;
26
using System.Diagnostics;
3-
using UnityEngine.Rendering.UI;
47

58
#if UNITY_EDITOR
69
using UnityEditor;
710
#endif
811

9-
#if UNITY_ANDROID || UNITY_IPHONE || UNITY_TVOS || UNITY_SWITCH || UNITY_SWITCH2
12+
#if ENABLE_RENDERING_DEBUGGER_UI
1013
using UnityEngine.UI;
14+
using UnityEngine.Rendering.UI;
1115
#endif
1216

1317
namespace UnityEngine.Rendering
@@ -94,6 +98,7 @@ public bool enableRuntimeUI
9498
/// </summary>
9599
public bool displayRuntimeUI
96100
{
101+
#if ENABLE_RENDERING_DEBUGGER_UI
97102
get => m_Root != null && m_Root.activeInHierarchy;
98103
set
99104
{
@@ -123,13 +128,18 @@ public bool displayRuntimeUI
123128

124129
runtimeUIState.open = m_Root != null && m_Root.activeInHierarchy;
125130
}
131+
#else
132+
get => false;
133+
set => throw new NotSupportedException("Rendering Debugger Runtime UI requires the ugui package.");
134+
#endif
126135
}
127136

128137
/// <summary>
129138
/// Displays the persistent runtime debug window.
130139
/// </summary>
131140
public bool displayPersistentRuntimeUI
132141
{
142+
#if ENABLE_RENDERING_DEBUGGER_UI
133143
get => m_RootUIPersistentCanvas != null && m_PersistentRoot.activeInHierarchy;
134144
set
135145
{
@@ -144,6 +154,10 @@ public bool displayPersistentRuntimeUI
144154
m_RootUIPersistentCanvas = null;
145155
}
146156
}
157+
#else
158+
get => false;
159+
set => throw new NotSupportedException("Rendering Debugger Runtime UI requires the ugui package.");
160+
#endif
147161
}
148162
}
149163
}

Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugManager.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
#if ENABLE_UGUI_PACKAGE && (UNITY_EDITOR || DEVELOPMENT_BUILD)
2+
#define ENABLE_RENDERING_DEBUGGER_UI
3+
#endif
4+
15
using System;
26
using System.Collections.Generic;
37
using System.Collections.ObjectModel;
48
using System.Diagnostics.CodeAnalysis;
59
using System.Linq;
610
using UnityEngine.Assertions;
11+
12+
#if ENABLE_RENDERING_DEBUGGER_UI
713
using UnityEngine.Rendering.UI;
14+
#endif
815

916
namespace UnityEngine.Rendering
1017
{
@@ -123,11 +130,13 @@ public ReadOnlyCollection<DebugUI.Panel> panels
123130

124131
int? m_RequestedPanelIndex;
125132

133+
#if ENABLE_RENDERING_DEBUGGER_UI
126134
GameObject m_Root;
127135
DebugUIHandlerCanvas m_RootUICanvas;
128136

129137
GameObject m_PersistentRoot;
130138
DebugUIHandlerPersistentCanvas m_RootUIPersistentCanvas;
139+
#endif
131140

132141
/// <summary>
133142
/// Is any debug window or UI currently active.
@@ -175,8 +184,10 @@ public void Reset()
175184
/// </summary>
176185
public void ReDrawOnScreenDebug()
177186
{
187+
#if ENABLE_RENDERING_DEBUGGER_UI
178188
if (displayRuntimeUI)
179189
m_RootUICanvas?.RequestHierarchyReset();
190+
#endif
180191
}
181192

182193
/// <summary>
@@ -205,6 +216,7 @@ public int GetState()
205216
return hash;
206217
}
207218

219+
#if ENABLE_RENDERING_DEBUGGER_UI
208220
internal void RegisterRootCanvas(DebugUIHandlerCanvas root)
209221
{
210222
Assert.IsNotNull(root);
@@ -273,6 +285,7 @@ internal void TogglePersistent(DebugUI.Widget widget, int? forceTupleIndex = nul
273285
break;
274286
}
275287
}
288+
#endif
276289

277290
void OnPanelDirty(DebugUI.Panel panel)
278291
{

Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugUpdater.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1+
#if ENABLE_UGUI_PACKAGE && (UNITY_EDITOR || DEVELOPMENT_BUILD)
2+
#define ENABLE_RENDERING_DEBUGGER_UI
3+
#endif
4+
15
#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE
26
#define USE_INPUT_SYSTEM
37
using UnityEngine.InputSystem;
4-
using UnityEngine.InputSystem.UI;
58
using UnityEngine.InputSystem.EnhancedTouch;
69
#endif
710
using System;
811
using System.Collections;
912
using System.Diagnostics;
13+
using UnityEngine;
14+
15+
#if USE_INPUT_SYSTEM && ENABLE_RENDERING_DEBUGGER_UI
16+
using UnityEngine.InputSystem.UI;
17+
#endif
18+
19+
#if ENABLE_RENDERING_DEBUGGER_UI
1020
using UnityEngine.EventSystems;
21+
#endif
1122

1223
namespace UnityEngine.Rendering
1324
{
@@ -80,6 +91,7 @@ internal static void HandleInternalEventSystemComponents(bool uiEnabled)
8091

8192
void EnsureExactlyOneEventSystem()
8293
{
94+
#if ENABLE_RENDERING_DEBUGGER_UI
8395
var eventSystems = FindObjectsByType<EventSystem>(FindObjectsSortMode.None);
8496
var debugEventSystem = GetComponent<EventSystem>();
8597

@@ -97,6 +109,7 @@ void EnsureExactlyOneEventSystem()
97109
{
98110
StartCoroutine(DoAfterInputModuleUpdated(CheckInputModuleExists));
99111
}
112+
#endif
100113
}
101114

102115
IEnumerator DoAfterInputModuleUpdated(Action action)
@@ -111,13 +124,15 @@ IEnumerator DoAfterInputModuleUpdated(Action action)
111124

112125
void CheckInputModuleExists()
113126
{
127+
#if ENABLE_RENDERING_DEBUGGER_UI
114128
if (EventSystem.current != null && EventSystem.current.currentInputModule == null)
115129
{
116130
Debug.LogWarning("Found a game object with EventSystem component but no corresponding BaseInputModule component - Debug UI input might not work correctly.");
117131
}
132+
#endif
118133
}
119134

120-
#if USE_INPUT_SYSTEM
135+
#if USE_INPUT_SYSTEM && ENABLE_RENDERING_DEBUGGER_UI
121136
void AssignDefaultActions()
122137
{
123138
if (EventSystem.current != null && EventSystem.current.currentInputModule is InputSystemUIInputModule inputSystemModule)
@@ -143,17 +158,20 @@ void AssignDefaultActions()
143158

144159
void CreateDebugEventSystem()
145160
{
161+
#if ENABLE_RENDERING_DEBUGGER_UI
146162
gameObject.AddComponent<EventSystem>();
147163
#if USE_INPUT_SYSTEM
148164
gameObject.AddComponent<InputSystemUIInputModule>();
149165
StartCoroutine(DoAfterInputModuleUpdated(AssignDefaultActions));
150166
#else
151167
gameObject.AddComponent<StandaloneInputModule>();
168+
#endif
152169
#endif
153170
}
154171

155172
void DestroyDebugEventSystem()
156173
{
174+
#if ENABLE_RENDERING_DEBUGGER_UI
157175
var eventSystem = GetComponent<EventSystem>();
158176
#if USE_INPUT_SYSTEM
159177
var inputModule = GetComponent<InputSystemUIInputModule>();
@@ -167,6 +185,7 @@ void DestroyDebugEventSystem()
167185
CoreUtils.Destroy(GetComponent<BaseInput>());
168186
#endif
169187
CoreUtils.Destroy(eventSystem);
188+
#endif
170189
}
171190

172191
void Update()
@@ -187,6 +206,7 @@ void Update()
187206
debugManager.displayRuntimeUI = !debugManager.displayRuntimeUI;
188207
}
189208

209+
#if ENABLE_RENDERING_DEBUGGER_UI
190210
if (debugManager.displayRuntimeUI)
191211
{
192212
if (debugManager.GetAction(DebugAction.ResetAll) != 0.0f)
@@ -203,6 +223,7 @@ void Update()
203223
}
204224

205225
m_RuntimeUiWasVisibleLastFrame = debugManager.displayRuntimeUI;
226+
#endif
206227
}
207228

208229
static IEnumerator RefreshRuntimeUINextFrame()

Packages/com.unity.render-pipelines.core/Runtime/Debugging/Prefabs/Scripts/DebugUIHandlerBitField.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#if ENABLE_UGUI_PACKAGE && (UNITY_EDITOR || DEVELOPMENT_BUILD)
2+
#define ENABLE_RENDERING_DEBUGGER_UI
3+
#endif
4+
5+
#if ENABLE_RENDERING_DEBUGGER_UI
6+
17
using System.Collections.Generic;
28
using UnityEngine.UI;
39

@@ -172,3 +178,5 @@ public override DebugUIHandlerWidget Next()
172178
}
173179
}
174180
}
181+
182+
#endif

Packages/com.unity.render-pipelines.core/Runtime/Debugging/Prefabs/Scripts/DebugUIHandlerButton.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#if ENABLE_UGUI_PACKAGE && (UNITY_EDITOR || DEVELOPMENT_BUILD)
2+
#define ENABLE_RENDERING_DEBUGGER_UI
3+
#endif
4+
#if ENABLE_RENDERING_DEBUGGER_UI
5+
16
using UnityEngine.UI;
27

38
namespace UnityEngine.Rendering.UI
@@ -48,3 +53,5 @@ public override void OnAction()
4853
}
4954
}
5055
}
56+
57+
#endif

Packages/com.unity.render-pipelines.core/Runtime/Debugging/Prefabs/Scripts/DebugUIHandlerCanvas.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#if ENABLE_UGUI_PACKAGE && (UNITY_EDITOR || DEVELOPMENT_BUILD)
2+
#define ENABLE_RENDERING_DEBUGGER_UI
3+
#endif
4+
#if ENABLE_RENDERING_DEBUGGER_UI
5+
16
using System;
27
using System.Collections.Generic;
38
using System.Linq;
@@ -356,3 +361,5 @@ internal void SetScrollTarget(DebugUIHandlerWidget widget)
356361
}
357362
}
358363
}
364+
365+
#endif

Packages/com.unity.render-pipelines.core/Runtime/Debugging/Prefabs/Scripts/DebugUIHandlerColor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#if ENABLE_UGUI_PACKAGE && (UNITY_EDITOR || DEVELOPMENT_BUILD)
2+
#define ENABLE_RENDERING_DEBUGGER_UI
3+
#endif
4+
#if ENABLE_RENDERING_DEBUGGER_UI
5+
16
using UnityEngine.UI;
27

38
namespace UnityEngine.Rendering.UI
@@ -165,3 +170,5 @@ public override DebugUIHandlerWidget Next()
165170
}
166171
}
167172
}
173+
174+
#endif

Packages/com.unity.render-pipelines.core/Runtime/Debugging/Prefabs/Scripts/DebugUIHandlerContainer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#if ENABLE_UGUI_PACKAGE && (UNITY_EDITOR || DEVELOPMENT_BUILD)
2+
#define ENABLE_RENDERING_DEBUGGER_UI
3+
#endif
4+
#if ENABLE_RENDERING_DEBUGGER_UI
5+
16
using System.Collections.Generic;
27
using System.Linq;
38

@@ -65,3 +70,5 @@ List<DebugUIHandlerWidget> GetActiveChildren()
6570
}
6671
}
6772
}
73+
74+
#endif

0 commit comments

Comments
 (0)