- Home /
Fade multiple GuiTextures in ONE Javascript
Hi folks,
Is it possible to fade multiple GuiTextures in and out in only one Js?
If yes, can someone show me how? Because I've no idea how. I'm talking about 3 GuiTextures.
Thanks in advance.
Please explain a bit more on what you want to do. You say fade, but, how fast? Which ones at which times? How often?
Answer by Entairex1 · Sep 26, 2013 at 06:29 PM
var _Alpha : float = 1; // Change this value to change the alpha of the GUI
var _Texture : Texture2D;
function OnGUI(){
GUI.color.a = _Alpha;
GUI.DrawTexture(Rect(0,0,100,100), _Texture, ScaleMode.StretchToFill, true);
GUI.DrawTexture(Rect(100,0,100,100), _Texture, ScaleMode.StretchToFill, true);
GUI.DrawTexture(Rect(200,0,200,200), _Texture, ScaleMode.StretchToFill, true);
}
Is this what you're looking for?
Hope this helps =)
It does nothing and I want the second texture fade in after the first texture fades out and the third texture when the second texture fades out.
It's not cool to come here and ask people to create complete scripts for you. How about you try for yourself?
Try using a timer that counts, and if the timer passes an interval, lerp the alpha value
I'm not asking for someone who can create a Js for me.
I ask for some help. I've written a lot of Js, but without any success.
It works only for one GuiTexture.
Please read my question properly for the next time before you say something :D
Here. Drag it onto any component, set the amount of textures you want and go.
var _bGroundTex : Texture2D[];
var _ChangeInterval : float;
var _ChangeSpeed : float;
private var _tmpTime : float = 0;
private var _bGroundIndex0 = 0;
private var _bGroundIndex1 = 1;
function OnGUI(){
GUI.color.a = 1;
GUI.DrawTexture(Rect(0,0,200,50), _bGroundTex[_bGroundIndex0], Scale$$anonymous$$ode.StretchToFill, true);
GUI.color.a = _tmpTime/(_ChangeInterval/_ChangeSpeed);
GUI.DrawTexture(Rect(0,0,200,50), _bGroundTex[_bGroundIndex1], Scale$$anonymous$$ode.StretchToFill, true);
}
function Update(){
_tmpTime += Time.deltaTime;
if(_tmpTime >= _ChangeInterval){
_tmpTime = 0;
_bGroundIndex0++;
if(_bGroundIndex0 >= _bGroundTex.Length)
_bGroundIndex0 = 0;
_bGroundIndex1 = _bGroundIndex0 + 1;
if(_bGroundIndex1 >= _bGroundTex.Length)
_bGroundIndex1 = 0;
}
}
JAG ÄR SÅ JÄVLA SNÄLL