public class A : MonoBehaviour {}
public void create(A prefab) // prefab not null.
{
A a = MonoBehavior.Instantiate(prefab.gameObject) as A;
// a is null now!
}
How can I Instantiate from a prefab and instead of putting the returned value into a GameObject I put it into a class type.
I rather not use this if possible:
GameObject g = Instantiate(prefab.gameObject) as GameObject;
A a = g.GetComponent<A>();