Answers for "c# unity gameObject.script"

C#
4

gameobject in unity c#

//define "myObject"
//(asign in in inspector)
public GameObject myObject;
//runs when you hit the play button
void Start()
{
  //change the name to "myObjectsNewName"
  myObject.name = "myObjectsNewName";
}
//Note for Unity and C#
Posted by: Guest on September-01-2020
1

c# unity gameObject.script

void Update()
{
  string Thing = gameObject.GetComponent<CustomScriptName>().Variable;

  if (Thing == "String1")
  {
	DoStuff();
  }
  
    if (Thing == "String2")
  {
	DoOtherStuff();
  }
}
Posted by: Guest on December-22-2020

C# Answers by Framework

Browse Popular Code Answers by Language