public Text txtExpPrg;
public Transform expPrgTrans;
int expPrgVal= (int)(pd.exp*1.0f / PECommon.GetExpUpValByLv(pd.lv))*100;
SetText(txtExpPrg, expPrgVal+ “%”);
int index=expPrgVal / 10;
GridLayoutGroup grid = expPrgTrans.GetComponent();
grid.cellSize = new Vector2(0,0);
//Ui针对标准尺寸的缩放比例
float globalRate = 1.0f * Constant.ScreenStandardheight / Screen.height;
//真实的宽度
float screenwidth = Screen.width * globalRate;
float width = (screenwidth - 194) / 10;
//计算任何模式下的宽高
grid.cellSize = new Vector2(width,12);
for (int i = 0; i < expPrgTrans.childCount; i++)
{
Image img = expPrgTrans.GetChild(i).GetComponent();
if (i < index)
{
img.fillAmount = 1;
}
else if (i == index)
{
img.fillAmount = expPrgVal % 10 * 1.0f / 10;
}
else
{
img.fillAmount = 0;
}
public static int GetExpUpValByLv(int lv)
{
return 100 * lv * lv;
}