通过左右两边按键控制图片轮播。
using dg.tweening;
using system.collections;
using system.collections.generic;
using unityengine;
public class lunbo : monobehaviour
{
public recttransform[] tfs; //需要扩展只需往该数组添加item即可
public void leftbtnclickevent()//左边按键
{
for (int i = 0; i < tfs.length - 1; i++)
{
tfs[i+1].doanchorpos(tfs[i].anchoredposition, 0.2f);//第i+1个元素移动至第i个元素的位置
tfs[i+1].dosizedelta(tfs[i].sizedelta, 0.2f);
}
tfs[0].doanchorpos(tfs[tfs.length-1].anchoredposition, 0.2f);
tfs[0].dosizedelta(tfs[tfs.length - 1].sizedelta, 0.2f);
}
public void rightbtnclickevent()//右边按键
{
for (int i = tfs.length - 1; i >0; i--)
{
tfs[i -1].doanchorpos(tfs[i].anchoredposition, 0.2f);
发表评论