先创建两个滚动条,分别控制进度条和音量
创建一个按钮,控制播放与暂停
给视频播放器挂这个代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
public class Videos : MonoBehaviour
{
public GameObject videoplayer;//视频播放器
public GameObject scroolbar;//进度条
public GameObject volumebar;//音量条
public bool Changetime;
public GameObject Stopbtn;
public int stoptime;
public Vector2 lastPos;//鼠标上次位置
public Vector2 currPos;//鼠标当前位置
private void OnMouseDown()
{
}
private void Update()//计算鼠标移动距离
{
if (Input.GetMouseButtonDown(0))
{
lastPos = Input.mousePosition;
Stopbtn.GetComponent<CanvasGroup>().alpha = 1;
stoptime = 50;//多久后开始变透明
}
if (Input.GetMouseButtonUp(0))
{
currPos = Input.mousePosition;
}
//Debug.Log(videoplayer.GetComponent<VideoPlayer