GLTFUtility
GLTFUtility copied to clipboard
Can not load .glb file on Android device.
I put my .glb files on http server, and download on android's Application.persistentPath. the file can download and store successfully, but when l use GLTFComponent.load to load the glb file, but it doesn't show anything. I have testted it successfully in unity editor. I also switch to other plugins, GLTFUtility and glFast, it occur the same proplem. So, if any one can help me, I'll be very appreciae.
are you sure the object is just not loading outside of camera view? have you tried attaching a debugger to the device and seeing if it outputs any errors?
Thanks for your reply. After some tries with UnityGLTF, i have successed loading glb file on android device.
Thanks for your reply. After some tries with UnityGLTF, i have successed loading glb file on android device.
@wangyanmeego : can you please share how you solved your issue? other people might have similar problem and need information on how to solve the issue
I still have a similar problem to this one, as I try to import downloaded bytes and it works perfectly in the unity player but fails when I try it on Unity
This is the line I'm using to import the gltf bytes:
_rootObj = Importer.LoadFromBytes(gltf, importOptions);
And this is the exception I get while debugging on Android:
System.ArgumentNullException: Value cannot be null.\nParameter name: shader\n at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+PbrMetalRoughness+<CreateMaterial>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+<CreateMaterial>d__13.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+ImportTask+<OnCoroutine>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, System.Byte[] bytefile, System.Int64 binChunkStart, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.ImportGLB (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadFromBytes (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings) [0x00000] in <00000000000000000000000000000000>:0 \n at RuntimeGltfUtilityImporter+<ParseGltfUtilityFile>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
And here is a link to the glb model I'm using for testing: https://drive.google.com/uc?export=download&id=1p9JbNkmd1nfpT1tLRv5qqlVZ0qKZvTPI
@kelyamany Try creating a folder in the Assets folder, drag 'n GLB/GLTF file in there, then drag it into your scene, disable mesh renderer, seems if you have no object/gltf/glb in the Scene with shaders you get that error, or this is what worked for us. We created an empty cube, added material and just disabled the renderer.
i am facing the same problem I put my .glb files on http server, and download on android's Application.persistentPath. the file can download and store successfully, but when l use GLTFComponent.load to load the glb file, but it doesn't show anything. I have testted it successfully in unity editor. I also switch to other plugins, GLTFUtility and glFast, it occur the same proplem. So, if any one can help me, I'll be very appreciae.
What the issue you all are facing ? its very simple. Step :1 Import plugin Step 2 : Download glb using UnityWebrequest Step 3 : Call method Importer.ImportGLBAsync(avatarBytes, new ImportSettings(), OnImportFinished);
I still have a similar problem to this one, as I try to import downloaded bytes and it works perfectly in the unity player but fails when I try it on Unity
This is the line I'm using to import the gltf bytes:
_rootObj = Importer.LoadFromBytes(gltf, importOptions);
And this is the exception I get while debugging on Android:
System.ArgumentNullException: Value cannot be null.\nParameter name: shader\n at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+PbrMetalRoughness+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+d__13.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+ImportTask+d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, System.Byte[] bytefile, System.Int64 binChunkStart, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.ImportGLB (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadFromBytes (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings) [0x00000] in <00000000000000000000000000000000>:0 \n at RuntimeGltfUtilityImporter+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
And here is a link to the glb model I'm using for testing: https://drive.google.com/uc?export=download&id=1p9JbNkmd1nfpT1tLRv5qqlVZ0qKZvTPI
Hey did you find a solution to this this issue? I don't really understand the few solutions that have been suggested here so far.
I still have a similar problem to this one, as I try to import downloaded bytes and it works perfectly in the unity player but fails when I try it on Unity This is the line I'm using to import the gltf bytes:
_rootObj = Importer.LoadFromBytes(gltf, importOptions);
And this is the exception I get while debugging on Android:System.ArgumentNullException: Value cannot be null.\nParameter name: shader\n at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+PbrMetalRoughness+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+d__13.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+ImportTask+d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, System.Byte[] bytefile, System.Int64 binChunkStart, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.ImportGLB (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadFromBytes (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings) [0x00000] in <00000000000000000000000000000000>:0 \n at RuntimeGltfUtilityImporter+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
And here is a link to the glb model I'm using for testing: https://drive.google.com/uc?export=download&id=1p9JbNkmd1nfpT1tLRv5qqlVZ0qKZvTPI
Hey did you find a solution to this this issue? I don't really understand the few solutions that have been suggested here so far.
Actually I have not facing this kind of issue. if you can share demo project I can fix for you. I have tested its work in Unity Editor as well as Android device , even on webGL its working
I still have a similar problem to this one, as I try to import downloaded bytes and it works perfectly in the unity player but fails when I try it on Unity This is the line I'm using to import the gltf bytes:
_rootObj = Importer.LoadFromBytes(gltf, importOptions);
And this is the exception I get while debugging on Android:System.ArgumentNullException: Value cannot be null.\nParameter name: shader\n at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+PbrMetalRoughness+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+d__13.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.GLTFMaterial+ImportTask+d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, System.Byte[] bytefile, System.Int64 binChunkStart, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.ImportGLB (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) [0x00000] in <00000000000000000000000000000000>:0 \n at Siccity.GLTFUtility.Importer.LoadFromBytes (System.Byte[] bytes, Siccity.GLTFUtility.ImportSettings importSettings) [0x00000] in <00000000000000000000000000000000>:0 \n at RuntimeGltfUtilityImporter+d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
And here is a link to the glb model I'm using for testing: https://drive.google.com/uc?export=download&id=1p9JbNkmd1nfpT1tLRv5qqlVZ0qKZvTPI
Hey did you find a solution to this this issue? I don't really understand the few solutions that have been suggested here so far.
Actually I have not facing this kind of issue. if you can share demo project I can fix for you. I have tested its work in Unity Editor as well as Android device , even on webGL its working
I'm fairly new to Unity development. How can I share a demo project with you?
I still have a similar problem to this one, as I try to import downloaded bytes and it works perfectly in the unity player but fails when I try it on Unity This is the line I'm using to import the gltf bytes:
_rootObj = Importer.LoadFromBytes(gltf, importOptions);
OK, explain how you are downloading the data first, are you loading it from a URL or trying to load it from disk/storage?
I personally am downloading a GTLF from the web using DownloadHandlerFile. Then using Importer.LoadFromFile I'm failing when on the device. When I click play in Unity my debugging works fine, but on the device I get a very similar error as described here.
Same exact error here. Loading at runtime from a URL using ImportGLBAsync
. Model loads fine in editor, but this is the error I get on device (Pixel 4a).
I don't think this is related, but for added context, I'm using ARFoundation and URP.
EDIT: SOLVED: This is unrelated to Android. Unrelated to URP or anything else. This is a classic RTFM (the shaders are lost during compile time)
*Remember to add the URP shaders instead if you're building for URP
Same exact error here. Loading at runtime from a URL using
ImportGLBAsync
. Model loads fine in editor, but this is the error I get on device (Pixel 4a).I don't think this is related, but for added context, I'm using ARFoundation and URP.
EDIT: SOLVED: This is unrelated to Android. Unrelated to URP or anything else. This is a classic RTFM (the shaders are lost during compile time)
*Remember to add the URP shaders instead if you're building for URP
After following the suggested solution I'm still getting a couple errors in my logcat.
The first two are as follows (not sure if it's a real problem or not): 2022/06/29 11:37:22.964 30440 30462 Error Unity A scripted object (probably UnityEngine.XR.MagicLeap.MagicLeapSettings?) has a different serialization layout when loading. (Read 52 bytes but expected 76 bytes) 2022/06/29 11:37:22.964 30440 30462 Error Unity Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
Then a moment later the classic:
2022/06/29 11:37:27.133 30440 30462 Error Unity ArgumentNullException: Value cannot be null.
2022/06/29 11:37:27.133 30440 30462 Error Unity Parameter name: shader
followed by similar errors as previously mentioned:
error at wrapper, unityengine.material..ctor, HTLFMaterial
ha, well, at least during my time at ML, the MLSDK was fraught with benign warnings and weird errors. The first one is definitely unrelated but I'd try removing and reinstalling the MLSDK.
Hmm, I'm not sure why that would happen - but I'd assume the core problem's the same. If your gltf is showing up in the editor and missing at runtime, with that error, it means some shaders are not being included when compiling. Are you sure you're adding the right variants (URP / standard)?
For reference, this is what my Quality settings look like after the fix:
Yeah that's exactly how mine looks other than the URP folder.
I guess the difference with the steps that I took though are the GTLFUtility folder that I got these from are in my assets folder as the docs just said to clone the master, unzip, and drop it in assets. So mine wasn't in Packages like stated above.