Skip to content

Commit 7ea81cd

Browse files
authored
Merge pull request #9675 from keveleigh/add-filter-for-null-providers
Add configurable UI filter for null providers
2 parents 15629a8 + 77886ce commit 7ea81cd

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ protected class ServiceConfigurationProperties
4949
private static readonly GUIContent ComponentTypeLabel = new GUIContent("Type");
5050
private static readonly GUIContent SupportedPlatformsLabel = new GUIContent("Supported Platform(s)");
5151

52+
private const string NewDataProvider = "New data provider";
53+
5254
/// <inheritdoc/>
5355
protected override void OnEnable()
5456
{
@@ -72,7 +74,7 @@ protected virtual void AddDataProvider()
7274
SerializedProperty provider = providerConfigurations.GetArrayElementAtIndex(providerConfigurations.arraySize - 1);
7375

7476
ServiceConfigurationProperties providerProperties = GetDataProviderConfigurationProperties(provider);
75-
providerProperties.componentName.stringValue = $"New data provider {providerConfigurations.arraySize - 1}";
77+
providerProperties.componentName.stringValue = $"{NewDataProvider} {providerConfigurations.arraySize - 1}";
7678
providerProperties.runtimePlatform.intValue = -1;
7779
providerProperties.providerProfile.objectReferenceValue = null;
7880

@@ -162,6 +164,12 @@ protected bool RenderDataProviderEntry(int index, GUIContent removeContent, Syst
162164

163165
var serviceType = GetDataProviderConfiguration(index).ComponentType;
164166

167+
// Don't hide new data providers added via the UI, otherwise there's no easy way to change their type
168+
if (serviceType?.Type == null && !MixedRealityProjectPreferences.ShowNullDataProviders && !providerProperties.componentName.stringValue.StartsWith(NewDataProvider))
169+
{
170+
return false;
171+
}
172+
165173
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
166174
{
167175
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)