Beispiel #1
0
    public IEnumerator SampleModelsTestLoadAllGlb()
    {
        yield return(GltfSampleModels.LoadGlbFileUrls());

        foreach (var file in GltfSampleModels.glbFileUrls)
        {
            var path = string.Format(
#if UNITY_ANDROID && !UNITY_EDITOR
                "{0}"
#else
                "file://{0}"
#endif
                , file
                );

            Debug.LogFormat("Testing {0}", path);

            var go        = new GameObject();
            var gltfAsset = go.AddComponent <GltfAsset>();

            bool done = false;

            gltfAsset.onLoadComplete += (success) => { done = true; Assert.IsTrue(success); };
            gltfAsset.url             = path;

            while (!done)
            {
                yield return(null);
            }
            Object.Destroy(go);
        }
    }
Beispiel #2
0
    public IEnumerator SampleModelsTestCheckFiles()
    {
        yield return(GltfSampleModels.LoadGlbFileUrls());

        CheckFileExist(GltfSampleModels.glbFileUrls);

        yield return(GltfSampleModels.LoadGltfFileUrls());

        CheckFileExist(GltfSampleModels.gltfFileUrls);
    }
    public IEnumerator SampleModelsTestCheckFiles()
    {
        yield return(GltfSampleModels.LoadGlbFileUrls());

        Assert.AreEqual(GltfSampleModels.glbFileUrls.Length, 44);
        CheckFileExist(GltfSampleModels.glbFileUrls);

        yield return(GltfSampleModels.LoadGltfFileUrls());

        Assert.AreEqual(GltfSampleModels.gltfFileUrls.Length, 120);
        CheckFileExist(GltfSampleModels.gltfFileUrls);
    }
Beispiel #4
0
    public IEnumerator SampleModelsTestLoadAllGlb()
    {
        yield return(GltfSampleModels.LoadGlbFileUrls());

        foreach (var file in GltfSampleModels.glbFileUrls)
        {
            var path = string.Format(
#if UNITY_ANDROID && !UNITY_EDITOR
                "{0}"
#else
                "file://{0}"
#endif
                , Path.Combine(Application.streamingAssetsPath, Path.Combine(prefix, file))
                );

            Debug.LogFormat("Testing {0}", path);

            var webRequest = UnityWebRequest.Get(path);
            yield return(webRequest.SendWebRequest());

            Assert.Null(webRequest.error);
            var bytes = webRequest.downloadHandler.data;

            Assert.NotNull(bytes);
            Assert.Greater(bytes.Length, 0);

            var go = new GameObject();
            var materialGenerator = new DefaultMaterialGenerator();
            var glTFast           = new GLTFast.GLTFast(materialGenerator);
            glTFast.LoadGlb(bytes, path);
            Assert.False(glTFast.LoadingError);
            yield return(glTFast.WaitForBufferDownloads());

            Assert.False(glTFast.LoadingError);
            yield return(glTFast.WaitForTextureDownloads());

            Assert.False(glTFast.LoadingError);
            yield return(glTFast.Prepare());

            Assert.False(glTFast.LoadingError);
            var success = glTFast.InstantiateGltf(go.transform);
            Assert.True(success);
            yield return(null);

            glTFast.Destroy();
            Object.Destroy(go);
        }
    }