Hi there,
I’m trying to use C#'s Reflection capabilities to access GameObject properties via strings, so I can address arbitrary objects in the game using URLs.
The problem is that I get a null FieldInfo when I try something like this:
GameObject cubeGameObject = GameObject.Find("Cube");
if (cubeGameObject != null)
{
FieldInfo field = cubeGameObject.GetType().GetField(
"transform", BindingFlags.Instance | BindingFlags.Public);
print("field == null? " + (field == null));
}
Is there a particular way I should be using Reflection within Unity?
Thanks,
Ahonek