Answer the question
In order to leave comments, you need to log in
How to upload an image using sprite?
Hello.
The picture is in the main. I also changed them to "Sprite 2D and UI" and changed the mod to "Single"
Then I wrote the following in the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ServerImg : MonoBehaviour {
public Image img1;
void Update () {
img1.sprite = Resources.Load<Sprite>("2");
// img1.GetComponent<Image>().overrideSprite = Resources.Load<Sprite>("2");
}
}
Answer the question
In order to leave comments, you need to log in
To get started, pull the sprite replacement from the update, put it in Awake or Start. Then check with a debugger that you really have something loaded from resources. Everything else should work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question