๐ฆ Unity Asset Bundle
๐ง Document
https://docs.unity3d.com/kr/530/Manual/BuildingAssetBundles.html
์ ๋ํฐ - ๋งค๋ด์ผ: 4.x๋ฒ์ ์์์ ์์ ๋ฒ๋ค ๋น๋
์์ ๋ฒ๋ค (AssetBundles) 4.x๋ฒ์ ์์์ ์์ ๋ฒ๋ค ๋น๋ To begin creating an AssetBundle (called AssetBundle in scripts and within the Unity Editor), select an asset from your project folder that you want to include in a bundle. At the very bott
docs.unity3d.com
https://docs.unity3d.com/2017.4/Documentation/Manual/AssetBundles-Native.html
Unity - Manual: Using AssetBundles Natively
Using AssetBundles Natively Important note: The AssetBundle Manager is deprecated for Unity versions 2018.2 and higher. It is no longer available from the Asset Store, but you can still download it from the AssetBundleDemo Bitbucket repository. If you use
docs.unity3d.com
๐ฆ Bundle Build



- AssetBundle์ ์ ์ : bundle_1

- Box ํ๋ฆฌํน๋ bundle_1๋ก ์ค์

- ํด๋ ์์ฑ : AssetBundles

- ํด๋ ์์ฑ : Editor
- ์คํฌ๋ฆฝํธ ์์ฑ : CreateAssetBundles
using UnityEditor;
public class CreateAssetBundles
{
[MenuItem("Assets/Build AssetBundles")]
static void BuildAllAssetBundles()
{
// ์์
๋ฒ๋ค ์์ฑ ๊ฒฝ๋ก, ๋น๋ ์ต์
, ๋น๋ ๋์ ํ๋ซํผ
BuildPipeline.BuildAssetBundles("Assets/AssetBundles", BuildAssetBundleOptions.None, BuildTarget.Android);
}
}
-

- Build AssetBundles ํด๋ฆญํ๋ฉด ์์ ๋ฒ๋ค์ ๋น๋ํจ

- AssetBundles ํด๋ ์์ ์์ ๊ฐ์ ํ์ผ์ด ์์ฑ๋ ๊ฒ์ ํ์ธ
๐ฆ Bundle Load
๐ง LoadFromMemoryAsync

- ๋น ๊ฒ์์ค๋ธ์ ํธ ์์ฑ : LoadManager
- ์คํฌ๋ฆฝํธ ์์ฑ : LoadManager
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class LoadManager : MonoBehaviour
{
// ๋ก๋ํ ์์
๋ฒ๋ค ๊ฒฝ๋ก
private string assetBundlePath = "Assets/AssetBundles/bundle_1";
// ๋ถ๋ฌ์ฌ ์ค๋ธ์ ํธ ์ด๋ฆ
private string asset_box = "Box";
void Start()
{
StartCoroutine(nameof(LoadFromMemoryAsync), assetBundlePath);
}
IEnumerator LoadFromMemoryAsync(string path)
{
// ์ง์ ๊ฒฝ๋ก์ ์๋ ๋ชจ๋ ๋ฐ์ดํธ๋ฅผ ์ฝ์ด์ ๋ก๋
AssetBundleCreateRequest createRequest = AssetBundle.LoadFromMemoryAsync(File.ReadAllBytes(path));
// ๋ชจ๋ ๋ก๋ํ ๋๊น์ง ๋๊ธฐ
yield return createRequest;
AssetBundle bundle = createRequest.assetBundle;
// ๋ก๋ํ ์์
๋ฒ๋ค์์ ๊ฒ์์ค๋ธ์ ํธ ๋ก๋
var prefab = bundle.LoadAsset<GameObject>(asset_box);
// ๋ถ๋ฌ์จ ๊ฒ์์ค๋ธ์ ํธ ์์ฑ
Instantiate(prefab);
}
}
-


- ์์ ๋ฒ๋ค๋ก ์ค์ ํ Box ํ๋ฆฌํน์ ์ญ์ ํ Play
'Unity > Else' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ ์ด์์ ์ฌ์ ๋ ฌ (0) | 2022.05.27 |
---|---|
Unity VScode Debugging (0) | 2022.05.23 |
Animation Rigging (0) | 2022.04.01 |
AudioMixer (0) | 2021.10.31 |
TMP(Text Mesh Pro) ํ๊ธ ์์ฑ (0) | 2021.10.30 |