//File A
public MyEnum { choice01, choice02}
//File B
public class theMixer: MonoBehaviour {
public MyEnum enum01;
}
//File C
public class theSelector: MonoBehaviour {
public MyEnum enum02;
void Update() {
gameObject.GetComponent<theMixer>().enum01 = enum02; //This doesn't work :(
}
}
You need a cast, GetComponent does not as standard return the type you put inside the “<>” which is kinda stupid since generic typing should work fine… oh well, for it to work try this:
Hummm… crazy… I wanted to grab the error message (it was a converting enum and missing cast) but the error doesn’t shows up anymore. And it is working now ! The only thing I changed since then is removing the script from the gameobject and reattached it because a string field was not working in the inspector.
Is it possible that could be some kind of bug ?
Sorry but thank you because without that post I would still have a long useless script
Im not sure about that, other seems to have random problems with fields not showing up, search google and unity may be the best way to go, remember, for it to show up it MUST be a public field (from my knowlegde). if this still wont work try