小白日记和功能实现(unity视频轮播、视频地址读取)

这篇博客记录了新手小白在Unity中实现视频轮播功能和星球界面UI随机移动的过程。使用Unity内置的Video Player组件完成视频加载和轮播,同时提到了AVpro插件作为更简便的视频播放解决方案,并提供了相关资源链接和联系方式。
摘要由CSDN通过智能技术生成

新手小白的成长日志

提示:同为小白的我记录bug、收获勉励自己一直学习的Data;


简单的功能实现

1.视频轮播功能的实现

代码如下(示例):

using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
/// <summary>
/// 导览助手视频功能 
/// </summary>
public class VideoManger : MonoBehaviour
{
   
    [SerializeField] 
    VideoPlayer videoPlan;   //video播放元件
    private Button _Togo = null;
    private Button _GoBack = null;
    private Button _StopAndContine = null;
    private Slider _Slider = null;
    bool _isStop;
    //Image _stopImage;        //视频界面显示暂停按钮
    //Sprite[] textures;       //多个图片
    //GameObject _anima;       //视频多个按钮显示
    //[SerializeField]
    //GameObject _VideoPathBase;
    private string _CruPath;
    private bool IsShow = false;
    private float WaitTime = 5F;
    private float CRUTime;
    private Animation _Animation;
    public static VideoManger _instance = null;
    private int _index;
    /// <summary>
    /// 单例
    /// </summary>
    public void Awake()
    {
   
        if (_instance == null)
            _instance = this;
        else
            return;
    }
    public void OnEnable()
    {
   
        videoPlan.Play();
    }
    /// <summary>
    /// 界面的弹出
    /// </summary>
    private void FixedUpdate()
    {
   
        if (IsShow)
        {
   
            if (videoPlan.isPlaying)
            {
   
                //jindutaio.value = ((float)videoPlan.frame / videoPlan.frameCount);
                CRUTime += Time.deltaTime;  //时间计时器
                if (CRUTime>WaitTime)
                {
   
                    CRUTime = 0;
                    IsShow = false;
                    //_anima.SetActive(false);
                }
            }
        }
    }
    /// <summary>
    /// 按钮显示
    /// </summary>
    public void AnimatorPlay()
    {
   
        CRUTime = 0;
        if (!IsShow)
        {
   
            _Animation.Play();
            //_anima.SetActive(true);
            IsShow = true;
        }
    }
    private void VideoPlan_LoopPninter(VideoPlayer source)
    {
   
        NextMovie();
    }
    private void NextMovie()
    {
   
        CRUTime = 0;
        for (int i = 0; i < SelectSystem.VideoPath.Count; i++)
        {
   
            if (_CruPath.Equals(SelectSystem.VideoPath[i]))
            {
   
                if (i + 1 >= SelectSystem.VideoPath.Count)
                {
   
                    VideoPlay(SelectSystem.VideoPath[0], 0);
                
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值