2015-01-04 19 views
7

Wszystko, co szukam, opiera się na starym interfejsie użytkownika.4.6 Nowy interfejs użytkownika Jak zmienić obraz przycisku?

Próbowałem następujące

button.image = Resource.Load<Image>("..."); 
button.GetComponent<Image>() = Resources.Load<Image>("...."); 
button.GetComponent<Button>().image = Resources.Load<Image>("...."); 
button.GetComponent<Image>().sprite = Resources.Load<Sprite>("...."); 

Chcę zmienić obraz przycisku na zdarzenie.

Odpowiedz

4

Testowany i działający.

public Sprite myImage; 
public Button myBtn; 
void Start(){ 

     myImage = Resources.Load<Sprite>("BTNS"); // Make sure not to include the file extension 

     //Make sure it is added in the Inspector. Or reference it using GameObject.Find. 
     myBtn.image.sprite = myImage; // That is right, no need to GetComponent. 

} 
Powiązane problemy