These are some of the best ways to reference game objects in the Unity engine. There are other methods of getting a reference such as the GameObject.Find and GameObject.FindObjectsOfType methods, but those methods are generally slow because they need to traverse the hierarchy to find the object and you don't get to choose which object it finds if you have multiple that match the parameters of the search.
My thoughts on the Singleton pattern:
It's a great design pattern and can be incredibly useful. However a lot of new game developers tend to overuse them and make everything a singleton just for easy references. This is bad practice, only use the singleton pattern when it is actually necessary, for example your UI doesn't need to be a singleton, it can subscribe to events to get updates from your player or other objects.
For more info about events, take a look at these resources:
Unity Learn: https://learn.unity.com/tutorial/even...
Jason Weimann on C# Events or UnityEvents: • Events or UnityEvents?????????
TIMESTAMPS
00:00 Serialized References
01:26 Singleton Pattern
03:09 Dependency Injection
05:07 Events
Nesta página do site você pode assistir ao vídeo on-line Reference Game Objects in Unity duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Boxfriend 24 Dezembro 2021, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 802 vezes e gostou 33 espectadores. Boa visualização!