How to replace the image in unity?

Hi all.
There is a ui image you Want to in the event the picture was replaced. How to do it? With others it was easier(text) and here I do not know.

.img1.GetComponent<img>().
June 27th 19 at 15:01
2 answers
June 27th 19 at 15:03
difficult. why bugaetsa on sprite
image.prntscr.com/image/2d6a8cf6c24648038162c2236f... - noel.Schmeler83 commented on June 27th 19 at 15:06
: in small letters of the properties are specified - tomas_Upt commented on June 27th 19 at 15:09
: ggwp, Unity Technogies! - patrick.Bro commented on June 27th 19 at 15:12
June 27th 19 at 15:05
As you already uksale UI.Image.sprite
but that's not a Sprite, and sprite
Settings and import the texture/image should be for sprite not tekstura defaults as is.

In other words, you will not be able to cram into the UI texture, but can sprait.
Yes, that's just why I can not find sprite ? image.prntscr.com/image/fbcd6d42638140ffa5cf86c459... - noel.Schmeler83 commented on June 27th 19 at 15:08
you would make a screenshot of your hierarchy and inspector and code here can be inserted by editing your question.
And you never know what you've screwed up.
who knows what you have there img1 is? can you a bit of Google and examples of work with scripts from the documentation as here? - tomas_Upt commented on June 27th 19 at 15:11
image.prntscr.com/image/2d6a8cf6c24648038162c2236f...
tried not of resources but just Spruit substitute? everything works?
But simply because the resources to pull Spruit and see what he pulls, and then try to glue it? you to organize and solve problems taught somewhere? - patrick.Bro commented on June 27th 19 at 15:14
: When you just want to write sprite. of the available lists it is not there. - noel.Schmeler83 commented on June 27th 19 at 15:17
Here is my code
using UnityEngine.UI;
Here I tried sprite public and prublic public image and transform to no avail.
public Image img1;

Here, too, tried all sorts of different solutions. also to no avail. Especially on the sprite gives an error. when I want to manually register the sprite. of the available tablita it is not there. Yesterday I sat and updated the unity and VS in the hope that will be corrected. others claim that it works. and I swear on the sprite.

void Update(){
img1.sprite = Resources.Load<sprite>("2");
}</sprite>
- earline.Fad commented on June 27th 19 at 15:20
likely swears on something else earlier and "about sprit" just one of the mistakes...consequence so to speak. - earline.Fad commented on June 27th 19 at 15:23
difficult you said so)
Earlier it was not used sprite.
current setactive and gepcomponent. more than anything - noel.Schmeler83 commented on June 27th 19 at 15:26

Find more questions by tags Unity Game EngineC#