cdiego

botonesMobiles.

Jun 11th, 2014
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Saltar : MonoBehaviour {
  5.  
  6.     //TEXTURA DEL BOTON PARA SALTAR
  7.     public GUITexture botonSaltar;
  8.     void Start () {
  9.    
  10.     }
  11.    
  12.     // Update is called once per frame
  13.     void Update () {
  14.         //LLAMAR AL VOID
  15.         programarSalto ();
  16.     }
  17.     void programarSalto()
  18.     {
  19.         //DETECTAR TODOS LOS TOQUES EN LA PANTALLA
  20.         foreach(Touch toque in Input.touches)
  21.         {
  22.             //SOLO TRATAR LOS TOQUES SOBRE ESE BOTON
  23.             //SI NO DARA ERROR EN HitTest
  24.             if(botonSaltar)
  25.             {
  26.                 //SABER SI HIZO TOQUE SOBRE EL BOTON
  27.                 bool hitTest = botonSaltar.HitTest(toque.position);
  28.                 //EVENTOS SOBRE TOQUE CUANDO SE LEVANTA EL DEDO
  29.                 if(toque.phase == TouchPhase.Ended)
  30.                 {
  31.                     if(hitTest)
  32.                     {
  33.                         Debug.Log("Saltar al levantar el dedo");
  34.                     }
  35.                 }
  36.                 //EVENTOS SOBRE TOQUE CUANDO SE PONE EL DEDO
  37.                 if(toque.phase == TouchPhase.Began)
  38.                 {
  39.                     if(hitTest)
  40.                     {
  41.                         Debug.Log("Saltar al poner el dedo");
  42.                     }
  43.                 }
  44.             }
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment