Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class botones2 : MonoBehaviour {
- void Start () {
- StartCoroutine("Animate");
- }
- public IEnumerator Animate( GameObject A ){
- activarAnimacion( A );
- Debug.Log("Animate funcion");
- yield return new WaitForSeconds(A.animation.clip.name.Length);
- desactivarAnimacion( A );
- }
- void Update () {
- foreach (Touch touch in Input.touches)
- {
- Ray ray = Camera.main.ScreenPointToRay(touch.position);
- if (touch.phase == TouchPhase.Began)
- {
- RaycastHit hit = new RaycastHit();
- if (Physics.Raycast(ray, out hit, 1000)){
- switch(hit.transform.name){
- case "recetas":{
- Debug.Log("boton recetas");
- GameObject.Find("menu2").renderer.enabled = false;
- Debug.Log("Oculta menu");
- GameObject animacion = GameObject.Find("RULETA");
- Animate(animacion);
- activarAnimacion(animacion);
- break;
- }
- }
- }
- }
- }
- }
- void activarAnimacion (GameObject animacion){
- //muestro todos los planos hijos
- Renderer[] textsAnimacion = animacion.GetComponentsInChildren<Renderer>();
- foreach (Renderer textura in textsAnimacion){
- textura.enabled = true;
- }
- //activo la animacion
- animacion.animation.Play();
- }
- void desactivarAnimacion(GameObject animacion){
- //muestro todos los planos hijos
- Renderer[] textsAnimacion = animacion.GetComponentsInChildren<Renderer>();
- foreach (Renderer textura in textsAnimacion){
- textura.enabled = false;
- }
- //desactivo la animacion
- animacion.animation.Stop();
- Debug.Log("Desactiva anim");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement