I am writing a plugin that needs check exists of other class (NGUI etc.) and access its attribute or invoke method.
For example what I need to do is to set UILabel attributes and invoke its method.
UILabel label = gameObject.GetComponent<UILabel>();
// Access attribute
label.text = "hello world";
// Invoke Method
label.MakePixelPerfect();
While another project, I have plugin to check presence of UILabel, if it exists it will change it’s attribute or invoke it’s method, else ignore it. Here’s the code I got stuck:
Type label = System.Type.GetType("AudioListener");
if(label != null){
// How do I access it's attribute?
// How do I invoke function?
}
So, my question would be how to check if the class exists and change its attribute or invoke its method if class exists.
Thank you
GetComponent is a also method of Component. http://msdn.microsoft.com/en-us/library/58918ffs.aspx
– Jessy