- Home /
Question by
FirePhenix · Dec 07, 2011 at 09:58 AM ·
inputiphonetouchdebug
Debug iPhone game without smartphone.
When I debug a game on the PC, unity does not recognize the touch with the mouse. I used the following script:
function Update () {
if (Input.touchCount > 0) {
print(Input.touchCount);
}
}
How to make my touch to be recognized unity during the debugging on PC(without debug with smartphone)? P.S. Sorry for my English:)
Comment
Best Answer
Answer by kayy · Dec 07, 2011 at 04:15 PM
One possible solution to this is to create an interface
public interface InputController {
void ProcessInput ();
}
Then build two implementing classes TouchInputController
and MouseInputController
that handle their input device. If they share a lot of code you might consider using an abstract base class or some utility class. Within your app manager class' initialisation code put: private InputController inputController;
void Awake () {
if (Application.platform == RuntimePlatform.IPhonePlayer) {
inputController = new TouchInputController ();
} else {
inputController = new MouseInputController ();
}
}
void Update () {
inputController.ProcessInput ();
}
You are welcome. If it helped you don't forget to upvote for me to get rich ;-)