using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using DG.Tweening; public class TestVideoControl : MonoBehaviour { public List VideoPos = new List(); public List m_Videos = new List(); private void Start() { for (int i = 0; i < m_Videos.Count; i++) { m_Videos[i].OnClickVideoItem += OnClickVideo; } } private void OnClickVideo(EState state, int id) { switch (state) { case EState.none: break; case EState.right: OnRight(id); break; case EState.left: OnLeft(id); break; default: break; } } private void OnLeft(int id) { int num = id - 3; List videos = new List(); for (int i = 0; i < m_Videos.Count; i++) { int n = num + i; if (n < m_Videos.Count) { videos.Add(m_Videos[n]); } } for (int i = 0; i < num; i++) { videos.Add(m_Videos[i]); } m_Videos.Clear(); m_Videos.AddRange(videos); for (int i = 0; i < videos.Count; i++) { //videos[i].transform.localPosition = VideoPos[i]; videos[i].ID = i + 1; videos[i].Play(VideoPos[i], EState.left); } } private void OnRight(int id) { int num = 3 - id; List videos = new List(); for (int i = m_Videos.Count - num; i < m_Videos.Count; i++) { videos.Add(m_Videos[i]); } for (int i = 0; i < m_Videos.Count - num; i++) { videos.Add(m_Videos[i]); } m_Videos.Clear(); m_Videos.AddRange(videos); for (int i = 0; i < videos.Count; i++) { //videos[i].transform.DOLocalMove(VideoPos[i], 3f); //videos[i].transform.localPosition = VideoPos[i]; videos[i].ID = i + 1; videos[i].Play(VideoPos[i], EState.right); } } }