Hey there… Just can’t figure this one out… Have searched and searched, tried many different things, and am stumped with this one…
All I am trying to do is use a variable, that contains the name of the script, instead
of hardcoding the scriptname, when using GetComponent<>().
// The variable ScriptName contains the script for an object
// TheObject, has the script, 'TheObjectAnimation_Script',
// attached to it, and in that script, contains the variable
// 'TheNoOfAnimationControllers' set to 5
TheObject.TheObjectAnimation_Script.TheNoOfAnimationControllers = 5;
public string ScriptName = "TheObjectAnimation_Script";
public GameObject TheObject;
public int NoOfAnimationControllers;
// So TheObject has the script, "TheObjectAnimation_Script"
// attached to it.
// The problem is, that ScriptName is a string,
// so how would you use this?
NoOfAnimationControllers = TheObject.GetComponent<ScriptName>().TheNoOfAnimationControllers;
The problem here, is that the name of the script, is stored in a variable called ScriptName.
How would one use this with GetComponent<>, or GetComponent(), etc, etc, etc
Thanks for any help ahead of time…