Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

call function from another script unity

MyScript2 x = gameObject.AddComponent(typeof(MyScript2)) as MyScript2;
x.MyFunctionFromScript2();

OR EVEN BETTER : 

public class myClassNameToInclude: MonoBehaviour { myfunction1(int x) Debug.Log(x); }
public class myClassName : myClassNameToInclude { myfunction1(2); } // MonoBehaviour included with myClassNameToInclude 
public class myClassName2 : myClassName {...} // MonoBehaviour AND myClassNameToInclude included with myClassName 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #call #function #script #unity
ADD COMMENT
Topic
Name
5+5 =