internal void UpdateBooleanContextPropertyIfNeeded(LoaderInformation FieldValue, string FieldKey, IntPtr fusionContext, AppDomainSetup oldADS)
 {
     if (this.Value[(int)FieldValue] != null)
     {
         UpdateContextProperty(fusionContext, FieldKey, "true");
     }
     else if ((oldADS != null) && (oldADS.Value[(int)FieldValue] != null))
     {
         UpdateContextProperty(fusionContext, FieldKey, "false");
     }
 }
        internal bool UpdateContextPropertyIfNeeded(LoaderInformation FieldValue, string FieldKey, string UpdatedField, IntPtr fusionContext, AppDomainSetup oldADS)
        {
            string str  = this.Value[(int)FieldValue];
            string str2 = (oldADS == null) ? null : oldADS.Value[(int)FieldValue];

            if (str != str2)
            {
                UpdateContextProperty(fusionContext, FieldKey, (UpdatedField == null) ? str : UpdatedField);
                return(true);
            }
            return(false);
        }
예제 #3
0
 void SetDisablesStateOnLoadersFromLoader(LoaderInformation li)
 {
     for (int i = 0; i < m_LoaderMetadata.Count; i++)
     {
         var otherLi = m_LoaderMetadata[i];
         if (otherLi.loaderType == li.loaderType)
         {
             continue;
         }
         if (li.customLoaderUI != null && Array.IndexOf(li.customLoaderUI.IncompatibleLoaders, otherLi.loaderType) >= 0)
         {
             if (li.toggled && otherLi.toggled)
             {
                 otherLi.toggled      = false;
                 otherLi.stateChanged = true;
             }
             otherLi.disabled    = li.toggled;
             m_LoaderMetadata[i] = otherLi;
         }
     }
 }
예제 #4
0
        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 UpdateContextPropertyIfNeeded(LoaderInformation FieldValue, string FieldKey, string UpdatedField, IntPtr fusionContext, AppDomainSetup oldADS)
 {
     string str = this.Value[(int) FieldValue];
     string str2 = (oldADS == null) ? null : oldADS.Value[(int) FieldValue];
     if (str != str2)
     {
         UpdateContextProperty(fusionContext, FieldKey, (UpdatedField == null) ? str : UpdatedField);
         return true;
     }
     return false;
 }
 internal void UpdateBooleanContextPropertyIfNeeded(LoaderInformation FieldValue, string FieldKey, IntPtr fusionContext, AppDomainSetup oldADS)
 {
     if (this.Value[(int) FieldValue] != null)
     {
         UpdateContextProperty(fusionContext, FieldKey, "true");
     }
     else if ((oldADS != null) && (oldADS.Value[(int) FieldValue] != null))
     {
         UpdateContextProperty(fusionContext, FieldKey, "false");
     }
 }
예제 #7
0
        internal bool UpdateContextPropertyIfNeeded(LoaderInformation FieldValue, String FieldKey, String UpdatedField, IntPtr fusionContext, AppDomainSetup oldADS)
        {
            String FieldString = Value[(int) FieldValue],
                   OldFieldString = (oldADS == null ? null : oldADS.Value[(int) FieldValue]);
            if (FieldString != OldFieldString) { // Compare references since strings are immutable
                UpdateContextProperty(fusionContext, FieldKey, UpdatedField == null ? FieldString : UpdatedField);
                return true;
            }

	     return false;
        }