sdestudio
sdestudio

Reputation: 25

Unity 3D onClick or Input.touchCount not working

We have a little problem. When we use

 if (Input.touchCount > 0)
    Debug.Log(Input.touchCount.ToString());

we always get a zero. What is wrong?

Or when we use

public class ExampleClass : MonoBehaviour {
    void OnMouseDown() {
        Application.LoadLevel("SomeLevel");
    }
}

it is not working too. We want to skip to another scene only on click anywhere.

Upvotes: 1

Views: 3877

Answers (3)

shieldgenerator7
shieldgenerator7

Reputation: 1756

This happened to me: my game stopped recognizing touch input, and it seemed to be right after installing the Input System. I closed Unity, deleted the Library folder in my project, then restarted Unity. Touch input works again now.

Upvotes: 0

nur farazi
nur farazi

Reputation: 1207

create a button and make it invisible and add this function

using UnityEngine;
using System.Collections;

public class btnAction : MonoBehaviour {

  public void PlaybtnClicked(string SceneNumber){
      Application.LoadLevel (SceneNumber);
  }

}

don't forget to make the button big enough to cover the whole screen . it will solve your problem

Upvotes: 4

Barış Çırıka
Barış Çırıka

Reputation: 1570

OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider.

if i understand your question properly you need to use Input.touchCount in Update function. Like:

void Update() {
   if (Input.touchCount > 0)
       Debug.Log(Input.touchCount.ToString());     
}

Upvotes: -1

Related Questions