ロバメモ - 素人のUnity覚書と奮闘記

素人のUnity覚書と奮闘記

Game scripts or other custom code contains OnMouse_ event handlers. Presence of such handlers might impact performance on handheld devices.

エラー内容

Game scripts or other custom code contains OnMouse_ event handlers. Presence of such handlers might impact performance on handheld devices.

Android / IOS を選んでビルドした際に出たエラー。
OnMouse~イベントを使っていると出るらしい。

対処方法

OnMouseDownをやめてInput.GetMouseButtonDownに変更する。

変更前

OnMouseDown(){
     //押した時の処理
}

OnMouseDrag(){
     //ドラッグした時の処理
}

変更後

Vector3 mouseStartPos;

void Update ()
{

    if (Input.GetMouseButtonDown (0)) {
        //押した時の処理
        mouseStartPos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
    } else if (Input.GetMouseButton (0)) {
        if (mouseStartPos != Input.mousePosition) {
            //ドラッグした時の処理
        }
    }
}

以上。