i’m making 2D mobile game which is almost done but the only thing that prevents me from publishing it that prefab is not changing the image when i run the build on android device but in the Unity editor everything works like it should. Maybe someone could explain me what’s the cause of this ?
Here is the code:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class playerchange1 : MonoBehaviour {
public Sprite img1;
public GameObject player;
private DimondManager DM;
private collectDimonds CD;
public bool isBought = false;
public GameObject Button;
void SetSprite()
{
player.GetComponent<Image> ().sprite = img1;
}
public void onClick ()
{
if (dimantuManager.dimonds >= 20 && isBought == false) {
SetSprite();
Button.GetComponent<Image> ().sprite = img1;
PlayerPrefs.SetInt ("Dimanti", + dimantuManager.dimonds - 20);
isBought = true;
Application.LoadLevel (Random.Range (0, 0));
}
else if (isBought == true) {
SetSprite();
Application.LoadLevel (Random.Range (0, 0));
}
}
}
The public gameobject player - is the prefab that is not changing the image when player clicks on the button which is also happening to the button prefab