/// <summary>OnPostprocessBuild override to provide XR Plugin specific build actions.</summary>
        /// <param name="report">The build report.</param>
        public override void OnPostprocessBuild(BuildReport report)
        {
            base.OnPostprocessBuild(report);

            XRGeneralSettings settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(report.summary.platformGroup);

            if (settings == null)
            {
                return;
            }

            string bootConfigPath = report.summary.outputPath;

            if (report.summary.platformGroup == BuildTargetGroup.WSA)
            {
                bool usePrimaryWindow = true;
                WindowsMRBuildSettings buildSettings = BuildSettingsForBuildTargetGroup(report.summary.platformGroup);
                if (buildSettings != null)
                {
                    usePrimaryWindow = buildSettings.UsePrimaryWindowForDisplay;
                }

                // Boot Config data path is highly specific to the platform being built.
                bootConfigPath = Path.Combine(bootConfigPath, PlayerSettings.productName);
                bootConfigPath = Path.Combine(bootConfigPath, "Data");
                bootConfigPath = Path.Combine(bootConfigPath, "boot.config");

                using (StreamWriter sw = File.AppendText(bootConfigPath))
                {
                    sw.WriteLine(String.Format("{0}={1}", k_ForcePrimaryWindowHolographic, usePrimaryWindow ? 1 : 0));
                }
            }
        }
Example #2
0
    protected bool EnableLoader(string loaderTypeName, bool enable, BuildTargetGroup buildTargetGroup = BuildTargetGroup.Standalone)
    {
#if UNITY_EDITOR
        XRGeneralSettings settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);
#else
        XRGeneralSettings settings = XRGeneralSettings.Instance;
#endif

        if (settings == null || settings.Manager == null)
        {
            return(false);
        }

        var instance = TestBaseSetup.GetInstanceOfTypeWithNameFromAssetDatabase(loaderTypeName);
        if (instance == null || !(instance is XRLoader))
        {
            return(false);
        }

        XRLoader loader = instance as XRLoader;
        bool     ret    = false;

        if (enable)
        {
            ret = settings.Manager.TryAddLoader(loader);
        }
        else
        {
            ret = settings.Manager.TryRemoveLoader(loader);
        }

        return(ret);
    }
Example #3
0
        private static void SetUpAppRemoting(BuildTargetGroup targetGroup)
        {
            Debug.Log($"Setting up app remoting for {targetGroup}");

            const string AppRemotingPlugin  = "Microsoft.MixedReality.OpenXR.Remoting.AppRemotingPlugin";
            Type         appRemotingFeature = typeof(AppRemoting).Assembly.GetType(AppRemotingPlugin);

            if (appRemotingFeature == null)
            {
                Debug.LogError($"Could not find {AppRemotingPlugin}. Has this class been removed or renamed?");
                return;
            }

            FeatureHelpers.RefreshFeatures(targetGroup);
            OpenXRFeature feature = OpenXRSettings.ActiveBuildTargetInstance.GetFeature(appRemotingFeature);

            if (feature == null)
            {
                Debug.LogError($"Could not load {AppRemotingPlugin} as an OpenXR feature. Has this class been removed or renamed?");
                return;
            }
            feature.enabled = true;

            XRGeneralSettings settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(targetGroup);

            if (settings != null)
            {
                settings.InitManagerOnStart = false;
            }
        }
Example #4
0
        static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
        {
            if (s_ScenesWithARTypes.Count > 0 && s_SessionCount == 0)
            {
                var scenes = "";
                foreach (var sceneName in s_ScenesWithARTypes)
                {
                    scenes += string.Format("\n\t{0}", sceneName);
                }

                Debug.LogWarningFormat(
                    "The following scenes contain AR components but no ARSession. The ARSession component controls the AR lifecycle, so these components will not do anything at runtime. Was this intended?{0}",
                    scenes);
            }

            var generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));

            if (generalSettings != null && generalSettings.Manager != null && generalSettings.Manager.activeLoaders != null)
            {
                int loaderCount = generalSettings.Manager.activeLoaders.Count;
                if (loaderCount <= 0 && s_SessionCount > 0)
                {
                    Debug.LogWarning(
                        "There are scenes that contain an ARSession, but no XR plug-in providers have been selected for the current platform. To make a plug-in provider available at runtime go to Project Settings > XR Plug-in Management and enable at least one for the target platform.");
                }
            }

            s_ScenesWithARTypes.Clear();
            s_SessionCount = 0;
        }
        public void OnPreprocessBuild(BuildReport report)
        {
            SetRuntimePluginCopyDelegate();

            if (report.summary.platform != BuildTarget.Android)
            {
                // Sometimes (e.g., build failure), the shader can get "stuck" in the Preloaded Assets array.
                // Make sure that if we are not building for Android, we remove that shader.
                BuildHelper.RemoveShaderFromProject(ARCoreCameraSubsystem.backgroundShaderName);
                return;
            }

            var generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));

            if (generalSettings == null)
            {
                return;
            }

            foreach (var loader in generalSettings.Manager.loaders)
            {
                if (loader is ARCoreLoader)
                {
                    EnsureARCoreSupportedIsNotChecked();
                    EnsureGoogleARCoreIsNotPresent();
                    EnsureMinSdkVersion();
                    EnsureOnlyOpenGLES3IsUsed();
                    EnsureGradleIsUsed();
                    EnsureGradleVersionIsSupported();
                    BuildImageTrackingAssets();
                    BuildHelper.AddBackgroundShaderToProject(ARCoreCameraSubsystem.backgroundShaderName);
                    break;
                }
            }
        }
        public static bool OculusLoaderPresentInSettingsForBuildTarget(BuildTargetGroup btg)
        {
            var generalSettingsForBuildTarget = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(btg);

            if (!generalSettingsForBuildTarget)
            {
                return(false);
            }
            var settings = generalSettingsForBuildTarget.AssignedSettings;

            if (!settings)
            {
                return(false);
            }

            bool loaderFound = false;

            for (int i = 0; i < settings.activeLoaders.Count; ++i)
            {
                if (settings.activeLoaders[i] as OculusLoader != null)
                {
                    loaderFound = true;
                    break;
                }
            }

            return(loaderFound);
        }
Example #7
0
        private bool SetEnableLoderForTarget(BuildTargetGroup buildTargetGroup, bool enable)
        {
            if (buildTargetGroup != BuildTargetGroup.Standalone && buildTargetGroup != BuildTargetGroup.WSA)
            {
                return(false);
            }

            XRGeneralSettings settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);

            if (settings == null)
            {
                return(false);
            }

            bool ret = false;

            if (enable)
            {
                ret = XRPackageMetadataStore.AssignLoader(settings.Manager, typeof(WindowsMRLoader).Name, buildTargetGroup);
            }
            else
            {
                ret = XRPackageMetadataStore.RemoveLoader(settings.Manager, typeof(WindowsMRLoader).Name, buildTargetGroup);
            }

            return(ret);
        }
Example #8
0
        public bool ShouldIncludeRemotingPluginsInBuild(string path)
        {
            XRGeneralSettings generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));

            if (generalSettings == null)
            {
                return(false);
            }

            bool loaderFound = false;

            for (int i = 0; i < generalSettings.Manager.loaders.Count; ++i)
            {
                if (generalSettings.Manager.loaders[i] as WindowsMRLoader != null)
                {
                    loaderFound = true;
                    break;
                }
            }

            if (!loaderFound)
            {
                return(false);
            }

            WindowsMRBuildSettings buildSettings = BuildSettingsForBuildTargetGroup(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget)) as WindowsMRBuildSettings;

            if (buildSettings == null)
            {
                return(false);
            }

            return(buildSettings.HolographicRemoting);
        }
Example #9
0
    protected bool IsLoaderEnabledForTarget(BuildTargetGroup buildTargetGroup, string loaderTypeName)
    {
        if (buildTargetGroup != BuildTargetGroup.Standalone && buildTargetGroup != BuildTargetGroup.WSA)
        {
            return(false);
        }

#if UNITY_EDITOR
        XRGeneralSettings settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);
#else
        XRGeneralSettings settings = XRGeneralSettings.Instance;
#endif

        if (settings == null || settings.Manager == null)
        {
            return(false);
        }

        var instance = TestBaseSetup.GetInstanceOfTypeWithNameFromAssetDatabase(loaderTypeName);
        if (instance == null || !(instance is XRLoader))
        {
            return(false);
        }

        XRLoader loader = instance as XRLoader;
        return(settings.Manager.activeLoaders.Contains(loader));
    }
        public void OnPreprocessBuild(BuildReport report)
        {
            SetRuntimePluginCopyDelegate();

            if (report.summary.platform != BuildTarget.Android)
            {
                return;
            }

            XRGeneralSettings generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));

            if (generalSettings == null)
            {
                return;
            }

            foreach (var loader in generalSettings.Manager.loaders)
            {
                if (loader is ARCoreLoader)
                {
                    EnsureARCoreSupportedIsNotChecked();
                    EnsureGoogleARCoreIsNotPresent();
                    EnsureMinSdkVersion();
                    EnsureOnlyOpenGLES3IsUsed();
                    EnsureGradleIsUsed();
                    BuildImageTrackingAssets();
                    BuildHelper.AddBackgroundShaderToProject(ARCoreCameraSubsystem.backgroundShaderName);
                    break;
                }
            }
        }
        /// <summary>
        /// Applies any preprocessing necessary to setup assets for a given build target.
        /// </summary>
        /// <remarks>
        /// This method instantiates all classes that derive from <see cref="IPreprocessBuild"/> and executes their
        /// <see cref="IPreprocessBuild.OnPreprocessBuild"/> methods.
        ///
        /// You should call this before building asset bundles (see
        /// [BuildPipeline.BuildAssetBundles](xref:UnityEditor.BuildPipeline.BuildAssetBundles(System.String,UnityEditor.BuildAssetBundleOptions,UnityEditor.BuildTarget)))
        /// in order to ensure that all AR assets have been correctly configured.
        /// </remarks>
        /// <param name="buildTarget">The build target for which assets should be preprocessed.</param>
        public static void PreprocessBuild(BuildTarget buildTarget)
        {
            // Get the list of active loaders for the given BuildTarget
            var settings = XRGeneralSettingsPerBuildTarget
                           .XRGeneralSettingsForBuildTarget(BuildPipeline.GetBuildTargetGroup(buildTarget));
            var activeLoaders = settings && settings.Manager ? settings.Manager.activeLoaders : null;

            if (activeLoaders == null)
            {
                return;
            }

            // Clear the data store before asking packages to populate it.
            XRReferenceImageLibraryBuildProcessor.ClearDataStore();

            // Find and create all IPreprocessBuild objects
            var interfaces = AppDomain.CurrentDomain
                             .GetAssemblies()
                             .SelectMany(x => x.GetTypes())
                             .Where(type => Array.Exists(type.GetInterfaces(), i => i == typeof(IPreprocessBuild)))
                             .Select(type => Activator.CreateInstance(type) as IPreprocessBuild)
                             .Where(buildPreprocessor => buildPreprocessor != null)
                             .ToList();

            // Sort by callback order
            interfaces.Sort((a, b) => a.callbackOrder.CompareTo(b.callbackOrder));

            // Invoke OnPreprocessBuild on each one
            var eventArgs = new PreprocessBuildEventArgs(buildTarget, activeLoaders);

            foreach (var @interface in interfaces)
            {
                @interface.OnPreprocessBuild(eventArgs);
            }
        }
        private bool HasLoaderEnabledForTarget(BuildTargetGroup buildTargetGroup)
        {
            if (buildTargetGroup != BuildTargetGroup.Standalone && buildTargetGroup != BuildTargetGroup.Android)
            {
                return(false);
            }

            XRGeneralSettings settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);

            if (settings == null)
            {
                return(false);
            }

            bool loaderFound = false;

            for (int i = 0; i < settings.Manager.activeLoaders.Count; ++i)
            {
                if (settings.Manager.activeLoaders[i] as OculusLoader != null)
                {
                    loaderFound = true;
                    break;
                }
            }

            return(loaderFound);
        }
Example #13
0
        public static bool OculusLoaderPresentInSettingsForBuildTarget(BuildTargetGroup btg)
        {
            var generalSettingsForBuildTarget = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(btg);

            if (!generalSettingsForBuildTarget)
            {
                return(false);
            }
            var settings = generalSettingsForBuildTarget.AssignedSettings;

            if (!settings)
            {
                return(false);
            }

#if XR_MGMT_GTE_400
            bool loaderFound = false;
            for (int i = 0; i < settings.activeLoaders.Count; ++i)
            {
                if (settings.activeLoaders[i] as OculusLoader != null)
                {
                    loaderFound = true;
                    break;
                }
            }

            return(loaderFound);
#else
            List <XRLoader> loaders = settings.loaders;
            return(loaders.Exists(loader => loader is OculusLoader));
#endif
        }
        public void Verify_iOS_XR_Settings()
        {
            var generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.iOS);
            var settingManager  = generalSettings.Manager;

            Assert.AreEqual(true, generalSettings.InitManagerOnStart);
            Assert.AreEqual(1, settingManager.activeLoaders.Count());
            Assert.AreEqual("AR Kit Loader", settingManager.activeLoaders[0].name);
        }
Example #15
0
        public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, ref BuildOptions options, string configKey, string buildPath)
        {
            XRGeneralSettings generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(platform.targetGroup);
            XRManagerSettings settingsManager = generalSettings.Manager;

            generalSettings.InitManagerOnStart = InitializeXROnStartup;

            settingsManager.loaders = XRPlugins;
        }
 public void OnPreprocessBuild(BuildReport report)
 {
     if (!report.summary.platform.Equals(BuildTarget.StandaloneWindows) &&
         !report.summary.platform.Equals(BuildTarget.StandaloneWindows64))
     {
         var generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Standalone);
         var settingManager  = generalSettings.Manager;
         settingManager.loaders.Clear();
     }
 }
Example #17
0
    public void ValidateLoaderTest()
    {
        if (RuntimeSettings.reuseTestsForXR)
        {
            InjectMockHMD.SetupLoader();

            var buildTargetSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Standalone);

            Assert.That(buildTargetSettings != null, "Unable to read for XR settings for build target!");
            Assert.AreEqual(1, buildTargetSettings.AssignedSettings.loaders.Count, "There should be exactly one XR loader!");
            Assert.That(buildTargetSettings.InitManagerOnStart, "XR loader is not set to init on start!");
            Assert.AreEqual("Mock HMD Loader", buildTargetSettings.AssignedSettings.loaders[0].name, "Invalid XR loader found!");
        }
    }
Example #18
0
        public static bool HasLoader(BuildTargetGroup targetGroup, System.Type loader)
        {
            var settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(targetGroup);

            if (settings)
            {
#pragma warning disable CS0618
                return(settings.Manager.loaders.Any(loader.IsInstanceOfType));

#pragma warning restore CS0618
            }

            return(false);
        }
    public void UpdateConfig()
    {
        EditorUserBuildSettings.development = DevelopmentBuild;
        AppConfig.IsDebug       = DevelopmentBuild;
        AppConfig.IsHotfix      = IsHotfix;
        AppConfig.IsLoadAB      = IsLoadAB;
        AppConfig.IsProServer   = IsProServer;
        AppConfig.RunXLua       = RunXLuaScripts;
        AppConfig.AppFrameRate  = AppFrameRate;
        AppConfig.TargetPackage = ApkTarget;

        EditorUtility.SetDirty(AppConfig);

        if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
        {
            EditorUserBuildSettings.exportAsGoogleAndroidProject = NativeApp;

            XRGeneralSettings androidXRSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Android);

            if (androidXRSettings == null)
            {
                var assignedSettings = ScriptableObject.CreateInstance <XRManagerSettings>() as XRManagerSettings;
                androidXRSettings.AssignedSettings = assignedSettings;
                EditorUtility.SetDirty(androidXRSettings); // Make sure this gets picked up for serialization later.
            }

            //取消当前选择的
            IReadOnlyList <XRLoader> list = androidXRSettings.Manager.activeLoaders;
            int hasCount = list.Count;
            //Debug.Log(hasCount);
            for (int i = 0; i < hasCount; i++)
            {
                string nameTemp = list[0].GetType().FullName;
                Debug.Log("disable xr plug:" + nameTemp);
                XRPackageMetadataStore.RemoveLoader(androidXRSettings.Manager, nameTemp, BuildTargetGroup.Android);
            }
            androidXRSettings.InitManagerOnStart = false;
            if (ApkTarget == TargetPackage.Pico)
            {
                androidXRSettings.InitManagerOnStart = true;
                //启用
                string loaderTypeName = "Unity.XR.PXR.PXR_Loader";
                XRPackageMetadataStore.AssignLoader(androidXRSettings.Manager, loaderTypeName, BuildTargetGroup.Android);
            }
            EditorUtility.SetDirty(androidXRSettings); // Make sure this gets picked up for serialization later.
        }
        AssetDatabase.Refresh();
    }
Example #20
0
    public void ValidateLoaderTest()
    {
        if (RuntimeSettings.reuseTestsForXR)
        {
            InjectMockHMD.SetupLoader();

            var buildTargetSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Standalone);

// XRTODO: remove pragmas once MockHMD package is published with new dependencies to xr.sdk.management and replace loaders with activeLoaders
#pragma warning disable CS0618
            Assert.That(buildTargetSettings != null, "Unable to read for XR settings for build target!");
            Assert.AreEqual(1, buildTargetSettings.AssignedSettings.loaders.Count, "There should be exactly one XR loader!");
            Assert.That(buildTargetSettings.InitManagerOnStart, "XR loader is not set to init on start!");
            Assert.AreEqual("Mock HMD Loader", buildTargetSettings.AssignedSettings.loaders[0].name, "Invalid XR loader found!");
#pragma warning restore CS0618
        }
    }
Example #21
0
        internal static bool IsLoaderAssigned(string loaderTypeName, BuildTargetGroup buildTargetGroup)
        {
            var settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);

            if (settings == null)
            {
                return(false);
            }

            foreach (var loader in settings.AssignedSettings.loaders)
            {
                if (loader != null && String.Compare(loader.GetType().FullName, loaderTypeName) == 0)
                {
                    return(true);
                }
            }
            return(false);
        }
        public static bool LoaderPresentInSettingsForBuildTarget(BuildTargetGroup btg)
        {
            var generalSettingsForBuildTarget = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(btg);

            if (!generalSettingsForBuildTarget)
            {
                return(false);
            }
            var settings = generalSettingsForBuildTarget.AssignedSettings;

            if (!settings)
            {
                return(false);
            }
            List <XRLoader> loaders = settings.loaders;

            return(loaders.Exists(loader => loader is PXR_Loader));
        }
        public bool ShouldIncludeRuntimePluginsInBuild(string path)
        {
            XRGeneralSettings generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));

            if (generalSettings == null)
            {
                return(false);
            }

            foreach (var loader in generalSettings.Manager.loaders)
            {
                if (loader is OpenVRLoader)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #24
0
        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;
        }
Example #25
0
        public static XRGeneralSettings MakeSureXRGeneralSettingsExists(BuildTargetGroup targetGroup)
        {
            // If we don't have XRGeneralSettings in EditorBuildSettings, check if we have one in the project and set it.
            var settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(targetGroup);

            if (!settings)
            {
                string   searchText = "t:XRGeneralSettings";
                string[] assets     = AssetDatabase.FindAssets(searchText);
                if (assets.Length > 0)
                {
                    string path        = AssetDatabase.GUIDToAssetPath(assets[0]);
                    var    allSettings = AssetDatabase.LoadAssetAtPath(path, typeof(XRGeneralSettingsPerBuildTarget)) as XRGeneralSettingsPerBuildTarget;
                    EditorBuildSettings.AddConfigObject(XRGeneralSettings.k_SettingsKey, allSettings, true);
                }
            }

            return(settings);
        }
Example #26
0
        public static bool IsAnyXRLoaderEnabled(BuildTargetGroup buildTargetGroup)
        {
#if VIU_XR_GENERAL_SETTINGS
            XRGeneralSettings xrSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);
            if (!xrSettings)
            {
                return(false);
            }

            if (!xrSettings.AssignedSettings)
            {
                return(false);
            }

            return(xrSettings.AssignedSettings.loaders.Count > 0);
#else
            return(false);
#endif
        }
Example #27
0
        public bool ShouldIncludeRuntimePluginsInBuild(string path)
        {
            // Return false if not on platform Lumin
#if PLATFORM_LUMIN
            XRGeneralSettings generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));
            if (generalSettings == null)
            {
                return(false);
            }

            foreach (var loader in generalSettings.Manager.activeLoaders)
            {
                if (loader is MagicLeapLoader)
                {
                    return(true);
                }
            }
#endif // PLATFORM_LUMIN

            return(false);
        }
        private bool CheckARCoreLoader()
        {
            XRGeneralSettings generalSettings =
                XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(
                    BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));

            if (generalSettings == null)
            {
                return(false);
            }

            foreach (var loader in generalSettings.Manager.loaders)
            {
                if (loader is ARCoreLoader)
                {
                    return(true);
                }
            }

            return(false);
        }
        private bool HasLoaderEnabledForTarget(BuildTargetGroup buildTargetGroup)
        {
            XRGeneralSettings settings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTargetGroup);

            if (settings == null)
            {
                return(false);
            }

            bool loaderFound = false;

            for (int i = 0; i < settings.Manager.loaders.Count; ++i)
            {
                if (settings.Manager.loaders[i] as WindowsMRLoader != null)
                {
                    loaderFound = true;
                    break;
                }
            }

            return(loaderFound);
        }
Example #30
0
        static void UpdateARKitDefines()
        {
            bool previousLoaderEnabled = ARKitBuildProcessor.s_LoaderEnabled;

            var generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));

            if (generalSettings != null)
            {
                ARKitBuildProcessor.s_LoaderEnabled = false;
                foreach (var loader in generalSettings.Manager.activeLoaders)
                {
                    if (loader is ARKitLoader)
                    {
                        ARKitBuildProcessor.s_LoaderEnabled = true;
                        break;
                    }
                }

                if (ARKitBuildProcessor.s_LoaderEnabled && !previousLoaderEnabled)
                {
                    AddDefineSymbols.Add("UNITY_XR_ARKIT_LOADER_ENABLED");
                }
                else if (!ARKitBuildProcessor.s_LoaderEnabled && previousLoaderEnabled)
                {
                    AddDefineSymbols.Remove("UNITY_XR_ARKIT_LOADER_ENABLED");
                }

                if (s_ARKitSettings.faceTracking && !ARKitBuildProcessor.s_FaceTrackingEnabled)
                {
                    AddDefineSymbols.Add("UNITY_XR_ARKIT_FACE_TRACKING_ENABLED");
                }
                else if (!s_ARKitSettings.faceTracking && ARKitBuildProcessor.s_FaceTrackingEnabled)
                {
                    AddDefineSymbols.Remove("UNITY_XR_ARKIT_FACE_TRACKING_ENABLED");
                }

                ARKitBuildProcessor.s_FaceTrackingEnabled = s_ARKitSettings.faceTracking;
            }
        }