Fade out effect when i change images from a list of textures
Hello, I have this script that basically lets me change textures from a list of textures i set when i click the keyboard button J. Is there a way to make the transition from one image to another not abrupt ? make it have a dim or a fade out smooth effect ?
Thank you :)
public var textureList : Texture[] ; public var objectList : GameObject[]; public var textureNumber : int; var coolDown : int = 1; var lastClickTime : float; var inTrigger : boolean = false;
function Update ()
{
if (Input.GetKeyDown(KeyCode.J) && inTrigger == true)
{
if(lastClickTime + coolDown < Time.time)
{
lastClickTime = Time.time;
textureNumber ++;
if (textureNumber > textureList.length - 1)
{
textureNumber = 0;
}
for (var i = 0; i < objectList.length; i++)
{
objectList[i].GetComponent.<Renderer>().material.mainTexture = textureList[textureNumber];
}
}
}
}
I would do this in a custom shader with some amount of lerping. From my recollection, you cannot interpolate textures via scripting, although it might work.
Your answer
Follow this Question
Related Questions
Textures not showing properly? 0 Answers
Baking lights in 3ds Max with Vray - Metallic Reflections & Seperate Lightmap 0 Answers
how to properly set a texture? 0 Answers
Unity 5.6 :Minecraft Wattermelon-like: Metallic Material? 1 Answer
How do I make my RenderTexture / RawImage overlay semi-transparent? 1 Answer