//Cuando vamos a tener que usar algo de UI CANVAS, hay que importar UnityEngine.UI // Use this for initialization void Start() { //Inicializamos las referencias motorDeCarreterasGO = GameObject.Find("MotorDeCarretera"); motorDeCarreteraScript = motorDeCarreterasGO.GetComponent <MotorDeCarretera>(); controladorCocheGO = GameObject.Find("ControladorCoche"); //inicializamos valores de tiempo y distancia txtTiempo.text = "2:00"; txtDistancia.text = "0"; //inicializamos tiempo tiempo = 50; //2 minutos //Obtenemos la mayor puntuacion: maxScore = PlayerPrefs.GetInt("highscore"); if (maxScore == null) { PlayerPrefs.SetInt("highscore", 0); } }
// Use this for initialization void Start() { //Buscamos objetos de tipo coche. Al final de la llamada .gameObject, lo devolvemos como un gam eobject y no como un componente. cocheGO = GameObject.FindObjectOfType <Coche>().gameObject; motorDeCarreteraGO = GameObject.Find("MotorDeCarretera"); motorDeCarreteraScript = motorDeCarreteraGO.GetComponent <MotorDeCarretera>(); }
void InicioComponentes() { motorDeCarreterasGO = GameObject.Find("MotorDeCarretera"); motorDeCarreteraScript = motorDeCarreterasGO.GetComponent <MotorDeCarretera>(); contadorNumerosGO = GameObject.Find("ContadorNumeros"); contadorNumerosComp = contadorNumerosGO.GetComponent <SpriteRenderer>(); cocheGO = GameObject.Find("Coche"); controladorCoche = GameObject.Find("ControladorCoche"); InicioCuentaAtras(); }
void Start() { //Buscamos los componentes cronometroGO = FindObjectOfType <Cronometro>().gameObject; cronometroScript = cronometroGO.GetComponent <Cronometro>(); //Lo que hacemos es buscar aquellos objetos que tengan el componente <XX> y lo "casteamos" a tipo GameObject AudioGo = FindObjectOfType <AudioFX>().gameObject; AudioFX = AudioGo.GetComponent <AudioFX>(); //Buscamos el motor de carrtera para cambiar la velocidad del juego motorDeCarreteraGO = GameObject.Find("MotorDeCarretera"); motorDeCarreteraScript = motorDeCarreteraGO.GetComponent <MotorDeCarretera>(); }