天天看點

01.程式集和資源加載

01.程式集和資源加載

01.程式集

01.程式集和資源加載

程式集引入

01.程式集和資源加載
01.程式集和資源加載

02.

01.程式集和資源加載
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEditor;

public class AssetBundleEditor : MonoBehaviour
{
    [MenuItem("Tools/打包")]
    public static void Buid()
    {
        if (Directory.Exists(Application.streamingAssetsPath) == false)
        {
            Directory.CreateDirectory(Application.streamingAssetsPath);
        }

        BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath, BuildAssetBundleOptions.ChunkBasedCompression,
            EditorUserBuildSettings.activeBuildTarget);
       AssetDatabase.Refresh();
    }
    
}      
void Start()
    {
        AssetBundle assetBundle=AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/Attack");
        GameObject item=Instantiate(assetBundle.LoadAsset<GameObject>("Attack"));
        item.transform.SetParent(this.transform);
    }