bug再現:
當把播放的視頻拖拽到MovieTexture上,打包後 即使將這個視頻刪除了,程序仍可以播放視頻。
movieTexture.Play(); 直接播放視頻。經過羣裏大神指導發現,當你拖拽物體到對應的腳本時候unity自己會關聯資源關係,從而直接打包到項目中。
www動態加載播放視頻代碼:
using UnityEngine;
using System.Collections;
public class MovePlay : MonoBehaviour {
public MovieTexture movieTexture;
public WWW www;
string datapath;
// Use this for initialization
void Start () {
datapath = Application.streamingAssetsPath+ "/DLXX.ogv";
Debug.Log("file://" + datapath );
StartCoroutine(OnLoadMove());
}
// Update is called once per frame
void Update () {
}
void OnGUI() {
if (GUILayout.Button("play")) {
movieTexture.Play();
}
}
IEnumerator OnLoadMove() {
www = new WWW("file://"+datapath);
Debug.Log(www);
yield return www;
movieTexture = www.movie;
renderer.material.mainTexture = movieTexture;
movieTexture.loop = true;
// movieTexture.Play();
}
}