一个随便写的Unity3D的图片墙移动特效,喜欢的拿走吧

一个随便写的Unity3D的图片墙移动特效,喜欢的拿走吧

1,这是一个用于展示图片的动画效果,如下图所示:
在这里插入图片描述
很简单的代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class PicCtrl : MonoBehaviour
{[System.Serializable]public class MyPicinfo{public string name;public string url;public int x;public int y;public Vector3 fromposi;public Vector3 toposi;public GameObject myobject;public void Setinfo(int xx, int yy, Vector3 from, Vector3 to, string mname, string murl){name = mname;url = murl;x = xx;y = yy;fromposi = from;toposi = to;}}public MyPicinfo[,] myPicinfo;public GameObject picPrefab;public Transform CubeSet;public int xcount = 30, ycount = 60;public int speed;void SetPrefavInit(){myPicinfo = new MyPicinfo[xcount, ycount];for (int i = 0; i < xcount; i++){for (int j = 0; j < ycount; j++){myPicinfo[i, j] = new MyPicinfo();Vector3 tt = new Vector3(i * 53, j * 53, 0);Vector3 ff = tt + Vector3.up * 2000;myPicinfo[i, j].myobject = Instantiate(picPrefab, ff, Quaternion.identity, CubeSet);myPicinfo[i, j].Setinfo(i, j, ff, tt, "test", "null");}}}public bool isok = false;private float moveLength, movetemp, savetamp;//移动到目标位置void MoveToPosi(){movetemp = Time.fixedTime - savetamp;if (isok){savetamp = Time.fixedTime;isok = false;}moveLength = Time.fixedDeltaTime * movetemp * speed;for (int i = 0; i < xcount; i++){for (int j = 0; j < ycount; j++){myPicinfo[i, j].myobject.transform.position =Vector3.Lerp(myPicinfo[i, j].fromposi +new Vector3(i * 300, j * 300, 0), myPicinfo[i, j].toposi, moveLength * (ycount - j * 0.2f) * 0.1f + i * 0.01f);//myPicinfo[i, j].myobject.transform.localScale =//    Vector3.Lerp(Vector3.one *2//    , Vector3.one//    , moveLength + i * 0.01f);}}}// Start is called before the first frame updatevoid Start(){SetPrefavInit();}// Update is called once per framevoid Update(){MoveToPosi();}
}

附上资源:源码下载


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部