[UNITY] ใช้ AssetBundle ด้วย Resources.Load (ไม่ต้องใช้ Internet) by tosawat
30
Apr0
Apr0
หากอยากใช้ AssetBundle ที่เราเตรียมไว้แล้ว แต่ไม่อยากให้โหลดจาก server ของเรา ก็มีวิธีการดังนี้
- ให้เปลี่ยนนามสกุลของไฟล์ AssetBundle ให้เป็นไฟล์ .txt
- จากนั้นนำไฟล์ AssetBubdle.txt ไปใส่ไว้ใส Folder Resources ของ Unity Project
- ใช้ code ชุดนี้ ในการโหลด AssetBundle
fileAsText = Resources.Load("AssetBundle.txt") as TextAsset;
byte[] bundleData = fileAsText.bytes.Clone() as byte[];
AssetBundleCreateRequest bundleRequest = AssetBundle.CreateFromMemory( bundleData ); - เราก็จะได้ bundleRequest.assetBundle เป็น AssetBundle มาให้ใช้ได้ตามอัธยาศัย
Enjoy this article?
Consider subscribing to our RSS feed!
ไม่มีความเห็น
ยังไม่มีความเห็น