Example #1
0
        public IEnumerator NotFailIfExternalTexturesAreMissing()
        {
            ContentServerUtils.MappingPair[] input =
            {
                new ContentServerUtils.MappingPair {
                    file = "SimpleCubeWithSharedNormal.gltf", hash = "SimpleCubeWithSharedNormal.gltf"
                },
                new ContentServerUtils.MappingPair {
                    file = "SimpleCubeWithSharedNormal.bin", hash = "SimpleCubeWithSharedNormal.bin"
                },
            };

            core.settings.baseUrl = TestAssetsUtils.GetPath() + "/GLTF/SimpleCube/";

            env  = ABConverter.Environment.CreateWithDefaultImplementations();
            core = new ABConverter.Core(env, core.settings);

            core.Convert(input);

            yield return(new WaitUntil(() => core.state.step == ABConverter.Core.State.Step.FINISHED));

            Assert.IsTrue(core.state.lastErrorCode == ABConverter.Core.ErrorCodes.SUCCESS);
            LogAssert.Expect(LogType.Error, new Regex(@"^.*?Buffer file not found"));
            LogAssert.Expect(LogType.Error, new Regex(@"^.*?Buffer file not found"));
        }
Example #2
0
        public IEnumerator NotGenerateColorMapsWithDXTnm()
        {
            ContentServerUtils.MappingPair[] input =
            {
                new ContentServerUtils.MappingPair {
                    file = "SimpleCubeWithSharedNormal.gltf", hash = "SimpleCubeWithSharedNormal.gltf"
                },
                new ContentServerUtils.MappingPair {
                    file = "SimpleCubeWithSharedNormal.bin", hash = "SimpleCubeWithSharedNormal.bin"
                },
                new ContentServerUtils.MappingPair {
                    file = "Textures/Test.png", hash = "Test.png"
                }
            };

            core.settings.baseUrl  = TestAssetsUtils.GetPath() + "/GLTF/SimpleCube/";
            core.settings.verbose  = true;
            core.settings.dumpOnly = true;
            core.settings.deleteDownloadPathAfterFinished = false;

            env  = ABConverter.Environment.CreateWithDefaultImplementations();
            core = new ABConverter.Core(env, core.settings);

            core.Convert(input);

            yield return(new WaitUntil(() => core.state.step == ABConverter.Core.State.Step.FINISHED));

            Assert.IsTrue(core.state.lastErrorCode == ABConverter.Core.ErrorCodes.SUCCESS);

            string          importerPath = $"{core.finalDownloadedPath}Test.png{ABConverter.Config.DASH}Test.png.png";
            TextureImporter importer     = env.assetDatabase.GetImporterAtPath(importerPath) as TextureImporter;

            Assert.IsTrue(importer != null, "Texture importer is null!");
            Assert.IsTrue(TextureImporterType.NormalMap != importer.textureType, "Texture is used for color! It shouldn't be never importer as normal map!");
        }
Example #3
0
        public void InitializeDirectoryPathsCorrectly()
        {
            var settings = new ABConverter.Client.Settings(ContentServerUtils.ApiTLD.ZONE);

            settings.deleteDownloadPathAfterFinished = false;

            env  = ABConverter.Environment.CreateWithDefaultImplementations();
            core = new ABConverter.Core(env, settings);

            core.InitializeDirectoryPaths(false);

            Assert.IsFalse(string.IsNullOrEmpty(core.settings.finalAssetBundlePath));
            Assert.IsFalse(string.IsNullOrEmpty(core.finalDownloadedPath));

            Assert.IsTrue(env.directory.Exists(core.settings.finalAssetBundlePath));
            Assert.IsTrue(env.directory.Exists(core.finalDownloadedPath));

            string file1 = core.settings.finalAssetBundlePath + "test.txt";
            string file2 = core.finalDownloadedPath + "test.txt";

            env.file.WriteAllText(file1, "test");
            env.file.WriteAllText(file2, "test");

            core.InitializeDirectoryPaths(true);

            Assert.IsFalse(env.file.Exists(file1));
            Assert.IsFalse(env.file.Exists(file2));
        }
Example #4
0
        public IEnumerator ConvertAssetsWithExternalTextures()
        {
            ContentServerUtils.MappingPair[] input =
            {
                new ContentServerUtils.MappingPair {
                    file = "SimpleCubeWithSharedNormal.gltf", hash = "SimpleCubeWithSharedNormal.gltf"
                },
                new ContentServerUtils.MappingPair {
                    file = "SimpleCubeWithSharedNormal.bin", hash = "SimpleCubeWithSharedNormal.bin"
                },
                new ContentServerUtils.MappingPair {
                    file = "Textures/Test.png", hash = "Test.png"
                }
            };

            core.settings.baseUrl = TestAssetsUtils.GetPath() + "/GLTF/SimpleCube/";

            env  = ABConverter.Environment.CreateWithDefaultImplementations();
            core = new ABConverter.Core(env, core.settings);

            core.Convert(input);

            yield return(new WaitUntil(() => core.state.step == ABConverter.Core.State.Step.FINISHED));

            Assert.IsTrue(core.state.lastErrorCode == ABConverter.Core.ErrorCodes.SUCCESS);

            AssetBundle abDependency = AssetBundle.LoadFromFile(ABConverter.Config.ASSET_BUNDLES_PATH_ROOT + "/Test.png");

            abDependency.LoadAllAssets();

            AssetBundle abMain = AssetBundle.LoadFromFile(ABConverter.Config.ASSET_BUNDLES_PATH_ROOT + "/SimpleCubeWithSharedNormal.gltf");

            Material[] mats = abMain.LoadAllAssets <Material>();

            bool hasMap = false;

            foreach (var mat in mats)
            {
                hasMap = mat.GetTexture("_BaseMap") != null;
            }

            abMain.Unload(true);
            abDependency.Unload(true);

            Assert.IsTrue(hasMap, "Dependency has NOT been generated correctly!");
        }
Example #5
0
        public void SetUp()
        {
            ResetCacheAndWorkingFolders();

            var settings = new ABConverter.Client.Settings(ContentServerUtils.ApiTLD.ZONE);

            settings.deleteDownloadPathAfterFinished = false;

            env  = ABConverter.Environment.CreateWithMockImplementations();
            core = new ABConverter.Core(env, settings);

            if (env.webRequest is Mocked.WebRequest mockedReq)
            {
                mockedReq.mockedContent.Add($"{baseUrl}{hash1}", contentData1);
                mockedReq.mockedContent.Add($"{baseUrl}{hash2}", contentData2);
                mockedReq.mockedContent.Add($"{baseUrl}{hash3}", contentData3);
            }
        }