private string LoaderTypeNameForBuildTarget(BuildTargetGroup buildTargetGroup) { var loaders = XRPackageMetadataStore.GetLoadersForBuildTarget(buildTargetGroup); var filteredLoaders = from l in loaders where String.Compare(l.loaderType, typeof(TestLoaderOne).FullName) == 0 select l; if (filteredLoaders.Any()) { var loaderInfo = filteredLoaders.First(); return(loaderInfo.loaderType); } return(""); }
public void FilteringMetadataByBuildTargetGroup( [Values(BuildTargetGroup.Standalone, BuildTargetGroup.Android, BuildTargetGroup.Unknown, BuildTargetGroup.WebGL)] BuildTargetGroup buildTargetGroup, [Values("Test Loader One", "Test Loader Two", "Test Loader Three", "")] string expectedType) { var loaders = XRPackageMetadataStore.GetLoadersForBuildTarget(buildTargetGroup); Assert.IsTrue((loaders.Count > 0 && !String.IsNullOrEmpty(expectedType)) || (loaders.Count <= 0 && String.IsNullOrEmpty(expectedType))); if (!String.IsNullOrEmpty(expectedType)) { var loaderNames = from lm in loaders where String.Compare(lm.loaderName, expectedType, false) == 0 select lm.loaderName; Assert.IsTrue(loaderNames.Any()); Assert.IsTrue(loaderNames.Count() == 1); } }
internal bool OnGUI(BuildTargetGroup buildTargetGroup) { var settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup); if (buildTargetGroup != CurrentBuildTargetGroup || m_LoaderMetadata == null) { CurrentBuildTargetGroup = buildTargetGroup; if (m_LoaderMetadata == null) { m_LoaderMetadata = new List <LoaderInformation>(); } else { m_LoaderMetadata.Clear(); } foreach (var pmd in XRPackageMetadataStore.GetLoadersForBuildTarget(buildTargetGroup)) { var newLi = new LoaderInformation() { packageName = pmd.packageName, packageId = pmd.packageId, loaderName = pmd.loaderName, loaderType = pmd.loaderType, toggled = XRPackageMetadataStore.IsLoaderAssigned(pmd.loaderType, buildTargetGroup), disabled = false, customLoaderUI = XRCustomLoaderUIManager.GetCustomLoaderUI(pmd.loaderType, buildTargetGroup) }; if (newLi.customLoaderUI != null) { newLi.customLoaderUI.IsLoaderEnabled = newLi.toggled; newLi.customLoaderUI.ActiveBuildTargetGroup = CurrentBuildTargetGroup; } m_LoaderMetadata.Add(newLi); } if (settings != null) { List <LoaderInformation> loadersWantingToDisableOtherLoaders = new List <LoaderInformation>(); LoaderInformation li; for (int i = 0; i < m_LoaderMetadata.Count; i++) { li = m_LoaderMetadata[i]; if (XRPackageMetadataStore.IsLoaderAssigned(settings.AssignedSettings, li.loaderType)) { li.toggled = true; m_LoaderMetadata[i] = li; if (li.customLoaderUI != null) { loadersWantingToDisableOtherLoaders.Add(li); } break; } } foreach (var loader in loadersWantingToDisableOtherLoaders) { SetDisablesStateOnLoadersFromLoader(loader); } } m_OrderedList = new ReorderableList(m_LoaderMetadata, typeof(LoaderInformation), false, true, false, false); m_OrderedList.drawHeaderCallback = (rect) => { var labelSize = EditorStyles.label.CalcSize(Content.k_LoaderUITitle); var labelRect = new Rect(rect); labelRect.width = labelSize.x; labelSize = EditorStyles.label.CalcSize(Content.k_HelpContent); var imageRect = new Rect(rect); imageRect.xMin = labelRect.xMax + 1; imageRect.width = labelSize.x; EditorGUI.LabelField(labelRect, Content.k_LoaderUITitle, EditorStyles.label); if (GUI.Button(imageRect, Content.k_HelpContent, EditorStyles.label)) { System.Diagnostics.Process.Start(Content.k_HelpUri); } }; m_OrderedList.drawElementCallback = (rect, index, isActive, isFocused) => DrawElementCallback(rect, index, isActive, isFocused); m_OrderedList.drawElementBackgroundCallback = (rect, index, isActive, isFocused) => { var tex = GUI.skin.label.normal.background; if (tex == null && GUI.skin.label.normal.scaledBackgrounds.Length > 0) { tex = GUI.skin.label.normal.scaledBackgrounds[0]; } if (tex == null) { return; } GUI.DrawTexture(rect, GUI.skin.label.normal.background); }; m_OrderedList.drawFooterCallback = (rect) => { var status = XRPackageMetadataStore.GetCurrentStatusDisplayText(); GUI.Label(rect, EditorGUIUtility.TrTextContent(status), EditorStyles.label); }; m_OrderedList.elementHeightCallback = (index) => GetElementHeight(index); } if (m_LoaderMetadata == null || m_LoaderMetadata.Count == 0) { EditorGUILayout.HelpBox(k_AtNoLoaderInstance, MessageType.Info); } else { m_OrderedList.DoLayoutList(); if (settings != null) { LoaderInformation li; for (int i = 0; i < m_LoaderMetadata.Count; i++) { li = m_LoaderMetadata[i]; if (li.stateChanged && li.customLoaderUI != null) { SetDisablesStateOnLoadersFromLoader(li); } } for (int i = 0; i < m_LoaderMetadata.Count; i++) { li = m_LoaderMetadata[i]; if (li.stateChanged) { if (li.toggled) { XRPackageMetadataStore.InstallPackageAndAssignLoaderForBuildTarget(li.packageId, li.loaderType, buildTargetGroup); } else { XRPackageMetadataStore.RemoveLoader(settings.AssignedSettings, li.loaderType, buildTargetGroup); } li.stateChanged = false; m_LoaderMetadata[i] = li; } } } } return(false); }
internal bool OnGUI(BuildTargetGroup buildTargetGroup) { var settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup); if (buildTargetGroup != CurrentBuildTargetGroup || m_LoaderMetadata == null) { CurrentBuildTargetGroup = buildTargetGroup; if (m_LoaderMetadata == null) { m_LoaderMetadata = new List <LoaderInformation>(); } else { m_LoaderMetadata.Clear(); } foreach (var pmd in XRPackageMetadataStore.GetLoadersForBuildTarget(buildTargetGroup)) { m_LoaderMetadata.Add(new LoaderInformation() { packageName = pmd.packageName, packageId = pmd.packageId, loaderName = pmd.loaderName, loaderType = pmd.loaderType, toggled = XRPackageMetadataStore.IsLoaderAssigned(pmd.loaderType, buildTargetGroup) }); } if (settings != null) { LoaderInformation li; for (int i = 0; i < m_LoaderMetadata.Count; i++) { li = m_LoaderMetadata[i]; if (XRPackageMetadataStore.IsLoaderAssigned(settings.AssignedSettings, li.loaderType)) { li.toggled = true; m_LoaderMetadata[i] = li; break; } } } m_OrderedList = new ReorderableList(m_LoaderMetadata, typeof(LoaderInformation), false, true, false, false); m_OrderedList.drawHeaderCallback = (rect) => GUI.Label(rect, EditorGUIUtility.TrTextContent("Plug-in Providers"), EditorStyles.label); m_OrderedList.drawElementCallback = (rect, index, isActive, isFocused) => DrawElementCallback(rect, index, isActive, isFocused); m_OrderedList.elementHeightCallback = (index) => GetElementHeight(index); } if (m_LoaderMetadata == null || m_LoaderMetadata.Count == 0) { EditorGUILayout.HelpBox(k_AtNoLoaderInstance, MessageType.Info); } else { m_OrderedList.DoLayoutList(); if (settings != null) { LoaderInformation li; for (int i = 0; i < m_LoaderMetadata.Count; i++) { li = m_LoaderMetadata[i]; if (li.stateChanged) { if (li.toggled) { if (XRPackageMetadataStore.IsPackageInstalled(li.packageId)) { XRPackageMetadataStore.AssignLoader(settings.AssignedSettings, li.loaderType, buildTargetGroup); } else { XRPackageMetadataStore.InstallPackageAndAssignLoaderForBuildTarget(li.packageId, li.loaderType, buildTargetGroup); } } else { XRPackageMetadataStore.RemoveLoader(settings.AssignedSettings, li.loaderType, buildTargetGroup); } li.stateChanged = false; m_LoaderMetadata[i] = li; } } } } return(false); }