Very simple problem, I have 3 UI images that are white squares in the inspector, at the start of the game I have a script in the gameManager object that takes an array containing 5 prefab images and randomly put 3 of their sprites as the 3 blank UI images. Its work actually, every time I start the game there’s 3 images, but the problem is with the size, it seems that Unity just fit the images in the space the square occupies, so the image appears deformed.
**How its in the scene
**How the image appears (I want them to appear like the gameobject at the right)
The code used:
private void CreateObjective()
{
for(int i = 0; i < 3; i++)
{
//random number
int randomIndex = UnityEngine.Random.Range(0, candiesPrefabs.Length);
//Set what candy needs to be destroyed to win the game(ignore this)
candiesObjective[i] = candiesPrefabs[randomIndex];
//Set the image of the candie to the blank square (CandiesdPrefabs are the game object prefabs, candiesSprites are Ui Image, both arrays have the same order)
imgSlider[i].sprite = candiesSprites[randomIndex].sprite;
//Debug.Log(candiesObjective[i]);
}
}