I have a scene with the following hierarchy:
This is game scene and the game manager is a singleton with the following variable fields:
// canvas public Canvas PauseCanvas; public Canvas MainMenuCanvas;
Before implementing singleton, I assigned them from the inspector. Now that the game manager is singleton, I need to assign them through script on level load. I can see one solution to this situation:
- Getting all canvas components through
GetComponents<Canvas>()and then iterating and checking their
namefields to assign them accordingly or maybe using LINQ.
What I want to ask is: Is there a name-based search method just like finding game objects with name
GameObject.Find("Name") that is applicable for Components?