I can add Unity components just fine (tried LineRenderer and CapsuleCollider), but any of my custom components I try adding don’t work. I feel like I’m missing a step somewhere.
Here’s the code:
// Inside AssetPostProcessorScript.cs in /Assets/Editor/
public class AssetPostProcessorScript : AssetPostprocessor
{
void OnPostprocessModel(GameObject go)
{
var comp = go.AddComponent<MyComponent>();
comp.someFloat = 0.5f;
}
}
// Inside MyComponent.cs in /Assets/Scripts/
public class MyComponent : MonoBehaviour
{
public float someFloat;
}
The postprocessor has no complaint, but when I drag in my .fbx to the scene, the GameObject has a missing script where MyComponent should be.
I don’t (want to) believe Unity doesn’t allow custom components to be added in AssetPostProcessor, so can anyone help me?
(edit) Worth mentioning that I can add MyComponent to the GameObject with no problem manually in the editor.