//根据等级计算经验值
int expPrgVal = (int)(pd.exp*1.0f / PECommon.GetExpUpValByLv(pd.lv)100);
SetText(txtExpPrg, expPrgVal+ “%”);
int index=expPrgVal / 10;
GridLayoutGroup grid = expPrgTrans.GetComponent();
//Ui针对标准尺寸的缩放比例
//以1334750为例
// ScreenStandardheight(750)
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;
}
}
经验进度条动态的自适应
最新推荐文章于 2023-04-20 15:49:21 发布