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

スクリプト言語

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

GUILayout.Button

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 function Button(content: GUIContent, style: GUIStyle, params options: GUILayoutOption[]): bool;
public static bool Button(GUIContent content, GUIStyle style, params GUILayoutOption[] options);
public static def Button(content as GUIContent, style as GUIStyle, *options as GUILayoutOption[]) as bool

Parameters

text ボタン上に表示するテキスト
image ボタン上に表示するTexture
content ボタンのテキスト、画像、ツールチップ
style 使用するスタイル。省略された場合は、現在のGUISkinにある button スタイルを使用します。
options 特別なレイアウト対応をするためのレイアウトオプションリスト。ここに渡された値は style で定義された設定を上書きします。
See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Returns

bool ユーザーがボタンを押したとき true を返します

Description

ボタン。ユーザーがボタンをクリックするとすぐに何かが起こります


ゲームビューのボタン

	// Draws a button with an image and a button with text
	var tex : Texture;
	function OnGUI() {
		if(!tex) {
			Debug.LogError("No texture found, please assign a texture on the inspector");
		}

		if(GUILayout.Button (tex)) {
			Debug.Log("Clicked the image");
		}
		if(GUILayout.Button ("I am a regular Automatic Layout Button")) {
			Debug.Log("Clicked Button");
		}
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public Texture tex;
    void OnGUI() {
        if (!tex)
            Debug.LogError("No texture found, please assign a texture on the inspector");
        
        if (GUILayout.Button(tex))
            Debug.Log("Clicked the image");
        
        if (GUILayout.Button("I am a regular Automatic Layout Button"))
            Debug.Log("Clicked Button");
        
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public tex as Texture

	def OnGUI() as void:
		if not tex:
			Debug.LogError('No texture found, please assign a texture on the inspector')
		if GUILayout.Button(tex):
			Debug.Log('Clicked the image')
		if GUILayout.Button('I am a regular Automatic Layout Button'):
			Debug.Log('Clicked Button')