AssetsBundle多种打包方式

此篇纯粹用来记录,害怕时间久忘了

第一种包名打包方式:

    [MenuItem ("MyAssets/packageModle004")]
    static void AssetsBundleFunction()
    {
        string abFile = "Assets/StreamingAssets";
        if (!Directory .Exists(abFile))
        {
            Directory.CreateDirectory(abFile);
        }
        BuildPipeline.BuildAssetBundles(abFile, BuildAssetBundleOptions.None,      BuildTarget.StandaloneWindows64);
    }

第二种分割打包:

    [MenuItem("MyAssets/Creat AssetBundle By themselves")]
    public static void CreatAssetBundleThemelves()
    {
        Object[] selects = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
        foreach (var item in selects)
        {
            string path = AssetDatabase.GetAssetPath(item);
            AssetImporter.GetAtPath(path).assetBundleName = item.name;
            string targetPath = "Assets/StreamingAssets";
            if (BuildPipeline.BuildAssetBundles(targetPath, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64))
            {
                Debug.Log(item.name + "is packed successfully");
            }
            else
            {
                Debug.Log(item.name + "is packed failly!");
            }
        }
    }

猜你喜欢

转载自blog.csdn.net/qq_42047805/article/details/82848250