private void AssignDefaultConfigurationValues( System.Type componentType, SerializedProperty componentName, SerializedProperty configurationProfile, SerializedProperty runtimePlatform) { configurationProfile.objectReferenceValue = null; runtimePlatform.intValue = -1; if (componentType != null) { if (MixedRealityExtensionServiceAttribute.Find(componentType) is MixedRealityExtensionServiceAttribute attr) { componentName.stringValue = !string.IsNullOrWhiteSpace(attr.Name) ? attr.Name : componentType.Name; configurationProfile.objectReferenceValue = attr.DefaultProfile; runtimePlatform.intValue = (int)attr.RuntimePlatforms; } else { componentName.stringValue = componentType.Name; } } serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Inspect the attributes of the provided type to determine if a configuration profile is required. /// </summary> /// <param name="type">The type representing the service.</param> /// <returns> /// True if the type is decorated with an attribute indicating a profile is required, false otherwise. /// </returns> protected static bool IsProfileRequired(Type type) { // Services marked with the MixedRealityExtensionServiceAttribute (or a derivative) // support specifying whether or not a profile is required. MixedRealityExtensionServiceAttribute attribute = (type != null) ? MixedRealityExtensionServiceAttribute.Find(type) : null; return(attribute != null && attribute.RequiresProfile); }
private void AssignDefaultConfigurationValues(System.Type componentType, SerializedProperty configurationProfile, SerializedProperty runtimePlatform) { configurationProfile.objectReferenceValue = null; runtimePlatform.intValue = -1; if (componentType != null && MixedRealityExtensionServiceAttribute.Find(componentType) is MixedRealityExtensionServiceAttribute attr) { configurationProfile.objectReferenceValue = attr.DefaultProfile; runtimePlatform.intValue = (int)attr.RuntimePlatforms; } serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Applies the given concrete data provider type properties to the provided <see cref="IMixedRealityServiceConfiguration"/> instance (as represented by <see cref="ServiceConfigurationProperties"/>). /// Requires <see cref="MixedRealityDataProviderAttribute"/> on concrete type class to pull initial values /// that will be applied to the <see cref="ServiceConfigurationProperties"/> container SerializedProperties /// </summary> protected virtual void ApplyProviderConfiguration(Type dataProviderType, ServiceConfigurationProperties providerProperties) { if (dataProviderType != null) { if (MixedRealityExtensionServiceAttribute.Find(dataProviderType) is MixedRealityDataProviderAttribute providerAttribute) { providerProperties.componentName.stringValue = !string.IsNullOrWhiteSpace(providerAttribute.Name) ? providerAttribute.Name : dataProviderType.Name; providerProperties.providerProfile.objectReferenceValue = providerAttribute.DefaultProfile; providerProperties.runtimePlatform.intValue = (int)providerAttribute.RuntimePlatforms; } else { providerProperties.componentName.stringValue = dataProviderType.Name; } serializedObject.ApplyModifiedProperties(); } }
/// <summary> /// Render list of data provider configuration profiles in inspector. Use provided add and remove content labels for the insert/remove buttons /// Returns true if any property has changed in this render pass, false otherwise /// </summary> protected bool RenderDataProviderList(GUIContent addContentLabel, GUIContent removeContentLabel, string errorMsg, Type dataProviderProfileType = null) { bool changed = false; using (new EditorGUILayout.VerticalScope()) { if (providerConfigurations == null || providerConfigurations.arraySize == 0) { EditorGUILayout.HelpBox(errorMsg, MessageType.Info); } if (InspectorUIUtility.RenderIndentedButton(addContentLabel, EditorStyles.miniButton)) { AddDataProvider(); return(true); } #if UNITY_2019 xrPipelineUtility.RenderXRPipelineTabs(); #endif // UNITY_2019 delayedDisplayProviders.Clear(); for (int i = 0; i < providerConfigurations.arraySize; i++) { SystemType serviceType = GetDataProviderConfiguration(i).ComponentType; if (serviceType.Type != null && MixedRealityExtensionServiceAttribute.Find(serviceType.Type) is MixedRealityDataProviderAttribute providerAttribute) { // Using == here to compare flags because we want to know if this is the only supported pipeline // Providers that support multiple pipelines are rendered below the tabbed section if (providerAttribute.SupportedUnityXRPipelines == xrPipelineUtility.SelectedPipeline) { changed |= RenderDataProviderEntry(i, removeContentLabel, serviceType, dataProviderProfileType); delayedDisplayProviders.Add(null); } else if (providerAttribute.SupportedUnityXRPipelines == (SupportedUnityXRPipelines)(-1)) { delayedDisplayProviders.Add(serviceType); } else { // Add null to ensure the delayedDisplayProviders list has an identical size to providerConfigurations.arraySize // This is so we can iterate through without keeping track of i separately delayedDisplayProviders.Add(null); } } else { delayedDisplayProviders.Add(serviceType); } } #if UNITY_2019 EditorGUILayout.LabelField(GeneralProvidersLabel, EditorStyles.boldLabel); #endif // UNITY_2019 for (int i = 0; i < delayedDisplayProviders.Count; i++) { SystemType service = delayedDisplayProviders[i]; if (service != null) { changed |= RenderDataProviderEntry(i, removeContentLabel, service, dataProviderProfileType); } } return(changed); } }