Right now I am calling a coroutine like this.
Update
{
if (Gui.Button(new Rect(15,15,150,150),"test coroutine"){
StartCoroutine(TestC(200f));
}
IEnumerator TestC(float P){
float A = 0;
while (A<P)
Debug.Log(A);
A++;
}
yield return null;
}
My understanding of this is that TestC will take in 200 as a float (called P) and then do the while until A equals P - 1 (since it’s < and not <=), at which point it returns nothing due to it being null. The yield is there since it tells the coroutine to yield to nothing and thus stop doing anything (I assume there are other names to use other then yield but that’s the only one I know). I’m saying this to make sure I understand how coroutines work since I am new with them.
I do have one question though, aren’t coroutines supposed to do code while your program runs so that you program doesn’t jam? EX: A loading screen. If so, why does my program still freeze when running a coroutine? I’m doing the same thing as above, only I’m interating 2’000 entries and it still freezes instead of silently running like I expected it to.
Second question, I will post this in a seperate thread if no one wants to answer it here. I am going through my terraindata point by point to return the splats that are located there. My terrain is 2’000 units by 2’000 units. After reaching 512 sideways, I get error. . .
Texture rectangle is out of bounds (1999 + 1 > 512)
UnityEngine.TerrainData:GetAlphamaps(Int32, Int32, Int32, Int32)
I actually had it working until I deleted my terrain and recreated it (my terrain seemed have unsynced from my scene, was the solution I found). I recreated the terrain and it’s the only terrain in the scene, I also debug.log(terrain.activeterrain.terraindata.name) and it turns out to be the right terrain so I am curious as to what is happening. It looks like it trying to read outside of it’s bounds (set to 512, even though my map is 2’000 and I debug.logged that too). Curious if anyone had this issue and know what setting it’s reading for 512.