123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using DG.Tweening;
- public class TestVideoControl : MonoBehaviour
- {
- public List<Vector3> VideoPos = new List<Vector3>();
- public List<TestVideoItem> m_Videos = new List<TestVideoItem>();
- 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<TestVideoItem> videos = new List<TestVideoItem>();
- 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<TestVideoItem> videos = new List<TestVideoItem>();
- 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);
- }
- }
- }
|