Nested startCoroutine
if i nested startcoroutine like the folloing code:
IEnumerator ParallaxOffset()
{
// yield return new WaitForSeconds(0.3f);
var offset = Time.time * -OffsetSpeed;
if (isVertical)
{
renderer.material.mainTextureOffset=new Vector2(0,offset);
}
else
{
renderer.material.mainTextureOffset=new Vector2(offset,0);
}
StartCoroutine(this.ParallaxOffset());
Debug.Log("i am start coroutine ");
yield return new WaitForSeconds(0.5f);
}
my unity will be crashed .
if i remove the annotation, this is ok.
IEnumerator ParallaxOffset()
{
yield return new WaitForSeconds(0.3f);
var offset = Time.time * -OffsetSpeed;
if (isVertical)
{
renderer.material.mainTextureOffset=new Vector2(0,offset);
}
else
{
renderer.material.mainTextureOffset=new Vector2(offset,0);
}
StartCoroutine(this.ParallaxOffset());
Debug.Log("i am start coroutine ");
yield return new WaitForSeconds(0.5f);
}

Offset with renderer.material.mainTextureOffset is relative the lcoal UV xy coordinate

浙公网安备 33010602011771号