I’m in a situation where I’m picking a class to assign to my GameObject from a list at random. I’m 99% of the way done, I’ve just hit one little snag:
Type enemyClass = randomEnemyClass(); AbstractEnemy enemy = enemyInstance.AddComponent<enemyClass>();
Yields the error:
Assets/Scripts/Quadrant.cs(156,59): error CS0246: The type or namespace name `enemyClass' could not be found. Are you missing a using directive or an assembly reference?
This likely comes down to my lack of understanding of the C# compiler. Can anyone offer the correct way to add my component?