2013年5月15日 星期三

unity render.material.mainTexture.Play() 問題以及解決方法 (render.material.mainTexture.Play() declear problem and solution)

由於小弟的研究必須用到在Unity中任意物件內部塞影片的問題

因此小弟很有上進心的跑去找系上Unity最厲害的學長詢問

學長給了一篇連結並告訴我照著做就可以了:http://www.youtube.com/watch?v=-vd9Mdb2r34

小弟都照著做直到某一步驟讓小弟差點把電腦給砸了 (卡了4個小時)

 

因此小弟特地把解決方法放到網路上供新手解決

解決方法(solving):
1. 下載QuickTime安裝 (download QuickTime and install)
http://www.apple.com/tw/quicktime/download/


2. 將影片匯入Unity (import your video)
PS:請注意格式 (please notice your video format)


3. 建立Cube 以及 Material (Create Cube and Material)


4. 將影片檔塞入Material材質中 ( Put the video file into the Material texture)

5. 將Material帶到 Cube 中(take the Material to the Cube)

6. 建立 C# Script (create the C# Script)
7. 將程式帶入Cube中 (put the script to the Cube)

8. 打上下列程式(type the follow code)

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {
public MovieTexture mov;
// Use this for initialization
void Start () {
renderer.material.mainTexture = mov;
mov.Play();
}
// Update is called once per frame
void Update () {
}
}

PS: 記得存檔及按下F8執行(Please remember save file and press F8 to compile)

9. 將影片檔放到Script下的mov (put the video file in the mov variable of Script)


10. 完成  可以試跑程式了 (Finish!!)












沒有留言:

張貼留言