- Home /
Answered and accepted
SOLVED Accessing an other C# script and run a function
Dear All,
I am starting to freak out. There are 2 scripts attached to the same GameObject, one refering to the other with:
ScreenShotMultiple w = (ScreenShotMultiple)(GameObject.Find("7-1 OK").GetComponent("ScreenShotMultiple"));
w.enabled=true;
w.Screenshots();
In the refered ScreenShotMultiple script there is the function like this:
public void Screenshots()
{
StartCoroutine(TakeScreenshot());
}
I can easily access the script, set in enabled, get values from it, but running this function does not work, I keep getting the following error:
error CS1061: Type ScreenShotMultiple' does not contain a definition for
Screenshots' and no extension method Screenshots' of type
ScreenShotMultiple' could be found (are you missing a using directive or an assembly reference?)
What am I doing wrong? As always any help or hint is thanked in advance.
I don't see anything wrong there. Does it make any difference if you change it to this?
ScreenShot$$anonymous$$ultiple w = GetComponent<ScreenShot$$anonymous$$ultiple>();
Answer by srancsik · Nov 11, 2013 at 01:42 PM
Dear Hamstar,
I tried your version too, it is working. Oh my god, I made such a lame error, for some reason I mistyped Screenshots. Sorry for the inconvenience.