Unity 3D Game Engine – Android – Tap Single – JS
Simple Android application, if you touch the screen it will change the GUI Text content, No Touch -> Touched!
1. Inside Hierarchy create the structure:
– Main Camera
– GUI Text
– GameController (Empty Object) attach the ‘TouchController.js’
TouchController.js
#pragma strict // Hierarchy DRAG E DROP over var GUI Text in Inspector var scoreText : GUIText; function Start () { scoreText.text = "No Touch"; } function Update() { if (Input.touchCount == 1) { // Do something scoreText.text = "Touched!"; } }
2. Hierarchy> GameController> TouchController.js> DRAG AND DROP ‘GUI Text’ Object over var ‘scoreText’