ユーザ用ツール

サイト用ツール

wiki:unity:tips:045

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

次のリビジョン
前のリビジョン
wiki:unity:tips:045 [2014/11/13 07:25]
127.0.0.1 外部編集
wiki:unity:tips:045 [2015/02/23 12:44] (現在)
ライン 1: ライン 1:
-====== 045 GUIコントロールについて ====== +[[http://stepism.sakura.ne.jp/unity/wiki/|Unityこちら移動しました。]]
- +
-===== 概要 ===== +
-UnityでGUIのコントロールは各スクリプトに記述出来るOnGUIコールバック関数で実装します。 +
- +
-<code csharp>​ +
-using UnityEngine;​ +
-using System.Collections;​ +
- +
-public class HogeScript ​MonoBehaviour +
-+
- void OnGUI() +
-+
- GUI.Box( new Rect(10,​10,​100,​90),​ "GUI Menu" ); +
-  +
- if(GUI.Button(new Rect(20,​40,​80,​20),​ "​Button1"​)) +
-+
- // ボタンを押した時の処理を記述します。 +
-+
-+
-+
-</code> +
-{{:​wiki:​unity:​tips:​ongui_button.png?​200|}} +
-GUI.Box でButton背景の四角形を配置し、その後、GUI.Button でボタンを配置しています。 +
-OnGUI 関数毎フレームよばれる点注意て下さい。 +
- +
-==== ボタンに画像を配置する ==== +
-GUI.Button の第2引数は文字列の代わりにテクスチャを指定することもできす。 +
-<code csharp>​ +
-using UnityEngine;​ +
-using System.Collections;​ +
- +
-public class HogeScript : MonoBehaviour +
-+
- public Texture2D icon; +
-  +
- void OnGUI() +
-+
- GUI.Box( new Rect(10,​10,​100,​90),​ "GUI Menu" ); +
-  +
- if(GUI.Button(new Rect(20,​40,​80,​20),​ icon)) +
-+
- // ボタンを押した時の処理を記述します +
-+
-+
-+
-</​code>​ +
- +
-{{:​wiki:​unity:​tips:​unity_ongui_icon.png?​200|}} +
- +
- +
-==== ボタンにテキストと画像を配置する ==== +
-GUI.Button の第3引数にGUIContent を指定すればボタンとテキストの両方を表示できます。 +
-<code csharp>​ +
-GUI.Button(new Rect(20,​40,​80,​20), ​ new GUIContent( "​テキスト",​ icon ) ); +
-</​code>​ +
-{{:​wiki:​unity:​tips:​unity_ongui_icon_with_text.png?​200|}} +
- +
-[[http://​docs-jp.unity3d.com/​Documentation/​Components/​gui-Controls.html|Unity - Unity Manual]] +
- +
Permalink wiki/unity/tips/045.1415863520.txt.gz · 最終更新: 2015/02/08 12:31 (外部編集)

oeffentlich