Show a GUI SKIN on click

Hi,

Here is what I’m looking for :

I have a button in my scene and when I click on the button I would like to show a GUI skin.

Here is the code I have :

var fadeTime= 2.0;
private var guiAlpha : float; 
private var fadeIn=false;
var icon: Texture2D;
var posHoriz: int=100;
var posVert: int=100;
var scaleHoriz: int=512;
var scaleVert: int=256;
@script ExecuteInEditMode


function OnGUI () { 
   if (GUILayout.Button("Open Image")) { 
   	if(fadeIn==true){
   	GUIFade(1, 0, fadeTime);
   	fadeIn=false;
   	Debug.Log("yes");
   	return;
   	}
   	else if(fadeIn==false){
   	GUIFade(0, 1, fadeTime);
   	fadeIn=true;
   	return;
   	} 
   }
 
   GUI.color.a = guiAlpha; 
   GUI.Button (Rect (posHoriz,posVert, scaleHoriz, scaleVert), icon); 
}

function GUIFade (start : float, end : float, length : float) { 
   for (i = 0.0; i <= 1.0; i += Time.deltaTime*(1/length)) { 
      guiAlpha = Mathf.Lerp(start, end, i); 
      yield; 
   } 
   guiAlpha = end; 
}

This code works fine to show a 2D Texture.

Now I need to show a GUI, but I’m lost … :frowning:

For information, my GUISKIN’s name is : “MetalGUISkin”

Does someone can help me ?

var newSkin : GUISkin;

function OnGUI ()
{
GUI.skin = newSkin;
GUI.Button (Rect (50, 50, 100, 50), “Hello World”);
}

Well this is the basic’s if you need to set a GUISkin, This will make in on to the GUI.Button

I have put your code but it doesn’t works.

When I click on the button : “Open Image” the skin is not visible.

When I play my project, the button with “Hello world” is visible by default. That’s not what I’m looking for.

Hey did you insert the new GUISkin, If you do not know add me on skype or msn messenger. I will be home in 1 hour - 2 hours. I will help you out with it.

Skype = designer_tc
Msn = cbfc1@hotmail.co.uk

Thankyou
Chris

Thanks Chris

Thankyou, for the thanks, not many people are like that.

Thankyou
Chris

As a Suggestion , make your GuiSkin as a 3D object/button, then use iTween to bring it in. So on your “Open Image” Button you attach a simple iTween 1 line script to it, it then calls your 3d object button and wallah. This may or may not help but i know that the “OnGui” situation can be a pain, and it doesn’t work every time.

Hope this helps.

i hope you can add me also