Answers for "how to call function in unity"

C#
7

how to reference function in unity

public GameObject myObject; //make ref. in inspector window

myObject.GetComponent<MyScript>().MyFunction();
Posted by: Guest on June-27-2020
1

how to make a function unity c#

Void Start()
{
  //call a void function (will return nothing/null)
  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")
  //if you get an error here do
  //return;
}
int MyIntFunction(float x)
{
 return x * 2; 
}
Posted by: Guest on November-18-2020

Code answers related to "how to call function in unity"

C# Answers by Framework

Browse Popular Code Answers by Language