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