Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question how to transfrom object type after using GetComponentsInChildren

Discussion in 'Scripting' started by ItsMe1423, Apr 2, 2024.

  1. ItsMe1423

    ItsMe1423

    Joined:
    Sep 23, 2020
    Posts:
    78
    How do I turn this
    Code (CSharp):
    1.         PlayerManager[] menus = canvas.GetComponentsInChildren<PlayerManager>();
    2.  
    into GameObject type?
    help would be much appreciated
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,591
    Iterate the PlayerManager array and use the gameObject property that's on every component type.
     
  3. ItsMe1423

    ItsMe1423

    Joined:
    Sep 23, 2020
    Posts:
    78
    It worked tnx