Help, could you help me, I am new to programming and I need to make a moving background in unity c # and when this background is finished a completely new one is created and the previous one is eliminated and this action several times. I have the code in java but I don't know how to do it in Unity.
Codigo:
Codigo:
Código (javascript) [Seleccionar]
var scrollSpeed : float = 0.5;
var GradientOn : boolean = false;
var $$anonymous$$ainImageOn : boolean = true;
var WhiteOn : boolean = false;
var WhiteToBlackon : boolean = false;
var texture : Texture;
var gradient : Texture;
var white : Texture;
var WhiteToBlacktex : Texture;
var offset : float;
var reset : float;
function Update ()
{
offset = reset += Time.deltaTime*scrollSpeed;
renderer.material.SetTextureOffset ("_$$anonymous$$ainTex", Vector2(0,reset));
if(offset >= 1.00 && $$anonymous$$ainImageOn == true)
{
reset=0;
Gradient();
$$anonymous$$ainImageOn = false;
GradientOn = true;
}
else if (offset >= 0.66 && GradientOn == true)
{
reset=0;
White();
GradientOn = false;
WhiteOn = true;
}
else if (offset >= 1.00 && WhiteOn == true)
{
reset=0;
WhiteToBlack();
WhiteOn=false;
WhiteToBlackon = true;
}
else if (offset >= 0.66 && WhiteToBlackon == true)
{
reset=0;
$$anonymous$$ainImage();
WhiteToBlackon = false;
$$anonymous$$ainImageOn = true;
}
}
function $$anonymous$$ainImage()
{
renderer.material.mainTexture = texture;
renderer.material.mainTextureScale = Vector2(1,1);
}
function Gradient()
{
renderer.material.mainTexture = gradient;
renderer.material.mainTextureScale = Vector2(1,0.333);
}
function White()
{
renderer.material.mainTexture = white;
renderer.material.mainTextureScale = Vector2(1,1);
}
function WhiteToBlack()
{
renderer.material.mainTexture = WhiteToBlacktex;
renderer.material.mainTextureScale = Vector2(1,0.333);
}