67 lines
1.7 KiB
C#
67 lines
1.7 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
public class FixedAssets : MonoBehaviour
|
||
{
|
||
public List<GameObject> userList;
|
||
|
||
// 是否开始旋转
|
||
public bool isRotate = true;
|
||
//移动的value值
|
||
private float value;
|
||
//每个子物体的位置坐标(长度为子物体总量)
|
||
Vector2[] vc = new Vector2[6];
|
||
//是否开始移动
|
||
bool Move;
|
||
// 用户列表下标
|
||
int index = 6;
|
||
|
||
void Start()
|
||
{
|
||
StartCoroutine(ExecuteEveryTwoSeconds());
|
||
}
|
||
|
||
public IEnumerator ExecuteEveryTwoSeconds()
|
||
{
|
||
while (isRotate) // 无限循环
|
||
{
|
||
// 执行事件
|
||
if (value == 0)
|
||
{
|
||
for (int i = 0; i < transform.childCount; i++)
|
||
{
|
||
vc[i] = transform.GetChild(i).localPosition;
|
||
}
|
||
Move = true;
|
||
StartCoroutine(MoveR());
|
||
}
|
||
// 等待2秒
|
||
yield return new WaitForSeconds(6f);
|
||
}
|
||
}
|
||
|
||
IEnumerator MoveR()
|
||
{
|
||
while (Move)
|
||
{
|
||
yield return new WaitForEndOfFrame();
|
||
for (int i = 0; i < transform.childCount; i++)
|
||
{
|
||
if (value > 1)
|
||
{
|
||
transform.GetChild(0).SetAsLastSibling();
|
||
value = 0;
|
||
Move = false;
|
||
break;
|
||
}
|
||
|
||
value += Time.deltaTime * 0.5f;
|
||
//new Vector2(vc[i].x + 1440, 0):在当前初始位置上向右移动1440
|
||
transform.GetChild(i).localPosition = Vector2.Lerp(vc[i], new Vector2(102.44f, vc[i].y + 46.3f), value);
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|