Skip to content

Commit

Permalink
fix nullrefs in ExportPlan with missing SkinnedMeshRenderer mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Nov 30, 2022
1 parent bdcab34 commit 957cc5b
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public AnimationData(Transform tr, double time, bool zeroScale = false, bool rec

exportPlans.Add(new ExportPlan("weights", typeof(float[]), x => x.GetComponent<SkinnedMeshRenderer>(), (tr0, x) =>
{
if (x is SkinnedMeshRenderer skinnedMesh && skinnedMesh)
if (x is SkinnedMeshRenderer skinnedMesh && skinnedMesh.sharedMesh)
{
var mesh = skinnedMesh.sharedMesh;
var blendShapeCount = mesh.blendShapeCount;
Expand Down Expand Up @@ -153,8 +153,9 @@ public AnimationData(Transform tr, double time, bool zeroScale = false, bool rec

foreach (var plan in exportPlans)
{
if (plan.GetTarget(tr))
if (plan.GetTarget(tr)) {
tracks.Add(new Track(tr, plan, time));
}
}
#endif
}
Expand Down Expand Up @@ -186,6 +187,8 @@ public Track(Transform tr, ExportPlan plan, double time)
public void SampleIfChanged(double time)
{
var value = plan.Sample(tr);
if (value == null || (value is Object o && !o))
return;
if (!value.Equals(lastSample))
{
samples[time] = value;
Expand Down

0 comments on commit 957cc5b

Please sign in to comment.