Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException while loading GLB during runtime #599

Closed
SathvikKS opened this issue Apr 19, 2023 · 1 comment
Closed

NullReferenceException while loading GLB during runtime #599

SathvikKS opened this issue Apr 19, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@SathvikKS
Copy link

Describe the bug
I am getting the NullReferenceException only after building the app and trying to load glb avatars. It works fine when loading avatar while running in Unity editor.

Files
ReadyPlayerMe Avatar

To Reproduce
Steps to reproduce the behaviour:

  1. Create a c# script to load a glb file at the start
  2. Build the project
  3. Run the exe file
  4. See the error

Expected behaviour
A loaded glb avatar.

Complete Log

NullReferenceException: Object reference not set to an instance of an object
  at GLTFast.Materials.BuiltInMaterialGenerator.GenerateDefaultMaterial (System.Boolean pointsSupport) [0x0003a] in C:\Users\sathv\Avatar SDK Expressions\Library\PackageCache\[email protected]\Runtime\Scripts\Material\BuiltInMaterialGenerator.cs:102 
  at GLTFast.Materials.MaterialGenerator.GetDefaultMaterial (System.Boolean pointsSupport) [0x0002e] in C:\Users\sathv\Avatar SDK Expressions\Library\PackageCache\[email protected]\Runtime\Scripts\Material\MaterialGenerator.cs:239 
  at GLTFast.GltfImport.GetDefaultMaterial () [0x00013] in C:\Users\sathv\Avatar SDK Expressions\Library\PackageCache\[email protected]\Runtime\Scripts\GltfImport.cs:704 
  at GLTFast.GameObjectInstantiator.AddPrimitive (System.UInt32 nodeIndex, System.String meshName, UnityEngine.Mesh mesh, System.Int32[] materialIndices, System.UInt32[] joints, System.Nullable`1[T] rootJoint, System.Single[] morphTargetWeights, System.Int32 primitiveNumeration) [0x001ad] in C:\Users\sathv\Avatar SDK Expressions\Library\PackageCache\[email protected]\Runtime\Scripts\GameObjectInstantiator.cs:294 
  at GLTFast.GltfImport+<>c__DisplayClass116_0.<InstantiateSceneInternal>g__PopulateHierarchy|2 (System.UInt32 nodeIndex, System.Nullable`1[T] parentIndex) [0x001c5] in C:\Users\sathv\Avatar SDK Expressions\Library\PackageCache\[email protected]\Runtime\Scripts\GltfImport.cs:2331 
  at GLTFast.GltfImport+<>c__DisplayClass116_0.<InstantiateSceneInternal>g__IterateNodes|0 (System.UInt32 nodeIndex, System.Nullable`1[T] parentIndex, System.Action`2[T1,T2] callback) [0x0003f] in C:\Users\sathv\Avatar SDK Expressions\Library\PackageCache\[email protected]\Runtime\Scripts\GltfImport.cs:2261 
  at GLTFast.GltfImport+<>c__DisplayClass116_0.<InstantiateSceneInternal>g__IterateNodes|0 (System.UInt32 nodeIndex, System.Nullable`1[T] parentIndex, System.Action`2[T1,T2] callback) [0x00137] in C:\Users\sathv\Avatar SDK Expressions\Library\PackageCache\[email protected]\Runtime\Scripts\GltfImport.cs:2267 
  at GLTFast.GltfImport.InstantiateSceneInternal (GLTFast.Schema.Root gltf, GLTFast.IInstantiator instantiator, System.Int32 sceneId) [0x00219] in C:\Users\sathv\Avatar SDK Expressions\Library\PackageCache\[email protected]\Runtime\Scripts\GltfImport.cs:2426 
  at GLTFast.GltfImport.InstantiateSceneAsync (GLTFast.IInstantiator instantiator, System.Int32 sceneIndex, System.Threading.CancellationToken cancellationToken) [0x00092] in C:\Users\sathv\Avatar SDK Expressions\Library\PackageCache\[email protected]\Runtime\Scripts\GltfImport.cs:599 
  at GLTFast.GltfImport.InstantiateMainSceneAsync (GLTFast.IInstantiator instantiator, System.Threading.CancellationToken cancellationToken) [0x00090] in C:\Users\sathv\Avatar SDK Expressions\Library\PackageCache\[email protected]\Runtime\Scripts\GltfImport.cs:557 
  at GLTFast.GltfImport.InstantiateMainSceneAsync (UnityEngine.Transform parent, System.Threading.CancellationToken cancellationToken) [0x00045] in C:\Users\sathv\Avatar SDK Expressions\Library\PackageCache\[email protected]\Runtime\Scripts\GltfImport.cs:531 
  at LoadAvatar.LoadAvatarFromFile (System.String filePath) [0x0012b] in C:\Users\sathv\Avatar SDK Expressions\Assets\LoadAvatar.cs:76 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in <88e4733ac7bc4ae1b496735e6b83bbd3>:0 
  at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00002] in <6c5d522f2f8d43e0a55c183046b307ae>:0 
  at UnityEngine.UnitySynchronizationContext.Exec () [0x00056] in <6c5d522f2f8d43e0a55c183046b307ae>:0 
  at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00014] in <6c5d522f2f8d43e0a55c183046b307ae>:0 

(Filename: C:/Users/sathv/Avatar SDK Expressions/Library/PackageCache/[email protected]/Runtime/Scripts/Material/BuiltInMaterialGenerator.cs Line: 102)

Desktop (please complete the following information):

  • glTFast version 5.0.4
  • Unity Editor version 2021.3.21f1
  • Platform: Windows
@SathvikKS SathvikKS added the bug Something isn't working label Apr 19, 2023
@SathvikKS
Copy link
Author

Fixed by always including the following shaders in project settings.

glTFPbrMetallicRoughness.shader
glTFPbrSpecularGlossiness.shader
glTFUnlit.shader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant