Scriptable Import with a Skinned Mesh ?

So I am trying to write a custom scriptable importer for a non-native supported 3d format.

I can load the model + animation fine in the scene view using a SkinnedMeshRenderer for setting up the mesh, bones and weights.

Now I am trying my hand at the scriptable importer class and it seems you cannot use a SkinnedMeshRenderer to setup your mesh from within that class. I do get a null reference from it.

Is it possible to use the SkinnedMeshRenderer from within the scriptable importer class?

The basic steps are:

  • Identify what is null
  • Identify why it is null
  • Fix that.

Wrong question. Fix the null first.

1 Like

Hi Kurt-Dekker,

thanks for helping me out yet again. I had misunderstood the concept of Gameobject components and the scriptable import class. Given that the SkinnedMeshRenderer is a component it needs to be assigned to a gameobject. Turns out, you can (and need to, depending on how you want to import) create a new Gameobject within the import class, assign the SkinnedMeshRenderer as a component and then access the sharedMesh/Material properties.
And then you return the Gameobject to the import class to create the Gameobject asset.

1 Like

Hi Kurt-Dekker,

might I ask you another question about the scriptable importer.

To my understanding the constructed gameobject can be assigned to the asset as follows:

ctx.AddObjectToAsset("_main", obj);
ctx.SetMainObject(obj);

In my debugger I can see that my gameobject contains three components with data before these 2 lines are executed. Namely a Transform, a SkinnedMeshRenderer and an Animation Component with Animation Clips assigned.

After these 2 lines execute the asset in the project pane shows all three components, however all the data is gone. No Mesh assigned to the SkinnedMeshRenderer, no Animation Clips assigned to the Animation Component. I have run out of ideas, could you point me into the right direction once more?