Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class PlayerController : MonoBehaviour {
- public bool button_left_pressed = false;
- public bool button_right_pressed = false;
- int button_left_fingerid = -1;
- int button_right_fingerid = -1;
- void Update ()
- {
- foreach (Touch myTouch in Input.touches)
- {
- if (myTouch.phase == TouchPhase.Began)
- {
- if (myTouch.position.x > 605f && myTouch.position.x < 905f && myTouch.position.y > 390f && myTouch.position.y < 690f)
- {
- //Debug.Log("Left");
- button_left_pressed = true;
- button_left_fingerid = myTouch.fingerId;
- }
- if (myTouch.position.x > 1114f && myTouch.position.x < 1414f && myTouch.position.y > 390f && myTouch.position.y < 690f)
- {
- //Debug.Log("Right");
- button_right_pressed = true;
- button_right_fingerid = myTouch.fingerId;
- }
- }
- if (button_left_fingerid != -1)
- {
- if (myTouch.fingerId == button_left_fingerid)
- {
- if (myTouch.phase == TouchPhase.Ended || myTouch.phase == TouchPhase.Canceled)
- {
- button_left_pressed = false;
- }
- }
- }
- if (button_right_fingerid != -1)
- {
- if (myTouch.fingerId == button_right_fingerid)
- {
- if (myTouch.phase == TouchPhase.Ended || myTouch.phase == TouchPhase.Canceled)
- {
- button_right_pressed = false;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement