- Home /
Prefab is not changing image in android
I'm working on 2D game which is almost finished but my only obstacle to publishing it is that prefab is not changing image in android device when i click the button but in the Unity editor everything works like it should. I really don't know what's the issue and i'm hoping for someone to explain it to me why it doesn't work.
Here is the script:
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) {
player.GetComponent<Image> ().sprite = img1;
Application.LoadLevel (Random.Range (0, 0));
}
}
}
the gameobject player is prefab also the same thing happens with button prefab which works fine in Unity editor but not on the device
Your answer
Follow this Question
Related Questions
Calendar not showing when installing from apk 0 Answers
Whats the best way to populate a Dictionary with multiple Prefabs? 0 Answers
How do you scale back GPU load on Android? 1 Answer
How to make an actor spawn at a fixed position 1 Answer
How to detect if the device is android mobile or tablet 2 Answers