Siccity / GLTFUtility

Simple GLTF importer for Unity
MIT License
999 stars 219 forks source link

Error during editor import of GLB file #33

Open lucasmontec opened 4 years ago

lucasmontec commented 4 years ago

Model: https://poly.google.com/view/eu-5IFEOh6C

Error:

Siccity.GLTFUtility.GLTFMaterial+ImportTask.OnMainThreadFinalize () (at Assets/GLTFUtility/Scripts/Spec/GLTFMaterial.cs:225)
Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () (at Assets/GLTFUtility/Scripts/Importer.cs:96)
Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Assets/GLTFUtility/Scripts/Importer.cs:138)
Siccity.GLTFUtility.Importer.ImportGLB (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Assets/GLTFUtility/Scripts/Importer.cs:69)
Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations, Siccity.GLTFUtility.Format format) (at Assets/GLTFUtility/Scripts/Importer.cs:26)
Siccity.GLTFUtility.GLBImporter.OnImportAsset (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at Assets/GLTFUtility/Scripts/Editor/GLBImporter.cs:11)
UnityEditor.Experimental.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at C:/buildslave/unity/build/Modules/AssetPipelineEditor/Public/ScriptedImporter.cs:20)
Siccity commented 4 years ago

Error no longer occurs

Mrgove10 commented 4 years ago

How did you manage to fix this ? (using the UPM)

Siccity commented 4 years ago

I don't know what exactly fixed it, but I tested import with the newest version from the master branch.

Mrgove10 commented 4 years ago

When importing a model GLB i get

Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, System.Int64 binChunkStart, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Importer.cs:206)
Siccity.GLTFUtility.Importer.ImportGLB (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Importer.cs:92)
Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations, Siccity.GLTFUtility.Format format) (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Importer.cs:26)
Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.Format format) (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Importer.cs:16)
Load.Start () (at Assets/Scenes/_Test/GLTF/Load.cs:17)
Siccity commented 4 years ago

https://github.com/Siccity/GLTFUtility/blob/9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Importer.cs#L205-L207

That line is item.Dispose(); Perhaps it is null? Try changing it to if (item != null) item.Dispose();

Mrgove10 commented 4 years ago

That seams to have fixed it ! Tho when I import objects they apear in the hierarchy but they do not render, like if the object was a single point.

If i can get it working I would also like to do a PR to add examples.

Siccity commented 4 years ago

That was a workaround though. item is not supposed to be null. Can you send me the file that produces the error?

Mrgove10 commented 4 years ago

It depends on the file. If use the same file as the original issue

Model: https://poly.google.com/view/eu-5IFEOh6C

I get this error :

NullReferenceException: Object reference not set to an instance of an object
Siccity.GLTFUtility.GLTFTexture+ImportResult+<GetTextureCached>d__3.MoveNext () (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Spec/GLTFTexture.cs:28)
Siccity.GLTFUtility.GLTFMaterial+PbrMetalRoughness+<CreateMaterial>d__5.MoveNext () (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Spec/GLTFMaterial.cs:153)
Siccity.GLTFUtility.GLTFMaterial+<CreateMaterial>d__14.MoveNext () (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Spec/GLTFMaterial.cs:42)
Siccity.GLTFUtility.GLTFMaterial+ImportTask+<OnCoroutine>d__4.MoveNext () (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Spec/GLTFMaterial.cs:279)
Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Importer.cs:156)
Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, System.Int64 binChunkStart, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Importer.cs:196)
Siccity.GLTFUtility.Importer.ImportGLB (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Importer.cs:92)
Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations, Siccity.GLTFUtility.Format format) (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Importer.cs:26)
Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.Format format) (at Library/PackageCache/com.siccity.gltfutility@9c5adcf7d6d816de1b974c2863290f23491c1f13/Scripts/Importer.cs:16)
Load.Start () (at Assets/Scenes/_Test/GLTF/Load.cs:16)

I also tried with the example file from Khronos : https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/2.0/2CylinderEngine/glTF-Binary/2CylinderEngine.glb

In that case no errors but nothing renders image

I can not give you the original file because it is a payed asset sadly. But the issue (nothing rendering) is exactly the same as with the example file from Khronos.

Mrgove10 commented 4 years ago

Any news on this issue ?

waseemkhan1989 commented 4 years ago

Hi @Siccity I am facing the same issue while importing a gltf file. I am trying to import the same gltf file(not .bin file) that is on (https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/GearboxAssy/glTF) but from a different server. The error is:

NullReferenceException: Object reference not set to an instance of an object Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, System.Byte[] bytefile, System.Int64 binChunkStart, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) (at Assets/GLTFUtility-master/Scripts/Importer.cs:217) Siccity.GLTFUtility.Importer.ImportGLTF (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations) (at Assets/GLTFUtility-master/Scripts/Importer.cs:141) Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, UnityEngine.AnimationClip[]& animations, Siccity.GLTFUtility.Format format) (at Assets/GLTFUtility-master/Scripts/Importer.cs:32) Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.Format format) (at Assets/GLTFUtility-master/Scripts/Importer.cs:16) ModelLoader.LoadModel (System.String path) (at Assets/Scripts/ModelLoader.cs:116) ModelLoader.DownloadFile (System.String url) (at Assets/Scripts/ModelLoader.cs:87) UnityEngine.Events.InvokableCall1[T1].Invoke (T1 args0) (at <ee47be73f7ef409ca5e5ce4b121745b7>:0) UnityEngine.Events.CachedInvokableCall1[T].Invoke (System.Object[] args) (at :0) UnityEngine.Events.UnityEvent.Invoke () (at :0) UnityEngine.UI.Button.Press () (at C:/Program Files/Unity/Hub/Editor/2019.4.9f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:68) UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2019.4.9f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:110) UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2019.4.9f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50) UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Unity/Hub/Editor/2019.4.9f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261) UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2019.4.9f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)

Any solution to this problem?

rvenky125 commented 2 years ago

I'm also facing the error

poworoznykd commented 1 year ago

I am facing this error as well