public IEnumerator AccessSettings()
        {
            int frameCount = 0;

            string[] assets = new string[0] {
            };

            TestPackage pkg = new TestPackage();

            XRPackageMetadataStore.AddPackage(pkg);
            XRPackageInitializationBootstrap.InitPackage(pkg);

            while (frameCount < 60)
            {
                yield return(null);

                frameCount++;
            }

            yield return(null);

            var metadata = XRPackageMetadataStore.GetMetadataForPackage("com.unity.xr.testpackage");

            Assert.IsNotNull(metadata);

            assets = AssetDatabase.FindAssets($"t:{metadata.settingsType}");
            Assert.IsTrue(assets.Length == 1);
            var assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);

            var instance = AssetDatabase.LoadAssetAtPath(assetPath, typeof(TestSettings));

            Assert.IsNotNull(instance);
        }
        public void Setup()
        {
            AssetDatabase.DeleteAsset("Assets/XR");
            XRPackageInitializationBootstrap.BeginPackageInitialization();

            TestPackage pkg = new TestPackage();

            XRPackageMetadataStore.AddPackage(pkg);
            XRPackageInitializationBootstrap.InitPackage(pkg);
        }
Ejemplo n.º 3
0
        public void SetUp()
        {
            AssetDatabase.DeleteAsset("Assets/XR");

            AssetDatabase.CreateFolder("Assets", "XR");

            m_Settings      = ScriptableObject.CreateInstance <XRManagerSettings>() as XRManagerSettings;
            m_Settings.name = "Actual testable settings.";

            m_TestSettings         = ScriptableObject.CreateInstance <XRGeneralSettings>() as XRGeneralSettings;
            m_TestSettings.Manager = m_Settings;
            m_TestSettings.name    = "Standalone Settings Container.";

            m_TestSettingsPerBuildTarget = ScriptableObject.CreateInstance <XRGeneralSettingsPerBuildTarget>() as XRGeneralSettingsPerBuildTarget;
            m_TestSettingsPerBuildTarget.SetSettingsForBuildTarget(BuildTargetGroup.Standalone, m_TestSettings);

            var testPath = XRGeneralSettingsTests.GetAssetPathForComponents(s_TempSettingsPath);

            if (!string.IsNullOrEmpty(testPath))
            {
                AssetDatabase.CreateAsset(m_TestSettingsPerBuildTarget, Path.Combine(testPath, "Test_XRGeneralSettings.asset"));

                AssetDatabase.AddObjectToAsset(m_TestSettings, AssetDatabase.GetAssetOrScenePath(m_TestSettingsPerBuildTarget));

                AssetDatabase.CreateFolder(testPath, "Settings");
                testPath = Path.Combine(testPath, "Settings");
                AssetDatabase.CreateAsset(m_Settings, Path.Combine(testPath, "Test_XRSettingsManager.asset"));

                m_TestSettings.AssignedSettings = m_Settings;
                AssetDatabase.SaveAssets();
            }

            EditorBuildSettings.AddConfigObject(XRGeneralSettings.k_SettingsKey, m_TestSettingsPerBuildTarget, true);

            XRPackageInitializationBootstrap.BeginPackageInitialization();

            TestPackage pkg = new TestPackage();

            XRPackageMetadataStore.AddPluginPackage(pkg);
            XRPackageInitializationBootstrap.InitPackage(pkg);

            TestLoaderBase.WasAssigned   = false;
            TestLoaderBase.WasUnassigned = false;
        }