Search Unity

Instantiate and fadein whaaaat

Discussion in 'Scripting' started by Conflei, Apr 5, 2014.

  1. Conflei

    Conflei

    Joined:
    Apr 21, 2013
    Posts:
    44
    Hello everyone, i'm actually working in a game and i need to fade in and fadeout screens, i already done those algorithms, see, fadeout a view is something like:

    fadeout(view)
    destroy(view)

    cool but when i go to fadein the next view it has to be something like

    instantiate(view)
    fadein(view)

    and it's makes a jump! Of course, is at first the render is full alpha's instanciated and later the alpha becomes 0 in the fadein algorithm, some idea to avoid that? Thanks!
     
  2. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    i guess that depends on how your fade function works. If at some point you access the material, why not also do it before the instantiate and set its alpha to zero there.
     
  3. djfunkey

    djfunkey

    Joined:
    Jul 16, 2012
    Posts:
    201
    Could you post some code, so we could see if there is anything wrong with it :) . also try looking at the Unity Wiki it has a lot of useful resources like this one
     
  4. Conflei

    Conflei

    Joined:
    Apr 21, 2013
    Posts:
    44
    Solved! Just instantiate the prefab somewhere else and wait until the next frame for moving into the camera, at this point the fadein function is working and the alpha is 0! Thanks!