I was wondering if it is possible to access public fields from a script component? For example in my game I’ve got a super simple class with the following field and method:
public string keyCode;
public string returnKey()
{
if (string.IsNullOrEmpty (keyCode))
return "";
else
return keyCode;
}
Is it possible using scripting to either access the field keyCode or call the returnKey method? I have this script attached to a GameObject. If possible I’m thinking along the lines of:
string result = GameObject.FindGameObjectsWithTag("LeftBullet")[0].GetComponent<MonoScript>().returnKey();
(Obviously that’s not going to work since it won’t make it past the compiler but you get the idea ).