- Home /
Using GUI skin with my GUI Button
I have never using a GUI skin yet so I am not fully understanding how to do it. I have the following code set up for my GUI button I would like to make it so that it uses a gui skin insted of normal textures. I would also like to change the first like to accept gui skins in the inspector if possable?
public Texture Location1Button;//Allows you to set the buttons 1 texture in the Inspector.
if (GUI.Button(new Rect(10, 10, 50, 50), Location1Button))
The only reason I am trying to make it have a skin is I cant find away to make a normal texture fill the button.
I have managed to get it setup so that the GUI skin can be applied in the inspector the only problem that remains is making so that my button uses the GUI skin.
Here is how i got it setup to be allowed to be place in in the inspector:
public GUISkin Location1Button;
When I try to tell me button what texture to use: public GUISkin Location1Button; if (GUI.Button(new Rect(10, 10, 50, 50), Location1Button))
it gives the following errors:
Assets/Portal Effect/Script/Portal.cs(60,35): error CS1502: The best overloaded method match for `UnityEngine.GUI.Button(UnityEngine.Rect, string)' has some invalid arguments
Assets/Portal Effect/Script/Portal.cs(60,35): error CS1503: Argument `#2' cannot convert `UnityEngine.GUISkin' expression to type `string'
Answer by lancer · Aug 10, 2013 at 04:07 PM
Try this, it is how I do it:
var MyGUISkin : GUISkin;
function OnGUI () {
GUI.skin = MyGUISkin;
//Put the other GUI stuff here
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Is it possible to link character skill lists to a GUI, and if so, how? 3 Answers
How To Add PlayerPrefs Scores? 1 Answer
Can someone help me understand this code. 1 Answer
Can't draw a box using Basic GUI 1 Answer