예제 #1
0
        internal static void BeginPackageInitialization()
        {
            EditorApplication.update -= BeginPackageInitialization;

            foreach (var t in TypeLoaderExtensions.GetAllTypesWithInterface <IXRPackage>())
            {
                if (t.IsInterface || t.FullName.Contains("Unity.XR.Management.TestPackage") || t.FullName.Contains("UnityEditor.XR.Management.Metadata.KnownPackages"))
                {
                    continue;
                }

                IXRPackage package = Activator.CreateInstance(t) as IXRPackage;
                if (package == null)
                {
                    Debug.LogError($"Unable to find an implementation for expected package type {t.FullName}.");
                    continue;
                }
                InitPackage(package);
            }

            foreach (var t in TypeLoaderExtensions.GetAllTypesWithInterface <XRPackageInitializationBase>())
            {
                if (t.IsInterface)
                {
                    continue;
                }

                XRPackageInitializationBase packageInit = Activator.CreateInstance(t) as XRPackageInitializationBase;
                if (packageInit == null)
                {
                    Debug.LogError($"Unable to find an implementation for expected package type {t.FullName}.");
                    continue;
                }
                InitPackage(packageInit);
            }

            XRPackageMetadataStore.RebuildInstalledCache();
            XRPackageMetadataStore.AssignAnyRequestedLoaders();
        }