unity function code example
Example 1: how to reference function in unity
public GameObject myObject;
myObject.GetComponent<MyScript>().MyFunction();
Example 2: functions unity
NumValue = 6;
int myfunc(int num){
}
myfunc(NumValue);
Example 3: how to make a function unity c#
Void Start()
{
MyVoidFunction(false);
debug.log(MyIntFunction(7));
}
Void MyVoidFunction(bool n)
{
if(n)
debug.log("Void Function Ran, n is true")
if(!n)
debug.log("Void Function Ran, n is false")
}
int MyIntFunction(float x)
{
return x * 2;
}