经验进度条动态的自适应

//根据等级计算经验值
int expPrgVal = (int)(pd.exp*1.0f / PECommon.GetExpUpValByLv(pd.lv)100);
SetText(txtExpPrg, expPrgVal+ “%”);
int index=expPrgVal / 10;
GridLayoutGroup grid = expPrgTrans.GetComponent();
//Ui针对标准尺寸的缩放比例
//以1334
750为例
// 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;
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值