Advertisement
Guest User

Codigo para Unity3d Answer

a guest
May 4th, 2012
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. public class botones2 : MonoBehaviour {
  2.     void Start () {
  3.         StartCoroutine("Animate");
  4.     }
  5.  
  6.     public IEnumerator Animate( GameObject A ){
  7.         activarAnimacion( A );
  8.         Debug.Log("Animate funcion");  
  9.             yield return new WaitForSeconds(A.animation.clip.name.Length);
  10.             desactivarAnimacion( A );
  11.     }
  12.  
  13.     void Update () {
  14.         foreach (Touch touch in Input.touches)
  15.         {
  16.             Ray ray = Camera.main.ScreenPointToRay(touch.position);
  17.        
  18.             if (touch.phase == TouchPhase.Began)
  19.             {
  20.                 RaycastHit hit = new RaycastHit();
  21.                 if (Physics.Raycast(ray, out hit, 1000)){
  22.                         switch(hit.transform.name){
  23.                             case "recetas":{
  24.                         Debug.Log("boton recetas");
  25.                         GameObject.Find("menu2").renderer.enabled = false;
  26.                         Debug.Log("Oculta menu");      
  27.                         GameObject animacion = GameObject.Find("RULETA");
  28.                         Animate(animacion);
  29.                         activarAnimacion(animacion);
  30.                     break;
  31.                     }
  32.                 }
  33.             }
  34.         }
  35.     }
  36. }
  37.  
  38.      void activarAnimacion (GameObject animacion){
  39.         //muestro todos los planos hijos
  40.         Renderer[] textsAnimacion = animacion.GetComponentsInChildren<Renderer>();
  41.         foreach (Renderer textura in textsAnimacion){
  42.                 textura.enabled = true;
  43.         }
  44.         //activo la animacion
  45.         animacion.animation.Play();
  46.     }
  47.    
  48.     void desactivarAnimacion(GameObject animacion){
  49.         //muestro todos los planos hijos
  50.         Renderer[] textsAnimacion = animacion.GetComponentsInChildren<Renderer>();
  51.         foreach (Renderer textura in textsAnimacion){
  52.                 textura.enabled = false;
  53.         }
  54.         //desactivo la animacion
  55.         animacion.animation.Stop();
  56.         Debug.Log("Desactiva anim");
  57.     }
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement