using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Image2 : 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);
}
}