Set custom object on created entity?
Hi umod,

Fair warning: super noob question, but here goes.

If I instantiate a game object using a prefab path like so:

var gameObject = Instantiate.GameObject(GameManager.server.FindPrefab("assets/prefabs/npc/scientist/scientist.prefab"), position, new Quaternion());​

The components that are attached to this game object seem predetermined. For example, this instantiates a Scientist object.

The issue I'm facing is: I want to be able to subclass the Scientist class, set a few read-only attributes (e.g. Family), and spawn it just like I do above.

Is there anyway to set which class the prefab instantiates? If not, where is that logic set? I've been going over the dlls with ilspy, and not finding where this might take place. Any advice would be awesome.

Thanks!

Probably in editor or kind of script. Or even inside prefab somewhere

If you want to work with fields you can simply cast it to specific type
var scientist = gameObject.GetComponent<Scientist>();​