I have a scene with the following hierarchy:

enter image description here

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 name fields 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?


1 Answer 1


There is no such method but you can use this to find your elements : yourCanvas = GameObject.Find("CanvasName").GetComponent<Canvas>();

  • \$\begingroup\$ The main problem was choosing canvasses from multiple canvas components of a game object according to canvas' name. I used LINQ to solve it tho. Still, thanks for the answer. \$\endgroup\$
    – Varaquilex
    Commented Jan 14, 2015 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .