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

Warning: Declaration of syntax_plugin_linebreak::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /home/stepism/www/unity/wiki/lib/plugins/linebreak/syntax.php on line 19

Warning: Declaration of syntax_plugin_linebreak::render($mode, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /home/stepism/www/unity/wiki/lib/plugins/linebreak/syntax.php on line 19
101 2Dカメラのピンチインアウト処理 [stepism@Unityメモ]

ユーザ用ツール

サイト用ツール


wiki:unity:tips:101

101 2Dカメラのピンチインアウト処理

// ピンチインアウト用. 
private float pinchLength = 0.0f; 
 
private void PinchInOut() 
{ 
    if (Input.touchCount >= 2) 
    { 
        Touch touch0 = Input.GetTouch(0); 
        Touch touch1 = Input.GetTouch(1); 
 
        // 2点タッチ開始時の距離を記憶. 
        if (touch1.phase == TouchPhase.Began) 
        { 
            pinchLength = Vector2.Distance(touch0.position, touch1.position); 
        } 
        // ピンチインアウト. 
        else if (touch0.phase == TouchPhase.Moved && touch1.phase == TouchPhase.Moved) 
        { 
            float length = Vector2.Distance(touch0.position, touch1.position); 
            m_Camera.orthographicSize += ((pinchLength - length) / 2) * 0.004f; 
 
            float fMinSize = 1.0f; 
            float fMaxSize = 3.0f; 
            m_Camera.orthographicSize = Mathf.Clamp(m_Camera.orthographicSize, fMinSize, fMaxSize); 
 
            pinchLength = length; 
            } 
        } 
    } 
}     
wiki/unity/tips/101.txt · 最終更新: 2015/03/10 12:23 by step