Advertisement
HectorPulido

FuncionesComunes1

Dec 10th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.67 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Fase1Mono : MonoBehaviour
  5. {
  6.     public MonoBehaviour PRUEBA;
  7.  
  8.  
  9.     void Update ()
  10.     {
  11.         if(Input.GetKeyDown(KeyCode.F1))
  12.         {
  13.             print ("Suscribete :D");
  14.             print ("Se ha ejecutado print(String) que muestra un mensaje en consola");
  15.         }
  16.         if(Input.GetKeyDown(KeyCode.F2))
  17.         {
  18.             PRUEBA.enabled = !PRUEBA.enabled;
  19.             print ("Se ha Cambiado el booleano MonoBehaviour.Enabled que indica si el componente esta activo o no");
  20.         }
  21.  
  22.         if(Input.GetKeyDown(KeyCode.F3))
  23.         {
  24.             Destroy (PRUEBA);
  25.             print ("Se ha ejecutado el comando Destroy(Object) que destruye un MonoBehaviour o un GameObject");
  26.         }
  27.         if(Input.GetKeyDown(KeyCode.F4))
  28.         {
  29.             Instantiate (PRUEBA, Vector3.zero, Quaternion.identity);
  30.             print ("Se ha ejecutado el comando Instantiate(Object, Vector3, Quaternion) que instancia un GameObject en el lugar indicado");
  31.         }
  32.         if(Input.GetKeyDown(KeyCode.F5))
  33.         {
  34.             PRUEBA.gameObject.SetActive (!PRUEBA.gameObject.activeInHierarchy);
  35.             print ("Se ha ejecutado la funcion gameObject.SetActive(bool) que cambia el estado del game object");
  36.         }
  37.         if(Input.GetKeyDown(KeyCode.F6))
  38.         {
  39.             PRUEBA.Invoke ("HolaMundo", 1);
  40.             print ("Se ha ejecutado el comando Invoke(String, float) que llama una funcion dentro de un tiempo determinado");
  41.         }
  42.         if(Input.GetKeyDown(KeyCode.F7))
  43.         {
  44.             print (PRUEBA.tag);
  45.             print ("Se ha Mostrado el atributo gameObject.tag");
  46.         }
  47.         if(Input.GetKeyDown(KeyCode.F8))
  48.         {
  49.             print (PRUEBA.gameObject.layer);
  50.             print ("Se ha Mostrado el atributo gameObject.layer");
  51.         }
  52.         if(Input.GetKeyDown(KeyCode.F9))
  53.         {
  54.             print (GameObject.Find("Prueba").tag);
  55.             print ("Se ha ejecutado la funcion GameObject.Find(String) que devuelve un GameObject");
  56.         }
  57.         if(Input.GetKeyDown(KeyCode.F10))
  58.         {
  59.             print (GameObject.FindGameObjectWithTag("TAG DE PRUEBA").name);
  60.             print ("Se ha ejecutado la funcion GameObject.Find(String) que devuelve un GameObject");
  61.         }
  62.         if(Input.GetKeyDown(KeyCode.F11))
  63.         {
  64.             PRUEBA.SendMessage ("HolaMundo");
  65.             print ("Se ha ejecutado la funcion SendMessage(string) que envia un texto a un MonoBehaviour");
  66.         }
  67.         if(Input.GetKeyDown(KeyCode.F12))
  68.         {
  69.             DontDestroyOnLoad (PRUEBA);
  70.             Application.LoadLevel (Application.loadedLevel);
  71.             print ("Se ha ejecutado el comando DontDestroyOnLoad(Object) que evita que el Objeto sea eliminado al cambiar de escena");
  72.         }
  73.         if (Input.GetKeyDown (KeyCode.Tab)) {
  74.             print (PRUEBA.GetComponent<Collider> ().isTrigger);
  75.             print ("Se esta mostrando el componente Obtenido mediante la funcion MonoBehaviour.GetComponent<ClaseABuscar>()\nY en este caso se esta mostrando si el componente es Trigger");
  76.         }
  77.  
  78.  
  79.  
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement