Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Realtime GI emission change with coroutines

Discussion in 'Global Illumination' started by Bolbo13, Mar 20, 2015.

  1. Bolbo13


    Apr 1, 2014

    I've been trying to change GI emission using coroutines. It appears only the last yield is taken into account.
    Here is an example :

    Code (CSharp):
    1. SetEmission(1);
    2. yield return new WaitForSeconds(0.5f);
    3. SetEmission(0);
    4. yield return new WaitForSeconds(0.5f);
    5. SetEmission(3);
    The result is that, the moment the coroutine is called, emission will be immediately set to 3 and all the instructions above the last yield are ignored.
    I threw in some debug.Logs to ensure the coroutine is executed properly, and it is. All the WaitForSeconds are respected.

    I use DynamicGI.SetEmissive to set the emission, and it works fine, but coupled with coroutines, this problem arises.
    Last edited: Mar 21, 2015