public int ortakDegisken;
IEnumerator coroutine1() {
while (true) {
ortakDegisken += 1;
Debug.Log(ortakDegisken);
yield return new WaitForSeconds(1);
}
}
IEnumerator coroutine2()
{
while (true)
{
ortakDegisken += 10;
Debug.Log(ortakDegisken);
yield return new WaitForSeconds(2);
}
}
private void Start()
{
StartCoroutine(coroutine1());
StartCoroutine(coroutine2());
}
Akla ilk çözüm yöntem değişkeni sınıf seviyesinde tanımlamak.
C#:public int ortakDegisken; IEnumerator coroutine1() { while (true) { ortakDegisken += 1; Debug.Log(ortakDegisken); yield return new WaitForSeconds(1); } } IEnumerator coroutine2() { while (true) { ortakDegisken += 10; Debug.Log(ortakDegisken); yield return new WaitForSeconds(2); } } private void Start() { StartCoroutine(coroutine1()); StartCoroutine(coroutine2()); }
Bu sitenin çalışmasını sağlamak için gerekli çerezleri ve deneyiminizi iyileştirmek için isteğe bağlı çerezleri kullanıyoruz.