public void ChangeTag(string newTag, CarMove.Direction dir) { switch (dir) { case CarMove.Direction.NW: //Busco a mi hijo SE transform.FindChild("SE").gameObject.tag = newTag; break; case CarMove.Direction.SE: //Busco a mi hijo NW transform.FindChild("NW").gameObject.tag = newTag; break; case CarMove.Direction.NE: //Busco a mi hijo SW transform.FindChild("SW").gameObject.tag = newTag; break; case CarMove.Direction.SW: //Busco a mi hijo NE transform.FindChild("NE").gameObject.tag = newTag; break; } }
/// <summary> /// Change the map tag depending on the path selected by the user /// Cambia el tag del mapa en dependencia del camino seleccionado por el usuario /// /// </summary> /// <param String name="newTag"></param> /// <param CarMove name="dir"></param> public void ChangeTag(string newTag, CarMove.Direction dir) { //Para cambiar el tag, debemos guardar el que tenía anteriormente y devolvérselo en algún momento. switch (dir) { case CarMove.Direction.NW: //Busco a mi hijo SE this.lastRoad = transform.Find("SE").gameObject; this.lastTag = this.lastRoad.tag; transform.Find("SE").gameObject.tag = newTag; break; case CarMove.Direction.SE: //Busco a mi hijo NW this.lastRoad = transform.Find("NW").gameObject; this.lastTag = this.lastRoad.tag; transform.Find("NW").gameObject.tag = newTag; break; case CarMove.Direction.NE: //Busco a mi hijo SW this.lastRoad = transform.Find("SW").gameObject; this.lastTag = this.lastRoad.tag; transform.Find("SW").gameObject.tag = newTag; break; case CarMove.Direction.SW: //Busco a mi hijo NE this.lastRoad = transform.Find("NE").gameObject; this.lastTag = this.lastRoad.tag; transform.Find("NE").gameObject.tag = newTag; break; } Debug.Log(lastTag); }