// The source image // string url = "https://clipground.com/images/monkey-baby-clipart-14.jpg"; public void Start() { // Debug.Log("DENTRO DE " + name); param = GameObject.Find("Parametrosaves"); prm = param.GetComponent <Parametrosaves>(); animales = prm.aleatorios(); /*foreach (string i in animales) { * Debug.Log("Animales desde Parametros: " + i); * }*/ int index = 0; bool rep = true; i1 = GameObject.Find("A1").GetComponent <Image>(); i2 = GameObject.Find("A2").GetComponent <Image>(); i3 = GameObject.Find("A3").GetComponent <Image>(); i4 = GameObject.Find("A4").GetComponent <Image>(); if (name == "A1") { anim = GameObject.Find("A1").GetComponent <Image>(); } if (name == "A2") { anim = GameObject.Find("A2").GetComponent <Image>(); } if (name == "A3") { anim = GameObject.Find("A3").GetComponent <Image>(); } if (name == "A4") { anim = GameObject.Find("A4").GetComponent <Image>(); } while (rep == true) { rep = false; System.Random rand = new System.Random(); index = rand.Next(animales.Length); //string rd = rutas[index]; string ruta = animales[index]; //Debug.Log("aleatorio "+name+": " + ruta); string[] dir = ruta.Split('/'); string etiqueta = dir[dir.Length - 1]; string[] et = etiqueta.Split('-'); if (et[0].Contains(".png")) { string[] lab = et[0].Split('.'); tag = lab[0]; name = lab[0]; //Debug.Log("Contiene PNG"); // Debug.Log("etiqueta final asignada: " + lab[0]); } else { tag = et[0]; //Debug.Log("etiqueta asignada 1: " + et[0]); } anim.sprite = Resources.Load <Sprite>(ruta); //"Sprites/oso perezoso_1" //Debug.Log("ANIMAL DESPUES: " + anim.sprite); if (name == "A1") { i1 = GameObject.Find("A1").GetComponent <Image>(); if (i1.sprite == i2.sprite || i1.sprite == i3.sprite || i1.sprite == i4.sprite) { rep = true; //Debug.Log("ANIMAL REPETIDO :" +rep); } } if (name == "A2") { i2 = GameObject.Find("A2").GetComponent <Image>(); if (i2.sprite == i1.sprite || i2.sprite == i3.sprite || i2.sprite == i4.sprite) { rep = true; //Debug.Log("ANIMAL REPETIDO :" +rep); } } if (name == "A3") { i3 = GameObject.Find("A3").GetComponent <Image>(); if (i3.sprite == i1.sprite || i3.sprite == i2.sprite || i3.sprite == i4.sprite) { rep = true; // Debug.Log("ANIMAL REPETIDO :" +rep); } } if (name == "A4") { i4 = GameObject.Find("A4").GetComponent <Image>(); if (i4.sprite == i1.sprite || i4.sprite == i2.sprite || i4.sprite == i3.sprite) { rep = true; // Debug.Log("ANIMAL REPETIDO :" +rep); } } /*Debug.Log("ANIMAL estado :" +rep); * Debug.Log("ANIMAL 1 : " + i1.sprite); * Debug.Log("ANIMAL 2 : " + i2.sprite); * Debug.Log("ANIMAL 3 : " + i3.sprite); * Debug.Log("ANIMAL 4 : " + i4.sprite);*/ } }
public void Start() { int index = 0; bool rep = true; // Debug.Log("DENTRO DE " + name); param = GameObject.Find("Parametrosaves"); prm = param.GetComponent <Parametrosaves>(); sombras = prm.sombras_al(); /*foreach (string i in sombras) { * Debug.Log("Sombras desde Parametros: " + i); * } */ i1 = GameObject.Find("S1").GetComponent <Image>(); i2 = GameObject.Find("S2").GetComponent <Image>(); i3 = GameObject.Find("S3").GetComponent <Image>(); i4 = GameObject.Find("S4").GetComponent <Image>(); if (name == "S1") { sombra = GameObject.Find("S1").GetComponent <Image>(); } if (name == "S2") { sombra = GameObject.Find("S2").GetComponent <Image>(); } if (name == "S3") { sombra = GameObject.Find("S3").GetComponent <Image>(); } if (name == "S4") { sombra = GameObject.Find("S4").GetComponent <Image>(); } while (rep == true) { rep = false; System.Random rand = new System.Random(); index = rand.Next(sombras.Length); //string rd = rutas[index]; string ruta = sombras[index]; // Debug.Log("aleatorio SOMBRA "+name+": " + ruta); string[] dir = ruta.Split('/'); string etiqueta = dir[dir.Length - 1]; string[] et = etiqueta.Split('-'); if (et[0].Contains(".png")) { string[] lab = et[0].Split('.'); tag = lab[0]; name = lab[0] + "_sombra"; //Debug.Log("Contiene PNG"); // Debug.Log("etiqueta final asignada: " + lab[0]); //Debug.Log("nombre final asignada: " + name); } else { tag = et[0]; //Debug.Log("etiqueta asignada 1: " + et[0]); } sombra.sprite = Resources.Load <Sprite>(ruta); animal = ruta.Replace("sombra", "color"); //Debug.Log("animal : "+ animal); //Debug.Log("SOMBRA DESPUES: " + sombra.sprite); if (name == "S1") { i1 = GameObject.Find("S1").GetComponent <Image>(); if (i1.sprite == i2.sprite || i1.sprite == i3.sprite || i1.sprite == i4.sprite) { rep = true; //Debug.Log("SOMBRA REPETIDO :" +rep); } } if (name == "S2") { i2 = GameObject.Find("S2").GetComponent <Image>(); if (i2.sprite == i1.sprite || i2.sprite == i3.sprite || i2.sprite == i4.sprite) { rep = true; // Debug.Log("SOMBRA REPETIDO :" +rep); } } if (name == "S3") { i3 = GameObject.Find("S3").GetComponent <Image>(); if (i3.sprite == i1.sprite || i3.sprite == i2.sprite || i3.sprite == i4.sprite) { rep = true; // Debug.Log("SOMBRA REPETIDO :" +rep); } } if (name == "S4") { i4 = GameObject.Find("S4").GetComponent <Image>(); if (i4.sprite == i1.sprite || i4.sprite == i2.sprite || i4.sprite == i3.sprite) { rep = true; //Debug.Log("SOMBRA REPETIDO :" +rep); } } } }