C# I want to acces my double coins from another script attached to a sprite so when i click it increases its value.I can manage to increase the value but i cannot access the double from the on click increase script. I am not sure if and how public globals and static works so i would be thankfull for helping
My first script with the double “coins” i need to access code
using UnityEngine;
using System.Collections;
public class SpriteChanger : MonoBehaviour {
public Sprite sprite1;
public Sprite sprite2;
private SpriteRenderer spriteRenderer;
public double coins = 0.00;
void Start ()
{
spriteRenderer = GetComponent<SpriteRenderer>();
spriteRenderer.sprite = sprite1;
}
void Update ()
{
if (coins > 30) {
ChangeTheDamnSprite ();
coins = 0;
}
else {
spriteRenderer.sprite = sprite1;
}
}
void ChangeTheDamnSprite ()
{
if (spriteRenderer.sprite == sprite1)
spriteRenderer.sprite = sprite2;
}
}
}