? ?這算是一個(gè)很常見的小功能,比如我們?cè)谕鏅M版游戲的時(shí)候,背景動(dòng)畫會(huì)以一定的頻率運(yùn)動(dòng),其實(shí)現(xiàn)方式也有很多種。
? 比如,使用UGUI的image+animtion動(dòng)畫的方式,自己k楨實(shí)現(xiàn)。
? 還可以使用材質(zhì)球本身的功能來實(shí)現(xiàn),關(guān)鍵函數(shù)如下:
public Material material;
public float _offset;
private int paraId;
void Start()
{
material = GetComponent<Image>().material;
paraId = Shader.PropertyToID("factor");
}
// Update is called once per frame
void Update()
{
material.SetTextureOffset("_MainTex", new Vector2(_offset, 0));
}
?
?配合的材質(zhì)球如下:文章來源:http://www.zghlxwxcb.cn/news/detail-598509.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-598509.html
到了這里,關(guān)于unity背景緩動(dòng)動(dòng)效的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!