Question by
beerandcheese · Mar 18, 2019 at 09:11 AM ·
methodexecution order
Why should GameObject.findObjectWithTag be in Awake or Start?
Hi, I'm new in Unity. Couldn't find any good answers so writing it. I read that Awake() initializes objects from here -https://docs.unity3d.com/540/Documentation/ScriptReference/MonoBehaviour.Awake.html. What I want to know is why is GameObject.findObjectWithTag not working if is outside of the method? Because of Execution Order of Event Functions? If that so, there is nothing happened outside of the methods? Thanks for reading it.
Comment
why is GameObject.findObjectWithTag not working if is outside of the method
GameObject.FindObjectWithTag
works perfectly fine outside of Awake
. But as indicated by the documentation, this method only finds active gameObjects with the given tag.
Thanks @Hellium for the answer. Appreciate it