zoukankan      html  css  js  c++  java
  • Unity 4.x 资源打包

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEditor;
    
    public class ExportAssetBundles : MonoBehaviour
    {
        //在Unity编辑器中添加菜单
        [MenuItem("Assets/Build AssetBundle From Selection")]
        static void ExportResource()
        {
            //打开保存面板
            string path = EditorUtility.SaveFilePanel("Save Resource", string.Empty, "New Resource", "assetbundle");
            if (path.Length > 0)
            {
                //选择要打包的对象
                Object[] selections = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
    
                //打包
                BuildPipeline.BuildAssetBundle(Selection.activeObject, selections, path, BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.CollectDependencies, BuildTarget.StandaloneWindows);
            }
        }
    
        [MenuItem("Assets/Save Scene")]
        static void ExportScene()
        {
            string path = EditorUtility.SaveFilePanel("Save Resource", string.Empty, "New Resource", "unity3d");
    
            if (path.Length > 0)
            {
                Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
    
                //具体到工程中,需要动态设置
                string[] scenes = { "Assets/Scene1.unity" };
    
                BuildPipeline.BuildPlayer(scenes, path, BuildTarget.StandaloneWindows, BuildOptions.BuildAdditionalStreamedScenes);
            }
        }
    }
    

      

  • 相关阅读:
    一些博弈
    中国剩余定理分析及扩展
    2018年全国多校算法寒假训练营练习比赛(第三场)
    数论——逆元
    扩展欧几里得
    算法思维题
    匈牙利算法
    Codeforces #449 div2 C题
    16级C程序设计竞赛C题
    动态规划--模板--hdu 1059 Dividing
  • 原文地址:https://www.cnblogs.com/luguoshuai/p/9124207.html
Copyright © 2011-2022 走看看