- Home /
Question by
jalal_moghaddam · Jun 12, 2017 at 08:43 AM ·
methodstypesfinding
How can run method from unknown type of script?
Hi, i have many objects that most of them have a script with 'Events' suffix. example : gameObject : Door, script : DoorEvents then i find this script after triggering player with them:
foreach (GameObject triggerObject in triggerList) {
Scripts = triggerObject.GetComponents<MonoBehaviour> ();
eventName = triggerObject.name + "Events";
foreach (MonoBehaviour script in Scripts)
if (script.GetType ().Name == eventName) {
print ("F");
var sc=Type.GetType(eventName);
}
}
all of this script have a public method with 'DoAction' name. how can run sc.DoAction?
Comment
in fact i want use a method from finded scripts that type of it , is various