Re Edit:
I Solved By Myself, it was just a Variable, thanks to all!
How do the coroutine know if its true? You will need to specify that.
Sorry but your code is still just garbage. I guess that you use C# however from that strange pseudo code it’s hard to tell. If it’s C# it would look more like:
//MainClass.cs
using UnityEngine;
using System.Collections;
public class MainClass : MonoBehaviour
{
public IEnumerator MyCoroutine(int var1, int var2)
{
while(true)
{
for(int i = 0; i < 10; i++)
{
Debug.Log(i);
yield return new WaitForSeconds (0.25f);
}
}
}
}
//OtherClass.cs
using UnityEngine;
using System.Collections;
public class OtherClass : MainClass
{
int var1 = 3;
int var2 = 5;
void OnMouseDown()
{
StartCoroutine(MyCoroutine(var1, var2));
}
}
With those classes in your project you can attach OtherClass to an object with a collider and once you clicked on that object you would get a Debug.Log 4 times a second and it would loop forever until you either stop all coroutines or you destroy the object the coroutine runs on.
So this above works, It’s based on the sparse information you’ve provided. I’ve renamed the method “Coroutine” to “MyCoroutine” as Coroutine is a class name. You should avoid names that are already takesn. If this example doesn’t work for you, you must be doing something wrong.