Search Unity

Texture2D.ReadPixels() call in Coroutine

Discussion in 'Developer Preview Archive' started by mulova, Oct 18, 2012.

  1. mulova

    mulova

    Joined:
    Apr 14, 2011
    Posts:
    62
    In 4.0b07, Coroutine containing Texture2D.ReadPixels() call works well,
    But in 4.0b11, it throws an error.

    ReadPixels was called to read pixels from system frame buffer, while not inside drawing frame.
    UnityEngine.Texture2D:ReadPixels(Rect, Int32, Int32, Boolean)
    $:MoveNext() (at Assets/Standard Assets/Scripts/ScreenWipe.js:94)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)

    Is it deprecated or a bug?
    What should I have to do to avoid this?
     
    Last edited: Oct 18, 2012
  2. mulova

    mulova

    Joined:
    Apr 14, 2011
    Posts:
    62
    Solved by adding "yield new WaitForEndOfFrame();" before ReadPixel
     
    Razek07 likes this.