static LoaderAssignmentRequests GetAllRequestsInQueue(string queueName) { var reqs = new LoaderAssignmentRequests(); reqs.activeRequests = new List <LoaderAssignmentRequest>(); if (XRPackageMetadataStore.SessionStateHasStoredData(queueName)) { string fromJson = SessionState.GetString(queueName, k_DefaultSessionStateString); reqs = JsonUtility.FromJson <LoaderAssignmentRequests>(fromJson); SessionState.EraseString(queueName); } return(reqs); }
private static void AssignAnyRequestedLoadersUpdate() { EditorApplication.update -= AssignAnyRequestedLoadersUpdate; LoaderAssignmentRequests reqs = GetAllRequestsInQueue(k_AssigningPackage); if (reqs.activeRequests == null || reqs.activeRequests.Count == 0) { return; } while (reqs.activeRequests.Count > 0) { var req = reqs.activeRequests[0]; reqs.activeRequests.RemoveAt(0); var settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(req.buildTargetGroup); if (settings == null) { continue; } if (settings.AssignedSettings == null) { var assignedSettings = ScriptableObject.CreateInstance <XRManagerSettings>() as XRManagerSettings; settings.AssignedSettings = assignedSettings; EditorUtility.SetDirty(settings); } if (XRPackageMetadataStore.AssignLoader(settings.AssignedSettings, req.loaderType, req.buildTargetGroup)) { Debug.Log($"Assigned loader {req.loaderType} for build target {req.buildTargetGroup}"); } else { req.installationState = InstallationState.Error; req.errorText = $"Unable to assign {req.packageId} for build target {req.buildTargetGroup}."; QueueLoaderRequest(req); } } XRSettingsManager.Instance.ResetUi = true; }
static void AddRequestToQueue(LoaderAssignmentRequest request, string queueName) { LoaderAssignmentRequests reqs; if (XRPackageMetadataStore.SessionStateHasStoredData(queueName)) { string fromJson = SessionState.GetString(queueName, k_DefaultSessionStateString); reqs = JsonUtility.FromJson <LoaderAssignmentRequests>(fromJson); } else { reqs = new LoaderAssignmentRequests(); reqs.activeRequests = new List <LoaderAssignmentRequest>(); } reqs.activeRequests.Add(request); string json = JsonUtility.ToJson(reqs); SessionState.SetString(queueName, json); }