Cześć , od niedawna zajmuję się programowaniem . Mam dla was dość podstawowe pytanie . Chcę użyć zmiennej "playtime" w drugim skrypcie .
public class Timer : MonoBehaviour
{
public int playtime = 0;
private int seconds = 0;
private int minutes = 0;
private bool timeVisible = true;
void Start()
{
StartCoroutine("PlayTime");
}
public IEnumerator PlayTime()
{
while (true)
{
yield return new WaitForSeconds(1);
playtime += 1;
seconds = (playtime % 60);
minutes = (playtime / 60) % 60;
}
}
void OnGUI()
{
GUI.Label(new Rect(50, 50, 100, 50), minutes.ToString() + " : " + seconds.ToString());
}
}
Próbowałem coś takiego napisać ale coś niepykło ;) :
public class ActiveObjects : MonoBehaviour
{
Timer timer = new Timer();
void Update()
{
if(timer.playtime>10)
{
Debug.Log("Hello", gameObject);
}
}
}
Z góry dziękuję za pomoc .