Search Unity

Get GUItexture of all objects

Discussion in 'Immediate Mode GUI (IMGUI)' started by vandreadcola, Apr 13, 2014.

  1. vandreadcola

    vandreadcola

    Joined:
    Mar 17, 2014
    Posts:
    38
    Hi,

    How do you get all the textures of all objects with a tag and set the texture individually :confused:

    I tried this:

    Code (csharp):
    1.  GameObject[] levels = GameObject.FindGameObjectsWithTag("levelButton");
    2.  
    3.                 foreach(GameObject button in levels)
    4.  
    5.                 {
    6.  
    7.                     UITexture[] tex = button.GetComponents<UITexture>();
    8.  
    9.                     foreach(UITexture texture in tex)
    10.  
    11.                     {
    12.  
    13.                         texture.mainTexture = lockedTexture;
    14.                     }
    15.                 }
    16.  
    This code will set the texture of ALL objects to "lockedTexture".
    I just want to set some of them to lockedTexture.



    Nevermind:

    I did this:

    Code (csharp):
    1.  
    2.                 UITexture texture = levels[i].GetComponent<UITexture>();
    3.                 texture.mainTexture = lockedTexture;
    4.  
     
    Last edited: Apr 13, 2014