制作CG动画,用video组件
1,首先需要一段视频格式,比如mp4
2,接下来需要创建一个Render Texture
3,写一个下面的脚本
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
public class VideoPanelCtrl : MonoBehaviour
{
public VideoPlayer VPlayer;
public GameObject rawImg;
/// <summary>
/// 是否要循环播放,加载背景需要循环,而且循环播放不关闭
/// </summary>
public bool isLoop;
/// <summary>
/// 是否是开始CG动画
/// </summary>
public bool isStartCG;
private void Awake()
{
rawImg.SetActive(false);
VPlayer.errorReceived += ErrorReceived;
VPlayer.loopPointReached += LoopPointReached;
}
private void Start()
{
//如果达到某些条件就不播放,比如CG动画只在第一次打开游戏时播放
if(PlayerPrefs.GetInt("Game", 0) == 1 && isStartCG)
{
Stop();