I have a simple C# class that has a constructor that takes in a Type:
public SomeClass( Type type, int maxObjects ) { ... }
The compiler doesn’t seem to like me using the type Type. Am I missing something (maybe its time to take a nap)?
I have a simple C# class that has a constructor that takes in a Type:
public SomeClass( Type type, int maxObjects ) { ... }
The compiler doesn’t seem to like me using the type Type. Am I missing something (maybe its time to take a nap)?
Have you declared Type in your script?
This works fine for me:
public enum Type
{
EN_Water,
EN_Sand,
EN_Ship,
EN_Mountain, // Obstacles
EN_Village, // Villages
EN_Resources, // Resources
EN_Grass
}
public Type type;
I’m trying to use the built in type Type. The return value from typeof or GetType(). I want to at runtime pass the class (type) into this constructor. Is that supported on iPhone? I can’t imagine it isn’t because GetComponent() takes in a Type.
Ah. Okay. You want to use:
System.Type type;
Wow. That’s all there is to it? I’ve wanted to do that for a while, but couldn’t figure out the syntax. Silly me.
Tempest, your a genius! Thanks.
alternatively add “using System;” at the top, which in non-unity c# programs is default but not in unity as Unity defines an own class object and you get double definition issues if you have system up there too and let something expand object
also it raises the size of webplayer and iphone games considerably