Unity2017 中Video Player的简单使用及一些可能触及的坑

新建VideoPanel,挂载VideoPanel脚本;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using FrameWork;

using FrameWork;
using UnityEngine.UI;

using UnityEngine.Video;

public class VideoPanel : UIPanel {

private string UIPanelType = "VideoPanel";

//public Button closeBtn;

public VideoPlayer videoPlayer;

private Button fullScreenBtn;

private RawImage img;
private bool isFullScreen = false;

private RectTransform canvas;

private Image bg;

private GameObject Panel;

private UnityAction CallBack;







private void Start()
{

    Panel = transform.GetChild(0).gameObject;

    Init();

}

void Init()
{
    Panel.transform.Find("Confirm").GetComponent

}

VideoPanel下建bg,挂Image组件–播放视频的底框,再挂上VideoPlayer插件;

VideoPlayer选择URL,url路径在脚本里设置;

bg下面建RawImage(此时搭建Panel也可以自由搭建,脚本没错即可);

新建一个Render Texture,分别拖进VideoPlayer和RawImage;

自己搭的服务器上测试时,IIS服务器上测试可能会播放不了因为缺少.mp4的配置,最好用阿帕奇服务器

添加播放暂停快进等功能可以看VideoPlayer下从元数据

不方便截图便不截图了

你可能感兴趣的:(video,Player,unity3d)