- Home /
C# Unity 3D Using functions from other files.
Having trouble figuring out how to use other C# files with my other C# files, can anyone help me getting this to work.
If your other file is attached to a game object, then tag this game object and use:
GameObject.FindGameObjectWithTag("sometag").GetComponent ().NameOfYourFunction();
Answer by Berenger · Jan 27, 2012 at 01:53 AM
If you are trying to access an instance of a script, I'll quote cj.coimbra :
GameObject.FindGameObjectWithTag("sometag").GetComponent < NameOfYourScript > ().NameOfYourFunction();
If you want to use a class from another file *.cs, well, nothing special here, just call the class as if it was one file. Not sure if it was your question, maybe you're looking for something static ?
Your answer
Follow this Question
Related Questions
Namespace order c#. 2 Answers
A node in a childnode? 1 Answer
I use c# and have a problem about namespace System.Drawing! 3 Answers
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer