Монети без UI
Скрипт Life на Main Camera (Screen.width, Screen.height)
public static int a = 0;
void OnGUI(){
GUI.color = Color.yellow;
GUI.skin.box.fontSize = 34;
GUI.Box(new Rect(0,0,200,50), "Монет: " + a);
}
Скрипт Coin на Монету
private string s = "";
void OnTriggerEnter(Collider other)
{
if (s != gameObject.name)
{
Life.a++;
s = gameObject.name;
Destroy(gameObject);
}
}