言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

GUI.skin

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static var skin: GUISkin;
public static GUISkin skin;
public static skin as GUISkin

Description

グローバルなスキン

他のスキンを設定することで任意のポイントでGUIの見た目を変更することができます。もしnullを設定した場合、skinはデフォルトのUnityスキンに戻ります。

	// Press space to change between added GUI skins.
	
	var s1 : GUISkin[];
	
	private var hSliderValue : float = 0.0;
	private var vSliderValue : float = 0.0;
	private var hSValue : float = 0.0;
	private var vSValue : float = 0.0;
	private var cont : int = 0;
	
	function Update() { 
		if(Input.GetKeyDown(KeyCode.Space))
			cont++;
	}
	function OnGUI() {
		GUI.skin = s1[cont%s1.Length];
		if(s1.Length == 0){
			Debug.LogError("Assign at least 1 skin on the array");
			return;
		}
		GUI.Label (Rect (10, 10, 100, 20), "Hello World!");
		GUI.Box(Rect(10, 50, 50, 50), "A BOX");
		if (GUI.Button(Rect(10,110,70,30), "A button"))
			Debug.Log("Button has been pressed");
		hSliderValue = GUI.HorizontalSlider (Rect (10, 150, 100, 30), hSliderValue, 0.0, 10.0);
		vSliderValue = GUI.VerticalSlider (Rect (10, 170, 100, 30), vSliderValue, 10.0, 0.0);
		hSValue = GUI.HorizontalScrollbar (Rect (10, 210, 100, 30), hSValue, 1.0, 0.0, 10.0);
		vSValue = GUI.VerticalScrollbar (Rect (10, 230, 100, 30), vSValue, 1.0, 10.0, 0.0);
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public GUISkin[] s1;
    private float hSliderValue = 0.0F;
    private float vSliderValue = 0.0F;
    private float hSValue = 0.0F;
    private float vSValue = 0.0F;
    private int cont = 0;
    void Update() {
        if (Input.GetKeyDown(KeyCode.Space))
            cont++;
        
    }
    void OnGUI() {
        GUI.skin = s1[cont % s1.Length];
        if (s1.Length == 0) {
            Debug.LogError("Assign at least 1 skin on the array");
            return;
        }
        GUI.Label(new Rect(10, 10, 100, 20), "Hello World!");
        GUI.Box(new Rect(10, 50, 50, 50), "A BOX");
        if (GUI.Button(new Rect(10, 110, 70, 30), "A button"))
            Debug.Log("Button has been pressed");
        
        hSliderValue = GUI.HorizontalSlider(new Rect(10, 150, 100, 30), hSliderValue, 0.0F, 10.0F);
        vSliderValue = GUI.VerticalSlider(new Rect(10, 170, 100, 30), vSliderValue, 10.0F, 0.0F);
        hSValue = GUI.HorizontalScrollbar(new Rect(10, 210, 100, 30), hSValue, 1.0F, 0.0F, 10.0F);
        vSValue = GUI.VerticalScrollbar(new Rect(10, 230, 100, 30), vSValue, 1.0F, 10.0F, 0.0F);
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public s1 as (GUISkin)

	private hSliderValue as float = 0.0F

	private vSliderValue as float = 0.0F

	private hSValue as float = 0.0F

	private vSValue as float = 0.0F

	private cont as int = 0

	def Update() as void:
		if Input.GetKeyDown(KeyCode.Space):
			cont++

	def OnGUI() as void:
		GUI.skin = s1[(cont % s1.Length)]
		if s1.Length == 0:
			Debug.LogError('Assign at least 1 skin on the array')
			return
		GUI.Label(Rect(10, 10, 100, 20), 'Hello World!')
		GUI.Box(Rect(10, 50, 50, 50), 'A BOX')
		if GUI.Button(Rect(10, 110, 70, 30), 'A button'):
			Debug.Log('Button has been pressed')
		hSliderValue = GUI.HorizontalSlider(Rect(10, 150, 100, 30), hSliderValue, 0.0F, 10.0F)
		vSliderValue = GUI.VerticalSlider(Rect(10, 170, 100, 30), vSliderValue, 10.0F, 0.0F)
		hSValue = GUI.HorizontalScrollbar(Rect(10, 210, 100, 30), hSValue, 1.0F, 0.0F, 10.0F)
		vSValue = GUI.VerticalScrollbar(Rect(10, 230, 100, 30), vSValue, 1.0F, 10.0F, 0.0F)