Hello,
I have a scene where I am fading in a texture.
using renderer. material.color.a
shader is transparent vertex lit.
it will fade in properly, but when I add a awake and don’t destroy on load
the texture will fade in ok as a stand alone scene but once that level gets called, it will fade in but also generate copies of the object like it’s been instantiated and the materials of the duplicated objects are missing,
Here’s the script.
//When I add this awake, it messes it up
/*function Awake()
{
DontDestroyOnLoad(this);
}*/
var durationFade : float = 90.0;
var fade : float = 0.0;
function Start()
{
renderer.material.color.a = fade;
}
function Update()
{
if(ASManager.instance.levelLoaded == true)
{
FadeIn();
}
}
function FadeIn()
{
while(fade < 1.0)
{
fade += Time.deltaTime / durationFade;
renderer.material.color.a = fade;
yield;
}
fade = 1;
}
If the scene is by itself it’s ok even with the awake function
but not when the level gets called and loaded.
I would like to use the object for the next levels that’s why I had the dont destroy.
Maybe I’m doing it wrong.
appreciate any help.
Thanks,
Ray