This is my code when button is pressed:
public void ChangeAvatar()
{
GameObject newAvatar = EventSystem.current.currentSelectedGameObject;
if (newAvatar != null)
{
Debug.Log(newAvatar.GetComponent<Image>().sprite);
avatarImageDP.GetComponent<Image>().sprite = newAvatar.GetComponent<Image>().sprite;
}
else
{
Debug.Log("newAvatar variable is empty");
}
}
Code works fine and all but whenever i click button, the gameObject that I referenced does not change its sprite. Been trying to solve this for a while now.

