zoukankan      html  css  js  c++  java
  • u3d加载外部视屏

    u3d的外部加载视屏,采用www方式,可以使用gui播放,也可以绑定到gameobject上作为动态材质使用,不过目前只支持。ogg格式,需要转。。。

    using UnityEngine;
    using System.Collections;

    public class movie : MonoBehaviour
    {
        private MovieTexture movTexture;

        private string movPath;

        void Start()
        {
            movPath = "file://" + Application.dataPath + "/1.ogg";
            StartCoroutine(LoadMoview());

        }
        public void LoadRes()
        {
            movPath = "file://" + Application.dataPath + "/1.ogg";
            StartCoroutine(LoadMoview());
        }
        IEnumerator LoadMoview()
        {
            WWW wwwDate = new WWW(movPath);

            yield return wwwDate;
            movTexture = wwwDate.movie;//得到下载的贴图
            movTexture.loop = true;
            movTexture.Play();
        }

        // Update is called once per frame
        void Update()
        {
            // GUI.DrawTexture(new Rect(0 + 100, 0 + 100, Screen.width - 100, Screen.height - 100), movTexture, ScaleMode.ScaleToFit);
            


            this.renderer.material.mainTexture = movTexture;  
        }

        void OnGUI()
        {
         
           
        }
    }


     下面是给一个gameobject加上这个脚本

    using UnityEngine;
    using System.Collections;
    
    public class Init : MonoBehaviour
    {
        private GameObject m_ObjCube;
        // Use this for initialization
        void Start () 
        {
            m_ObjCube = GameObject.Find("ECube");
            m_ObjCube.AddComponent<movie>();
            //m_ObjCube.GetComponent<movie>().LoadRes();
        }
        
        // Update is called once per frame
        void Update () {
        
        }
    }
  • 相关阅读:
    angularjs1-8,cacheFactory,sce
    angularjs1-7,http,location
    angularjs1-7,供应商
    angularjs1-6,自定义服务
    UI设计师不可不知的安卓屏幕知识-安卓100分享
    k8s ingres 的安装与使用
    get、put、post、delete含义与区别
    [影像技术与PACS] 从技术角度看国内部份PACS厂商
    UML类图符号 各种关系说明以及举例
    理解 Delphi 的类(八)
  • 原文地址:https://www.cnblogs.com/dragon2012/p/3922050.html
Copyright © 2011-2022 走看看