/// In script:
enum city { London, New York, Toronto }
/// In Editor script:
function OnInspectorGUI
{
Debug.Log( target.city );
}
It returns null, when I’m expecting it to return the enum.
/// In script:
enum city { London, New York, Toronto }
/// In Editor script:
function OnInspectorGUI
{
Debug.Log( target.city );
}
It returns null, when I’m expecting it to return the enum.
An enum is like a type. You just declared it but your script is not using it.
What you need to do:
/// In script
enum City // use uppercase
{
London,
NewYork, // you cannot use whitespace
Toronto,
}
City myCityVariable = City.Toronto;
/// In editor script
function OnInspectorGUI
{
Debug.Log( target.myCityVariable );
}
But if you want to log this enum as a type, you need to access it as a class-variable:
Debug.Log( YourScript.City.ToString() );
where YourScript
is the name of your script (in fact the name of the class defined in your script).