How to find a GameObject from the project file via scripting ?
This script didn’t work please help me.
Ps: “explosion” is situated in the project file
var explosion: GameObject;
explosion=GameObject.Find("explosion");
How to find a GameObject from the project file via scripting ?
This script didn’t work please help me.
Ps: “explosion” is situated in the project file
var explosion: GameObject;
explosion=GameObject.Find("explosion");
Ok so you can’t do that exactly, what you can do is:
If you put the explosion prefab in a Resources folder (any folder called Resources, anywhere in your project) you can do Resources.Load(“explosion”).
If the explosion prefab is referenced anywhere in the scene you can find it using Resources.FindAllObjectsOfType(typeof(GameObject)) and search for it in the returned array.
You should probably just assign it in the inspector though and you shouldn’t really put code outside a function like Start() or Awake() for initialization.
Thanks a lot Dude !