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.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) { 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); }