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
097 uGUIのボタンとGameObjectが重なっている時のタッチ判定について [stepism@UE4メモ]

ユーザ用ツール

サイト用ツール


wiki:unity:tips:097

差分

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

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

両方とも前のリビジョン 前のリビジョン
wiki:unity:tips:097 [2015/02/08 12:37]
step
— (現在)
ライン 1: ライン 1:
-====== 097 uGUIのボタンとGameObjectが重なっている時のタッチ判定について ====== 
- 
-uGUIのボタンにSpriteなど他のGameObject重なっている時、両方のタッチ処理に反応してしまうのは都合が悪いので、 
-uGUIのUIオブジェクトが何かしら重なっている時は、その他のタッチ処理を無効にして通らない様にしてみます。 
-基本的には、EventSystem.current.IsPointerOverGameObject()を使えば良いです。 
- 
-<code csharp> 
-using UnityEngine.EventSystems;​ 
- 
-//​------------------------------------------------------------- 
-// EventSystemのGameObjectにマウスオーバーしているか? 
-//​------------------------------------------------------------- 
-public bool IsPointerOverGameObject() 
-{ 
-    EventSystem current = EventSystem.current;​ 
-    if (current != null) 
-    { 
-        if (current.IsPointerOverGameObject()) 
-        { 
-            return true; 
-        } 
- 
-        foreach (Touch t in Input.touches) 
-        { 
-            if (current.IsPointerOverGameObject(t.fingerId)) 
-            { 
-                return true; 
-            } 
-        } 
-    } 
-    return false; 
-} 
-</​code>​ 
-  
-使い方はシンプルに 
-<code csharp> 
-//​------------------------------------------------------------- 
-//! タッチしたか. 
-//​------------------------------------------------------------- 
-public bool IsTouchPress() 
-{ 
-    if (Input.GetMouseButtonDown(0)) 
-    { 
-        if (!IsPointerOverGameObject()) 
-        { 
-        return true; 
-        } 
-    } 
-    return false; 
-} 
-</​code>​ 
- 
-こんな感じでタッチ処理をラップしてIsTouchPressを使う様にしてあげれば良いです。 
  
wiki/unity/tips/097.1423399040.txt.gz · 最終更新: 2015/02/08 12:37 by step