void AddPaths(string[] paths) { #if !UNITY_EDITOR string prefix = GltfSampleModels.baseUrl; #else string prefix = GltfSampleModels.baseUrlLocal; #endif var tmpLocalPath = localPath; items = new List <Tuple <string, string> >(); itemsLocal = new List <Tuple <string, string> >(); foreach (var path in paths) { var name = GltfSampleModels.GetNameFromPath(path); if (!string.IsNullOrEmpty(prefix)) { var p = string.Format( "{0}/{1}" , prefix , path ); items.Add(new Tuple <string, string>(name, p)); } var localPath = string.Format( "{0}/{1}" , tmpLocalPath , path ); itemsLocal.Add(new Tuple <string, string>(name, localPath)); } }
public IEnumerator SampleModelsTestLoadAllGltf() { yield return(GltfSampleModels.LoadGltfFileUrls()); foreach (var file in GltfSampleModels.gltfFileUrls) { 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, webRequest.error); Assert.IsFalse(webRequest.isNetworkError); Assert.IsFalse(webRequest.isHttpError); var json = webRequest.downloadHandler.text; Assert.NotNull(json); Assert.Greater(json.Length, 0); var go = new GameObject(GltfSampleModels.GetNameFromPath(file)); var materialGenerator = new DefaultMaterialGenerator(); var glTFast = new GLTFast.GLTFast(materialGenerator); glTFast.LoadGltf(json, path); Assert.IsFalse(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.IsTrue(success); yield return(null); glTFast.Destroy(); Object.Destroy(go); } }
public IEnumerator SampleModelsTestLoadAllGltf() { yield return(GltfSampleModels.LoadGltfFileUrls()); var deferAgent = new UninterruptedDeferAgent(); foreach (var file in GltfSampleModels.gltfFileUrls) { var path = string.Format( #if UNITY_ANDROID && !UNITY_EDITOR "{0}" #else "file://{0}" #endif , file ); Debug.LogFormat("Testing {0}", path); var webRequest = UnityWebRequest.Get(path); yield return(webRequest.SendWebRequest()); Assert.Null(webRequest.error, webRequest.error); Assert.IsFalse(webRequest.isNetworkError); Assert.IsFalse(webRequest.isHttpError); var json = webRequest.downloadHandler.text; Assert.NotNull(json); Assert.Greater(json.Length, 0); var go = new GameObject(GltfSampleModels.GetNameFromPath(path)); var gltfAsset = go.AddComponent <GltfAsset>(); bool done = false; gltfAsset.onLoadComplete += (asset, success) => { done = true; Assert.IsTrue(success); }; gltfAsset.loadOnStartup = false; gltfAsset.Load(path, null, deferAgent); while (!done) { yield return(null); } Object.Destroy(go); } }
IEnumerator InitGui() { #if !UNITY_EDITOR string prefix = GltfSampleModels.baseUrl; #else string prefix = GltfSampleModels.baseUrlLocal; #endif var prefixLocal = GltfSampleModels.localPath; yield return(GltfSampleModels.LoadGltfFileUrls()); var names = GltfSampleModels.gltfFileUrls; foreach (var n in names) { var t = GltfSampleModels.GetNameFromPath(n); testItems.Add(new System.Tuple <string, string>( t, string.Format( "{0}/{1}" , prefix , n ) ) ); testItemsLocal.Add(new System.Tuple <string, string>( t, string.Format( "{0}/{1}" , prefixLocal , n ) ) ); } }