I try this
public T test<T>()
{
switch((int)typeBuilding) // Enumerator
{
case 0:
return Wall; // class
break;
case 1:
return House; //class
break;
}
}
GameObject objeto=(GameObject)Instantiate(object,mousePosition(),Quaternion.identity);
objeto.AddComponent<test()>();
But dont works, How can I do it? thanks