I'm currently making an Android game (it's my first one) in which you can collect rotating coins (in fact they are just white cubes.) The code for collecting them looks like this:
public class Collect : MonoBehaviour
{
[HideInInspector]
public Text collectiblesText;
private GameObject collManager;
void Start()
{
collManager = GameObject.Find("CollectibleCounter");
collectiblesText = GameObject.Find("CollectiblesText").GetComponent();
}
void OnTriggerStay(Collider other)
{
if (other.gameObject.tag == "Player")
{
collManager.GetComponent().collectibleCount++;
collectiblesText.GetComponent().text = collManager.GetComponent().collectibleCount.ToString();
PlayerPrefs.SetInt("Coins", collManager.GetComponent().collectibleCount);
gameObject.SetActive(false);
}
}
}
In the Unity Editor everything works fine, but the actual Android game crashes and closes when collecting one of these coins. Please tell me if you see the problem or just know some good Android debugging tools. If you miss some important information, write a comment and I will add it.
Thanks for your help, Luke
Screenshots:
Overall view with coin selected
![alt text][1]
Overall profiler at frame of collecting
![alt text][2]
[1]: /storage/temp/61896-screenshot-6.png
[2]: /storage/temp/61897-screenshot-7.png
↧