public void ChangeColor(int Color) { FormBuild.Color = Color; GameObject Cache = this.transform.Find("Images").gameObject; for (int x = 0; x < Cache.transform.childCount; x++) { Image iTile = Cache.transform.GetChild(x).GetComponent <Image>(); if (iTile) { iTile.color = MISC.GetColorCode(Color); } } }
public void UpdateImage() { Image FormSprite = this.GetComponent <Image>(); FormSprite.sprite = LevelSprite; //FormSprite.overrideSprite = LevelSprite; FormSprite.color = MISC.GetColorCode(FormBuild.Color); //FormSprite.transform.Find("Texture").GetComponent<Image>().color= MISC.GetColorCode(FormBuild.Color); //FormSprite.GetComponentInChildren<GameObject>()//.Find("Gun").gameObject; FormSprite.rectTransform.sizeDelta = new Vector2(LevelSprite.texture.width, LevelSprite.texture.height); rectTransform.anchoredPosition = new Vector2(xpos, ypos); this.GetComponent <Image>().enabled = false; for (int i = 0; i < texturesAndShadows.Length; i++) { if (this.name + "texture" == texturesAndShadows[i].name) { this.transform.Find("texture").GetComponent <Image>().sprite = texturesAndShadows[i]; } if (this.name + "shadow" == texturesAndShadows[i].name) { this.transform.Find("shadow").GetComponent <Image>().sprite = texturesAndShadows[i]; } } this.transform.Find("texture").transform.Rotate(0.0f, 0.0f, this.GetComponent <FormController>().FormBuild.Rotated * 90f, Space.Self); this.transform.Find("texture").GetComponent <Image>().color = ColorPalette[Random.Range(0, ColorPalette.Count)]; this.transform.Find("texture").GetComponent <Image>().preserveAspect = true; //this.transform.Find("texture").GetComponent<RectTransform>().sizeDelta = this.GetComponent<RectTransform>().sizeDelta; float max = Compare(this.GetComponent <RectTransform>().sizeDelta.x, this.GetComponent <RectTransform>().sizeDelta.y); this.transform.Find("shadow").transform.Rotate(0.0f, 0.0f, this.GetComponent <FormController>().FormBuild.Rotated * 90f, Space.Self); this.transform.Find("shadow").GetComponent <Image>().preserveAspect = true; this.transform.Find("shadow").GetComponent <RectTransform>().sizeDelta = this.GetComponent <RectTransform>().sizeDelta; this.transform.Find("texture").GetComponent <RectTransform>().sizeDelta = new Vector2(max, max); this.transform.Find("shadow").GetComponent <RectTransform>().sizeDelta = new Vector2(max, max); // this.transform.Find("shadow").GetComponent<RectTransform>().transform.position = new Vector2(7,-7); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // README //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Because rotating shifts the position // Just rotate the images in Photoshop etc // and put the rotated versions also in the list // Then load it. // // Check it with rotationstate again (from FormBuild) //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /* || this.name + "texture" == "Tri5texture" * { * this.transform.Find("texture").GetComponent<RectTransform>().sizeDelta = new Vector2(this.GetComponent<RectTransform>().sizeDelta.y, this.GetComponent<RectTransform>().sizeDelta.x); * } * if (this.name == "Tri5" && this.FormBuild.Rotated == 3/* || this.name + "texture" == "Tri5texture"* * /* { * this.transform.Find("texture").GetComponent<RectTransform>().sizeDelta = new Vector2(this.GetComponent<RectTransform>().sizeDelta.y, this.GetComponent<RectTransform>().sizeDelta.x); * } * else*/ }