Unity类网易云效果Banner

如题

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();
             
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值