zoukankan      html  css  js  c++  java
  • AssetBundle之批量打包

    1.2批量打包方法

    using UnityEngine;
    using UnityEditor;
    using System.Collections;

    public class ExportAssetSerielize : MonoBehaviour 
    {
    [MenuItem("Custom Editor/Create AssetBundles Main")]
    static void CreateAssetBundleMain() 
    {
    //获取在project视图中选择的所有游戏对象
    Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

    //遍历所有的游戏对象
    foreach(Object obj in SelectedAsset)
    {
    string sourcePath = AssetDatabase.GetAssetPath(obj);
    string targetPath = Application.dataPath + @"/Prb/" + obj.name + ".assetbundle";

    if (BuildPipeline.BuildAssetBundle(obj, null, targetPath, BuildAssetBundleOptions.CollectDependencies))
    {
    Debug.Log(obj.name + "资源打包成功");
    }
    else 
    {
    Debug.Log(obj.name + "资源打包失败");
    }
    }
    AssetDatabase.Refresh();// 刷新编辑器
    }
    }

  • 相关阅读:
    js18
    js17
    js16
    js15
    js14
    js13
    js12
    js11
    八月二十三的php
    八月二十二的php
  • 原文地址:https://www.cnblogs.com/xwwFrank/p/4450895.html
Copyright © 2011-2022 走看看