[SOLVED] Game scripts or other custom code contains OnMouse_ event handlers

Issue

I just need a little help. I keep getting this warning when Im building my game for android.

Game scripts or other custom code contains OnMouse_ event handlers. Presence of such handlers might impact performance on handheld
devices. UnityEditor.HostView:OnGUI()

Do you know how to get rid of this?

The Only Controller I have that has a mouse event.

public class ButtonOnClickController : MonoBehaviour 
{ 
    void OnMouseUp()
    {     
        Application.Quit(); 
    }
}

Solution

Although this is only a warning, I would not ignore it. This could have unintended effects on your game.

It is common to get this on Android builds that you tend to test in the editor. You can simply fix it by adding this:

#if UNITY_EDITOR

   void OnMouseUp() 
   {
   }

#endif

Then add a different code block for Android.

#if UNITY_ANDROID

   // Handle screen touches here.      

#endif

What you are doing here is separating Editor code from Android code. In other words, you wouldn’t really want Mouse Input on an Android device.

Answered By – apxcode

Answer Checked By – Jay B. (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *