Warning: Declaration of action_plugin_linebreak::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/linebreak/action.php on line 41

Warning: Declaration of action_plugin_markdownextra::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/markdownextra/action.php on line 16

Warning: Declaration of action_plugin_syntaxhighlighter3_action::register(Doku_Event_Handler &$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /home/stepism/www/ue4/wiki/lib/plugins/syntaxhighlighter3/action/action.php on line 28
045 GUIコントロールについて [stepism@UE4メモ]

ユーザ用ツール

サイト用ツール


wiki:unity:tips:045

差分

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

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

次のリビジョン
前のリビジョン
wiki:unity:tips:045 [2014/11/13 07:25]
127.0.0.1 外部編集
— (現在)
ライン 1: ライン 1:
-====== 045 GUIコントロールについて ====== 
- 
-===== 概要 ===== 
-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]] 
- 
  
wiki/unity/tips/045.1415863520.txt.gz · 最終更新: 2015/02/08 12:31 (外部編集)