Question by
IKilledKenny_2 · Aug 24, 2016 at 03:38 PM ·
texturecollidergraphicstexture2dguitexture
Change Texture
Hello Unity3D.I have a problem with Texture2D.My problem is that i want to change the texture2D every 5 seconds but i can't seem to make it happen.For Example.I am making a countdown for my game and i need the texture to change so that the players know when to fight.If anyone knows how i can make it that i can change my texture2D every 5 seconds.Can you please tell me how
Script
var AboutToBeLit : Texture;
var Round1 : Texture;
var LetsGetIt : Texture;
var CharacterName : Texture;
var AboutToBeLitLength : float;
var Round1Length : float;
var x : float;
var XAboutToBeLit : float;
var YAboutToBeLit : float;
var XRound1: float;
var YRound1: float;
var XLetsGetIt : float;
var YLetsGetIt : float;
var AboutToBeLitwidth: float;
var Round1width: float;
var nameWidth: float;
var nameLength: float;
var y : float;
var LetsGetItLength : float;
var LetsGetItWidth : float;
var Xname : float;
var Yname : float;
var GetLit : AudioClip;
var Round : AudioClip;
var GetIt : AudioClip;
var GUIEnabled : boolean = false;
function OnGUI() {
GUI.DrawTexture(Rect((Screen.width/2) - XAboutToBeLit, YAboutToBeLit, AboutToBeLitLength, AboutToBeLitwidth), AboutToBeLit);{
AboutToBeLit.rend.material.mainTexture = AboutToBeLit;
yield WaitForSeconds(1);
GUI.DrawTexture(Rect((Screen.width/2) - XRound1, YRound1, Round1Length, Round1width), Round1);
yield WaitForSeconds(1);
GUI.DrawTexture(Rect((Screen.width/2) - x, y, LetsGetItLength, LetsGetItWidth), LetsGetIt);
}
}
function Start () {
rend = GetComponent.<Renderer>();
GUI.DrawTexture(Rect((Screen.width/2) - XAboutToBeLit, YAboutToBeLit, AboutToBeLitLength, AboutToBeLitwidth), AboutToBeLit);
AboutToBeLit.rend.material.mainTexture = AboutToBeLit;
yield WaitForSeconds(5);
Round1.rend.material.mainTexture = Round1;
GUI.DrawTexture(Rect((Screen.width/2) - XRound1, YRound1, Round1Length, Round1width), Round1);
yield WaitForSeconds(5);
LetsGetIt.rend.material.mainTexture = LetsGetIt;
GUI.DrawTexture(Rect((Screen.width/2) - x, y, LetsGetItLength, LetsGetItWidth), LetsGetIt);
}
Comment