Unity-ScrollRect-循环播放图片(确实没有转载是真的)

来源:互联网 发布:百川考试软件怎么样 编辑:程序博客网 时间:2024/06/05 10:17

都在代码和代码注释里了

发表在这里我还是有私心想要问问题的:

是因为自己在使用时发现,Unity会调用两次通过继承来的PictureScrollView的Start函数两次,

我并不能想明白是怎么回事,还请有了解的指点一下:)先谢谢能给我指点的各位了;)

而且我写的这个代码当用户按住鼠标不松开一直向某个方向拖动的话就不会循环显示图片了,交换一次只会运行,即只交换一张对应图片

我自己所摆放的预制体样式


using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.EventSystems;using UnityEngine.UI;/// /// 继承自UnityEngine.UI的ScrollRect/// public class PictureScrollView : ScrollRect{    Vector3 v_OldContenPos = Vector3.zero;    float size = 0;    float contentDeltaPos = 0;    float moveDirection = 0;    int count = 0;    bool isDrag = true;    bool isStillMove = false;    ///     /// 存储content下的子物体    ///     Button[] buttonElements = null;    public delegate void Func(bool b);    ///     /// 不在拖动和拖动后持续移动的状态下,要进行的操作    ///     public Func DisMove;    void StopAction()    {        DisMove(false);    }    protected override void Start()    {        base.Start();        buttonElements = content.GetComponentsInChildren
原创粉丝点击