ousttrue / UniGLTF

glTF 2.0 importer and exporter for Unity 5.6 or later
MIT License
288 stars 63 forks source link

Asynchronus Load throwing error Release v1.22 #43

Closed Zeneroth closed 6 years ago

Zeneroth commented 6 years ago

I download the new release v1.22 to check out the new LoadAsync. Then I tried using the new Async load as follows

context.Parse(path);
context.LoadAsync(onLoaded, onError, false);

And got some error like this

NullReferenceException: Object reference not set to an instance of an object
DepthFirstScheduler.Schedulable`1[T].OnExecute (DepthFirstScheduler.IScheduler scheduler, System.Action`1[T] pred) (at Assets/UniGLTF/DepthFirstScheduler/Schedulable.cs:155)
UniGLTF.ImporterContext.LoadAsync (System.Boolean show) (at Assets/UniGLTF/Core/Scripts/IO/ImporterContext.cs:469)
UniGLTF.ImporterContext.LoadAsync (System.Action`1[T] onLoaded, System.Action`1[T] onError, System.Boolean show) (at Assets/UniGLTF/Core/Scripts/IO/ImporterContext.cs:452)

I have traced this back to this line in Schedulable.cs

Parent.AddChild(schedulable);

and it seems that Parent is null. I'm not quite sure if this is from me using the LoadAsync incorrectly without proper setup or there is something I'm missing? Thanks in advance for the advise.

ousttrue commented 6 years ago

Thank you for your feedback.

This is bug. Schedulable require AddTask() before OnExecute(). I fixed it.

https://github.com/ousttrue/UniGLTF/commit/ef42257ac24e3d71a01c5854be696e1c7487129e#diff-37f6edcd531537fb48bf880cd76e8750R515

Please use v1.23.

Zeneroth commented 6 years ago

Awesome I just tested it out and now working correctly!