public void Awake() { List <Image> childs = this.GetComponentsInChildren <Image>().ToList(); foreach (var child in childs) { if (child.gameObject != this.gameObject) { MeshImage mi = null; if (child.gameObject.GetComponent <MeshImage>() != null) { mi = child.gameObject.GetComponent <MeshImage>(); mi.mask = this; } MeshRawImage mri = null; if (child.gameObject.GetComponent <MeshRawImage>() != null) { mri = child.gameObject.GetComponent <MeshRawImage>(); mri.mask = this; } MeshButton mb = null; if (child.gameObject.GetComponent <MeshButton>() != null) { mb = child.gameObject.GetComponent <MeshButton>(); mb.mask = this; } } } }
public override void ModifyMesh(VertexHelper vh) { if (this.enabled) { vertices = polygon2d.GetPath(0).ToList(); //vh.Clear(); //if (vertices != null && triangles != null) //{ // float tw = image.rectTransform.rect.width; // float th = image.rectTransform.rect.height; // Vector4 uv = image.overrideSprite != null ? DataUtility.GetOuterUV(image.overrideSprite) : Vector4.zero; // float uvCenterX = (uv.x + uv.z) * 0.5f; // float uvCenterY = (uv.y + uv.w) * 0.5f; // float uvScaleX = (uv.z - uv.x) / tw; // float uvScaleY = (uv.w - uv.y) / th; // for (int i = 0; i < vertices.Count; i++) // { // UIVertex v = new UIVertex(); // v.color = image.color; // //v.position = new Vector2(vertices[i].x * tw, vertices[i].y * tw); // v.position = vertices[i]; // v.uv0 = new Vector2(v.position.x * uvScaleX + uvCenterX, v.position.y * uvScaleY + uvCenterY); // _uiVertices.Add(v); // } // vh.AddUIVertexStream(_uiVertices, triangles); //} List <Image> childs = this.GetComponentsInChildren <Image>().ToList(); foreach (var child in childs) { if (child.gameObject != this.gameObject) { MeshImage mi = null; if (child.gameObject.GetComponent <MeshImage>() != null) { mi = child.gameObject.GetComponent <MeshImage>(); mi.mask = this; } MeshButton mb = null; if (child.gameObject.GetComponent <MeshButton>() != null) { mb = child.gameObject.GetComponent <MeshButton>(); mb.mask = this; } } } } }