如题
using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using Object = UnityEngine.Object;
/// <summary>
/// 类商城横幅UI组件
/// </summary>
public class TitleBanner : MonoBehaviour , IDragHandler , IBeginDragHandler , IEndDragHandler
{
/// <summary>
/// 创建点点
/// </summary>
public bool ShowDot;
/// <summary>
/// 点点prefab
/// </summary>
public GameObject DotPrefab;
/// <summary>
/// 点点父物体
/// </summary>
public Transform DotParent;
/// <summary>
/// banner子对象
/// </summary>
public GameObject ItemPrefab;
/// <summary>
/// banner父物体
/// </summary>
public Transform ItemParent;
/// <summary>
/// 自动轮播
/// </summary>
public bool AutoTurn;
/// <summary>
/// 自动轮播方向
/// </summary>
public bool TurnRight;
/// <summary>
/// 轮播间隔
/// </summary>
public float TurnInterval;
/// <summary>
/// 间隔宽度
/// </summary>
public float Width;
/// <summary>
/// 动画时长
/// </summary>
public float TweenTime;
/// <summary>
/// 刷新动画Scale
/// </summary>
public Vector3 ShakeScale;
/// <summary>
/// 刷新动画总时长
/// </summary>
public float ShakeTime;
/// <summary>
/// 左按钮
/// </summary>
public Button LeftButton;
/// <summary>
/// 右按钮
/// </summary>
public Button RightButton;
/// <summary>
/// 拖拽距离
/// </summary>
public float DragDistance;
/// <summary>
/// 是否接受拖拽事件
/// </summary>
public bool DragEnable = true;
private int displayCount;
private int centerViewIndex;
private ViewNode tempNode;
private GameObject[] dots;
private Node[] nodes;
private Node curNode;
private ViewNode[] viewNodes;
private ViewNode curViewNode;
private Action<GameObject, int, bool> _onUpdateNode;
private Action<GameObject, int, bool> _onUpdateDot;
private List<Tween> tweenList = new List<Tween>();
private float time;
private float dragDis;
private Vector3 dragBeginPos;
private bool hasDragEventInvoke;
private Coroutine cor;
void Start()
{
if (LeftButton != null)
{
LeftButton.onClick.AddListener(() =>
{
MoveLeft();
});
}
if (RightButton != null)
{
RightButton.onClick.AddListener(() =>
{
MoveRight();
});
}
}
void Update()
{
if (AutoTurn)
{
time += Time.deltaTime;
if (time > TurnInterval)
{
if (TurnRight)
{
MoveRight();