This two lines are right after each other in the code. D_ReferenceCard is accessible in the following code.(not empty) The class PlayerCard they inherit from indirectly inherits from monobehaviour.
This works, but this:
throws the exception. What could I have done wrong?
asked May 09, 2011 at 09:55 AM
What's the type of D_ReferenceCard? In your case it have to be of type PlayerCard and have to be attached to a GameObject (can be a prefab). Instantiate just clones the object. It returns the same type that you hand in. If you reference a component (what you have done), the whole containing GameObject gets cloned and the cloned reference of your component is returned.
I can't say much more about that since I have no idea what is returned by getPlayerByID. A final hint: Components (like Monobehaviour) can only exist on GameObjects. It's not possible to create a standalone component.