- Home /
How do I use a GUISkin as a button? C#
using UnityEngine;
using System.Collections;
public class StartUI : MonoBehaviour {
public GUISkin customGUISkin;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI() {
if (customGUISkin) {
Application.LoadLevel("one");
}
}
}
My code.
I want it to load level one when you click the customGUISkin but it loads it automatically. Thanks
Comment
Answer by Chronos-L · May 18, 2013 at 04:13 AM
This explains on what a GUISkin is, how to make one, and how to use GUISkin in script.
using UnityEngine;
using System.Collections;
public class StartUI : MonoBehaviour {
public GUISkin customGUISkin;
void OnGUI() {
if( customGUISkin ) {
GUI.skin = customGUISkin;
}
if (GUILayout.Button("Load")) {
Application.LoadLevel("one");
}
}
}
[2]: http://docs.unity3d.com/Documentation/ScriptReference/GUI-skin.html?from=GUISkin
I use guiskin to customise button and code is the same as your code but it doesn't work. any idears? i'm using unity 2019.3
Your answer
![](https://koobas.hobune.stream/wayback/20220613102455im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Basic C# Public Variable Help 3 Answers
Why can't I access the Name field in the Custom Styles section of a GUISkin in the Inspector? 2 Answers
[C#] Buttons through an Array. 1 Answer