vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
454 stars 72 forks source link

When compiling with AOT, I encountered a problem #187

Closed CeSun closed 1 year ago

CeSun commented 1 year ago

Does SharpGLTF support aot, or what code/config should I add?

Unhandled Exception: System.MissingMethodException: No parameterless constructor defined for type 'SharpGLTF.Schema2.Asset'.
   at System.ActivatorImplementation.CreateInstance(Type, Boolean) + 0x121
   at SharpGLTF.IO.JsonSerializable._TryCastValue(Utf8JsonReader&, Type, Object&) + 0xa77
   at SharpGLTF.IO.JsonSerializable.DeserializePropertyValue[T](Utf8JsonReader&) + 0x30
   at SharpGLTF.Schema2.ModelRoot.DeserializeProperty(String, Utf8JsonReader&) + 0x398
   at SharpGLTF.IO.JsonSerializable.Deserialize(Utf8JsonReader&) + 0x56
   at SharpGLTF.Schema2.ReadContext._Read(ReadOnlyMemory`1) + 0x2bd
   at SharpGLTF.Schema2.ReadContext._ReadGLB(Stream) + 0xd6
   at SharpGLTF.Schema2.ReadContext.ReadBinarySchema2(Stream) + 0x42
   at Spark.Engine.Assets.StaticMesh.LoadAsset() + 0xc2
   at Spark.Engine.Assets.Asset..ctor(String) + 0x64
   at Spark.Engine.Level.BeginPlay() + 0x112
   at Spark.Engine.World.BeginPlay() + 0x17
   at System.Collections.Generic.List`1.ForEach(Action`1) + 0x3a
   at Desktop!<BaseAddress>+0x29d207
   at Silk.NET.Windowing.Internals.ViewImplementationBase.Initialize() + 0x1a1
   at Silk.NET.Windowing.WindowExtensions.Run(IView) + 0x30
   at Program.<Main>$(String[]) + 0x264
   at Desktop!<BaseAddress>+0x29f3bb
vpenades commented 1 year ago

I've just made some changes that theoretically will fix that issue, but I will not know if they work until you try.

Could you clone the sharpgltf repository, and reference the projects instead of using the nugets?

Ley me know if it worked

CeSun commented 1 year ago

It works, thank you, looking forward to the next release