最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Unity實(shí)現(xiàn)跑馬燈效果的示例代碼

 更新時(shí)間:2022年05月06日 16:48:13   作者:龍胖胖的博客  
這篇文章主要為大家詳細(xì)介紹了如何利用Unity實(shí)現(xiàn)跑馬燈效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

一、效果

二、需要?jiǎng)赢?huà)插件DOTween

下載地址

三、腳本

1.每個(gè)格子上的腳本文件

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class MarqueeUIItem : MonoBehaviour
{
    private RawImage m_RawImage;
    private string thisIndex;
    private Coroutine m_coroutine;
    private void Start()
    {
        m_RawImage = GetComponent<RawImage>();

        thisIndex = transform.GetSiblingIndex().ToString();
    }
    public void UpdateImageColorA()
    {
        KillDOTween();
        m_RawImage.color = Color.white;
        m_coroutine= StartCoroutine(ShowUI());
    }
    private IEnumerator ShowUI()
    {
        yield return new WaitForSeconds(0.1F);
        m_RawImage.DOColor(Color.clear, 1.5f).SetId(thisIndex);
    }
    public void KillDOTween()
    {
        if (DOTween.IsTweening(thisIndex))
        {
            if (m_coroutine != null)
            {
                StopCoroutine(m_coroutine);
            }
            DOTween.Kill(thisIndex);      
        }
    }
}

2.管理腳本文件

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MarqueeUIManager : MonoBehaviour
{
    [Header("時(shí)間間隔")]
    public float time_interval=0.05f;
    public RawImage m_firstImage; 
    public RawImage[] m_allImage;
 
    private Coroutine m_LeftCor;
    private Coroutine m_RightCor;
    private void Start()
    {
        m_firstImage.color=Color.clear;
        for (int i = 0; i < m_allImage.Length; i++)
        {
            m_allImage[i].color=Color.clear;
        }               
    }
        private void Update()
    {
        if (Input.GetKeyDown(KeyCode.L))
        {
            LeftRotationUI();
        }
        if (Input.GetKeyDown(KeyCode.R))
        {
            RightRotationUI();
        }
    }
    private void LeftRotationUI()
    {
        if (m_RightCor != null)
        {
            StopCoroutine(m_RightCor);
        }
          if(m_LeftCor!=null)
        {
            StopCoroutine(m_LeftCor);
        }
        m_LeftCor = StartCoroutine(LeftRoatation());
    }
    private void RightRotationUI()
    {
        if (m_LeftCor != null)
        {
            StopCoroutine(m_LeftCor);
        }
           if (m_RightCor != null)
        {
            StopCoroutine(m_RightCor);
        }
        m_RightCor = StartCoroutine(RightRoatation());
    }


    private IEnumerator LeftRoatation()
    {
        KillAllDOTween();
        yield return new WaitForSeconds(0.01f);
        m_firstImage.GetComponent<MarqueeUIItem>().UpdateImageColorA();
        yield return new WaitForSeconds(time_interval);
        for (int i = m_allImage.Length-1; i > -1; i--)
        {
            m_allImage[i].GetComponent<MarqueeUIItem>().UpdateImageColorA();
            yield return new WaitForSeconds(time_interval);
        }
        yield return new WaitForSeconds(time_interval);
        m_firstImage.GetComponent<MarqueeUIItem>().UpdateImageColorA();

    }
    private IEnumerator RightRoatation()
    {
        KillAllDOTween();
        yield return new WaitForSeconds(0.01f);
        m_firstImage.GetComponent<MarqueeUIItem>().UpdateImageColorA();
        yield return new WaitForSeconds(time_interval);
        for (int i = 0; i < m_allImage.Length; i++)
        {
            m_allImage[i].GetComponent<MarqueeUIItem>().UpdateImageColorA();
            yield return new WaitForSeconds(time_interval);
        }
        yield return new WaitForSeconds(time_interval);
        m_firstImage.GetComponent<MarqueeUIItem>().UpdateImageColorA();
    }
    private void KillAllDOTween()
    {
        m_firstImage.GetComponent<MarqueeUIItem>().KillDOTween();
        m_firstImage.color = Color.clear;
        for (int i = 0; i < m_allImage.Length; i++)
        {
            m_allImage[i].GetComponent<MarqueeUIItem>().KillDOTween();
            m_allImage[i].color = Color.clear;
        }
    }
}

設(shè)置

到此這篇關(guān)于Unity實(shí)現(xiàn)跑馬燈效果的示例代碼的文章就介紹到這了,更多相關(guān)Unity跑馬燈效果內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • C#常用GDI+文字操作匯總

    C#常用GDI+文字操作匯總

    這篇文章主要介紹了C#常用GDI+文字操作,包括文字投影、倒影、旋轉(zhuǎn)等特效,對(duì)于提升程序界面的視覺(jué)效果有很大的用處,需要的朋友可以參考下
    2014-08-08
  • C#中Socket通信編程的異步實(shí)現(xiàn)流程分析

    C#中Socket通信編程的異步實(shí)現(xiàn)流程分析

    Socket編程的異步實(shí)現(xiàn)是指按照異步過(guò)程來(lái)實(shí)現(xiàn)Socket編程,即在完成了一次調(diào)用后通過(guò)狀態(tài)、通知和回調(diào)來(lái)告知調(diào)用者,本文給大家介紹C#中Socket通信編程的異步實(shí)現(xiàn)流程分析,感興趣的朋友一起看看吧
    2024-12-12
  • npoi2.0將datatable對(duì)象轉(zhuǎn)換為excel2007示例

    npoi2.0將datatable對(duì)象轉(zhuǎn)換為excel2007示例

    這篇文章主要介紹了npoi2.0將datatable對(duì)象轉(zhuǎn)換為excel2007示例的相關(guān)資料
    2014-04-04
  • c# 實(shí)現(xiàn)發(fā)送郵件的功能

    c# 實(shí)現(xiàn)發(fā)送郵件的功能

    這篇文章主要介紹了c# 如何實(shí)現(xiàn)發(fā)送郵件的功能,文中示例代碼非常詳細(xì),幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-07-07
  • Unity時(shí)間戳的使用方法

    Unity時(shí)間戳的使用方法

    這篇文章主要為大家詳細(xì)介紹了Unity時(shí)間戳的使用方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-05-05
  • Unity使用ScrollRect制作搖桿

    Unity使用ScrollRect制作搖桿

    這篇文章主要為大家詳細(xì)介紹了Unity使用ScrollRect制作搖桿,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-04-04
  • WPF TextBox實(shí)現(xiàn)按字節(jié)長(zhǎng)度限制輸入功能

    WPF TextBox實(shí)現(xiàn)按字節(jié)長(zhǎng)度限制輸入功能

    這篇文章主要為大家詳細(xì)介紹了WPF TextBox實(shí)現(xiàn)按字節(jié)長(zhǎng)度限制輸入功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • 關(guān)于C#理解裝箱與拆箱

    關(guān)于C#理解裝箱與拆箱

    這篇文章主要介紹了關(guān)于C語(yǔ)言理解裝箱與拆箱的相關(guān)資料,需要的朋友可以參考下面文章內(nèi)容
    2021-09-09
  • C#批量刪除Excel重復(fù)項(xiàng)的實(shí)現(xiàn)方法

    C#批量刪除Excel重復(fù)項(xiàng)的實(shí)現(xiàn)方法

    當(dāng)從不同來(lái)源導(dǎo)入Excel數(shù)據(jù)時(shí),可能存在重復(fù)的記錄,為了確保數(shù)據(jù)的準(zhǔn)確性,通常需要?jiǎng)h除這些重復(fù)的行,本文將提供一個(gè)使用C# 快速查找并刪除Excel重復(fù)項(xiàng)的免費(fèi)解決方案,需要的朋友可以參考下
    2024-04-04
  • C#調(diào)用python腳本的方法詳解

    C#調(diào)用python腳本的方法詳解

    這篇文章主要為大家詳細(xì)介紹了C#調(diào)用python腳本的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),感興趣的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-11-11

最新評(píng)論

白银市| 安阳市| 平邑县| 湘潭县| 介休市| 灌南县| 星座| 酒泉市| 丁青县| 泰宁县| 葵青区| 维西| 泰安市| 股票| 郑州市| 芒康县| 舟山市| 旺苍县| 拜泉县| 天长市| 乐至县| 渑池县| 云梦县| 枣阳市| 南宁市| 志丹县| 巴青县| 延吉市| 阿尔山市| 商河县| 黔江区| 邳州市| 长春市| 堆龙德庆县| 伽师县| 昭觉县| 武汉市| 威宁| 犍为县| 灵宝市| 乌鲁木齐县|