Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

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

$
0
0
Hello, I wrote this custom script in order to enable my mobile application to use touch controls on a sprite and navigate to a next scene or page. The code I wrote below is uses a isTouched function to call the LoadScene method inside so that when I load my application, I can tap on the screen and it will load the next scene. public class Next_lvl : MonoBehaviour { public static Collider2D cd; void Update () { if (isTouched ()) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } } public bool isTouched(){ bool result = false; if (Input.touchCount == 1) { if (Input.touches [0].phase == TouchPhase.Ended) { Vector3 wp = Camera.main.ScreenToWorldPoint (Input.GetTouch (0).position); Vector2 touchPos = new Vector2 (wp.x, wp.y); if (cd == Physics2D.OverlapPoint (touchPos)) { result = true; } } } return result; } } However, this causes my application to have bugs in it, crashes and does allow me to navigate to any other pages when I test this on the phone. I keep getting this error that **game scripts or other custom code contains OnMouse_ event handlers. The presence of such handlers might impact performance on handheld devices.** I'm not sure why my code generates this error but is there anyway I can write a *touch method that would allow me to tap on a sprite on my mobile device the go to another scene or call a function without causing errors on my phone.* Thank you.

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>