public class ImageTest : Graphic
{
public override Texture mainTexture
{
get
{
if (material.mainTexture != null)
{
return material.mainTexture;
}
return s_WhiteTexture;
}
}
protected override void OnPopulateMesh(VertexHelper vh)
{
Rect rect = this.rectTransform.rect;
vh.Clear();
vh.AddVert(new Vector3(rect.x, rect.y, 0), Color.white, Vector2.zero);
vh.AddVert(new Vector3(rect.x, rect.y+rect.height, 0), Color.white, Vector2.up);
vh.AddVert(new Vector3(rect.x+rect.width , rect.y, 0), Color.white, Vector2.right);
vh.AddVert(new Vector3(rect.x+rect.width , rect.y+rect.height, 0), Color.white, Vector2.one);
vh.AddTriangle(0, 1, 2);
vh.AddTriangle(3, 2, 1);
}
}
Canvas Renderer组件绘制Image
于 2023-01-06 20:53:16 首次发布