Question by
ch3mbot141 · Jul 31, 2019 at 05:19 AM ·
uiguiui image
Unity Sprite Scaling Problem While Changing Sprites Through Code
For some reason whenever I change sprites through code, they become distorted. Here is a gif showing the problem. ![]()
All the sprites used were the same size, and the image they were rendered never changed in size or scale. The code for changing sprite is very simple:
public IEnumerator Reload(float reloadTime)
{
reloading = true;
//do a quarter of the wait, changing the loading circle each time
mainUIControl.loadingCircleImage.sprite = mainUIControl.loadingSprites[1];
yield return new WaitForSeconds(reloadTime / 4);
mainUIControl.loadingCircleImage.sprite = mainUIControl.loadingSprites[2];
yield return new WaitForSeconds(reloadTime / 4);
mainUIControl.loadingCircleImage.sprite = mainUIControl.loadingSprites[3];
yield return new WaitForSeconds(reloadTime / 4);
mainUIControl.loadingCircleImage.sprite = mainUIControl.loadingSprites[4];
yield return new WaitForSeconds(reloadTime / 4);
mainUIControl.loadingCircleImage.sprite = mainUIControl.loadingSprites[0];
reloading = false;
}
Any ideas on what could be causing this would be very helpful.
sprite-problem.gif
(35.7 kB)
Comment
Your answer
Follow this Question
Related Questions
UI problems 0 Answers
Canvas not filling up the whole screen in Unity 5 0 Answers
Using downloaded image as UI Image's source image? 1 Answer