u3d加载外部视屏
u3d的外部加載視屏,采用www方式,可以使用gui播放,也可以綁定到gameobject上作為動態(tài)材質(zhì)使用,不過目前只支持。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 initializationvoid Start () {m_ObjCube = GameObject.Find("ECube");m_ObjCube.AddComponent<movie>();//m_ObjCube.GetComponent<movie>().LoadRes(); }// Update is called once per framevoid Update () {} }?
轉載于:https://www.cnblogs.com/dragon2012/p/3922050.html
《新程序員》:云原生和全面數(shù)字化實踐50位技術專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結
- 上一篇: Linux mail 命令参数
- 下一篇: 使用Physics_Body_Edito