• Unity播放视频


    视频导入Unity,需要先安装QuickTime Player,不能识别视频,需要重启下电脑

    转换视频格式,转换成mov格式,之前系统上可以播放mp4格式,现在的电脑mp4视频,播放出来是黑屏,不知是视频问题还是什么问题,转换成mov在播放,就好了

    using UnityEngine;  
    using System.Collections;  
      
    public class MovieTest : MonoBehaviour  
    {  
        public MovieTexture movTexture;  
        public AudioSource movAudio;  
      
        void Start()  
        {  
            renderer.material.mainTexture = movTexture;  
            movTexture.loop = true;  
        }  
      
        void OnGUI()  
        {  
            if (GUILayout.Button("播放/继续"))  
            {  
                if (!movTexture.isPlaying)  
                {  
                    movTexture.Play();  
                    movAudio.Play();  
                }  
            }  
      
            if (GUILayout.Button("暂停播放"))  
            {  
                movTexture.Pause();  
                movAudio.Pause();  
            }  
      
            if (GUILayout.Button("停止播放"))  
            {  
                movTexture.Stop();  
                movAudio.Stop();  
            }  
        }  
    }  
            Material[] ms = GetComponent<Renderer>().materials;
            Material m = ms.FirstOrDefault(w => w.name.IndexOf("GGJ_1") != -1);
            if (m != null)
            {
                moveTexture = m.mainTexture as MovieTexture;
                moveTexture.loop = true;
                moveTexture.Play();
            }
  • 相关阅读:
    杜教筛学习笔记
    AtCoder Beginner Contest 188 F
    求和公式
    洛谷P4848 崂山白花蛇草水 权值线段树+KDtree
    二次剩余学习笔记
    Miller Rabin素数检测与Pollard Rho算法
    半平面交学习笔记
    凸包习题总结
    多项式半家桶
    CF997解题报告
  • 原文地址:https://www.cnblogs.com/dj1232090/p/5465810.html
Copyright © 2020-2023  润新知