Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

Handles.Button

マニュアルに切り替える
public static bool Button(Vector3 position, Quaternion direction, float size, float pickSize, Handles.DrawCapFunction capFunc);

パラメーター

position ボタンを描画するワールドスペースの位置
direction ボタンの回転
size ボタンのビジュアルサイズ
pickSize クリックを検出するボタンのサイズ
capFunc ボタンの描画スタイル

戻り値

bool ユーザーがボタンをクリックした時に True 。

説明

3D ボタンを作成します。

これは通常の GUI.Button のように動作します。 3D Position を持ち、ハンドル関数によって描画されます。

注意: 画面サイズに対して固定サイズのハンドルを持ちたい場合、 HandleUtility.GetHandleSize を使用します。


" シーンビューの矩形としての Button ハンドル "

この例を使用するには、このスクリプトを Assets/Editor フォルダーに置きます。

スクリプトはエディターでボタンを表示したいオブジェクトにアタッチします。:

using UnityEngine;
using UnityEditor;

public class ButtonCheckerEditor : MonoBehaviour { // Create a simple button on 3D space and when the user clicks over the handle // it prints a message.

[CustomEditor( typeof( ButtonChecker ) )] class ButtonHandle : Editor { void OnSceneGUI( ) { ButtonChecker b = target as ButtonChecker;

bool pressed = Handles.Button( b.transform.position + new Vector3(0, 2, 0), Quaternion.identity, 3, 6, Handles.RectangleCap ); if( pressed ) { b.checkButton = true; Debug.Log( "The button was pressed!" ); } } } }

このスクリプトをボタンを表示したいオブジェクトに置きます。

using UnityEngine;

public class ButtonChecker : MonoBehaviour { // Usage: Place this script on the object you want to create the button on.

public bool checkButton = false; }