π¦ 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 |