usingUnityEngine;usingSystem.Collections;publicclassCrearCubos:MonoBehaviour{//Me creo una propiedad para contarpublicintcontador;publicboolincrementaLuz;publicTextMeshpantalla;publicboolCubosConstruidos=false;// Use this for initializationvoidStart(){this.contador=0;this.incrementaLuz=true;pantalla=(TextMesh)GameObject.Find("Text_reciver").GetComponent<TextMesh>();pantalla.text="hola";//this.construirCubos();}// Update is called once per framevoidUpdate(){//Creamos una variable, para saber cuando construir los cubos//int tiempo=1000;//Si el contador acaba llegando a ese tiempo, construimos los cubos//if(this.contador == tiempo){//this.construirCubos();//}//Recogemos el GameObject llamado "Luz"//GameObject luz = GameObject.Find ("Luz"); //Miramos a ver si incrementamos o no la intensidad de luz/*if (incrementaLuz) { luz.GetComponent<Light> ().intensity += 0.01f; } else { luz.GetComponent<Light> ().intensity -= 0.01f; }*///Miramos a ver si tenemos que apagar luces o encenderlas./*if(luz.GetComponent<Light>().intensity <0f){ this.incrementaLuz=true; Debug.Log("Cambiamos a true"); } if(luz.GetComponent<Light>().intensity > 8f){ this.incrementaLuz=false; Debug.Log("Cambiamos a false"); }*///Siempre incrementamos el contadorthis.contador++;//pantalla.text = this.contador.ToString();//this.pantalla.text = contador.ToString();this.pantalla.text=Time.realtimeSinceStartup.ToString();if(Time.time>10){if(CubosConstruidos==false){this.construirCubos();CubosConstruidos=true;}}}voidconstruirCubos(){floatposx;floatposy;floatdesplazamiento=0.6f;for(inty=0;y<50;y++){for(intx=0;x<20;x++){GameObjectcube=GameObject.CreatePrimitive(PrimitiveType.Cube);cube.AddComponent<Rigidbody>();cube.AddComponent<Rotar>();posx=x+(float)(desplazamiento*x)-10;posy=y+(float)(desplazamiento*y)+3;cube.transform.position=newVector3(posx,posy,0);}}}}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.