Skip to content

Commit 3659ce3

Browse files
committed
Add UI filter for null data provider types
1 parent b3e046e commit 3659ce3

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Assets/MRTK/Core/Inspectors/Profiles/DataProviderAccessServiceInspector.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ protected bool RenderDataProviderEntry(int index, GUIContent removeContent, Syst
162162

163163
var serviceType = GetDataProviderConfiguration(index).ComponentType;
164164

165+
166+
SerializedProperty typeProperty = providerProperties.componentType.FindPropertyRelative("reference");
167+
if (!string.IsNullOrEmpty(typeProperty.stringValue) && Type.GetType(typeProperty.stringValue) == null && !MixedRealityProjectPreferences.ShowNullDataProviders)
168+
{
169+
return false;
170+
}
171+
165172
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
166173
{
167174
using (new EditorGUILayout.HorizontalScope())

Assets/MRTK/Core/Utilities/Editor/Preferences/MixedRealityProjectPreferences.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,34 @@ public static bool RunOptimalConfiguration
122122

123123
#endregion Run optimal configuration analysis on Play
124124

125+
#region Display null data providers
126+
127+
private static readonly GUIContent NullDataProviderContent = new GUIContent("Show null data providers in the input profile", "Mainly used for debugging unexpected behavior. Will render null data providers in red in the inspector.");
128+
private const string NULL_DATA_PROVIDER_KEY = "MixedRealityToolkit_Editor_NullDataProviders";
129+
private static bool nullDataProviderPrefLoaded;
130+
private static bool nullDataProvider;
131+
132+
/// <summary>
133+
/// Whether to show null data providers in the profile UI.
134+
/// </summary>
135+
/// <remarks>Mainly used for debugging unexpected behavior. Data providers may be null due to a namespace change or while using an incompatible Unity version.</remarks>
136+
public static bool ShowNullDataProviders
137+
{
138+
get
139+
{
140+
if (!nullDataProviderPrefLoaded)
141+
{
142+
nullDataProvider = ProjectPreferences.Get(NULL_DATA_PROVIDER_KEY, false);
143+
nullDataProviderPrefLoaded = true;
144+
}
145+
146+
return nullDataProvider;
147+
}
148+
set => ProjectPreferences.Set(NULL_DATA_PROVIDER_KEY, nullDataProvider = value);
149+
}
150+
151+
#endregion Display null data providers
152+
125153
#region Project configuration cache
126154

127155
// This section contains data that gets cached for future reference to help detect configuration
@@ -212,6 +240,12 @@ void GUIHandler(string searchContext)
212240
RunOptimalConfiguration = runOptimalConfig;
213241
}
214242

243+
bool nullProviders = EditorGUILayout.Toggle(NullDataProviderContent, ShowNullDataProviders);
244+
if (ShowNullDataProviders != nullProviders)
245+
{
246+
ShowNullDataProviders = nullProviders;
247+
}
248+
215249
EditorGUIUtility.labelWidth = prevLabelWidth;
216250
}
217251

0 commit comments

Comments
 (0)