I have a GameObject, whch I disabled by hand (ticked off at the top of the Inspector).
Now I want to enable it in the code:
GameObject.Find("GunInHand") = enabled;
But it doesn’t works. How to make it correct?
I have a GameObject, whch I disabled by hand (ticked off at the top of the Inspector).
Now I want to enable it in the code:
GameObject.Find("GunInHand") = enabled;
But it doesn’t works. How to make it correct?
Look at the GameObject documentation.
// In C#
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
void Example() {
GameObject go = GameObject.Find("GunInHand");
// Or
GameObject go = GameObject.Find<GunInHand>();
go.SetActive(true);
// Or
GameObject.Find<GunInHand>().SetActive(true);
}
}
// In Javascript it is the same procedure
// Activates the game object.
gameObject.SetActive (true);