// 打包自己指定资源
    public static void BuildCustomAssetBundles()
    {
        // Choose the output path according to the build target.
        string outputPath = ExportUtil.getStreamingDataPath("");

        if (!Directory.Exists(outputPath))
        {
            Directory.CreateDirectory(outputPath);
        }

        AssetBundleParam param = new AssetBundleParam();

        param.m_buildList = new AssetBundleBuild[1];
        param.m_buildList[0].assetBundleName    = "TestExportPrefab";
        param.m_buildList[0].assetBundleVariant = UtilApi.UNITY3D;
        param.m_buildList[0].assetNames         = new string[1];
        param.m_buildList[0].assetNames[0]      = "Assets/TestAssets/TestPrefab.prefab"; // 这个目录一定要是 Assets 下面写,并且加上扩展名字
        param.m_pathName           = outputPath;
        param.m_assetBundleOptions = 0;
        param.m_targetPlatform     = EditorUserBuildSettings.activeBuildTarget;
        ExportUtil.BuildAssetBundle(param);

        // 打包成 unity3d 后文件名字会变成小写,这里修改一下
        UtilPath.modifyFileNameToCapital(outputPath, "TestExportPrefab");
    }
Example #2
0
        protected void packOneBundlePack()
        {
            string resPath = "";
            List<string> assetNamesList = new List<string>();
            List<Object> objList = new List<Object>();
            UnityEngine.Object go;

            List<string> pathList = new List<string>();
            List<string> filesList = ExportUtil.GetAll(ExportUtil.getDataPath(m_packParam.m_inPath));
            string ext = "";
            string nameNoExt = "";
#if UNITY_4_6
            string tmpStr = "";
#endif
            AssetBundleParam bundleParam = new AssetBundleParam();

            foreach (string filePath in filesList)
            {
                objList.Clear();
                assetNamesList.Clear();
                ext = ExportUtil.getFileExt(filePath);
                nameNoExt = ExportUtil.getFileNameNoExt(filePath);
                if (ExportUtil.isArrContainElem(ext, m_packParam.m_extArr))
                {
                    resPath = ExportUtil.convFullPath2AssetsPath(filePath);
                    assetNamesList.Add(resPath);
                    go = AssetDatabase.LoadAssetAtPath(resPath, ExportUtil.convResStr2Type(ExportUtil.convExt2ResStr(ext)));
                    if (go)
                    {
                        objList.Add(go);
                        
#if UNITY_5
                        bundleParam.m_buildList = new AssetBundleBuild[1];
                        bundleParam.m_buildList[0].assetBundleName = nameNoExt;
                        bundleParam.m_buildList[0].assetBundleVariant = ExportUtil.UNITY3D;
                        bundleParam.m_buildList[0].assetNames = assetNamesList.ToArray();
                        pathList.Clear();
                        pathList.Add(m_packParam.m_outPath);
                        bundleParam.m_pathName = ExportUtil.getStreamingDataPath(ExportUtil.combine(pathList.ToArray()));
#elif UNITY_4_6 || UNITY_4_5
                        bundleParam.m_assets = objList.ToArray();
                        pathList.Clear();
                        pathList.Add(m_packParam.m_outPath);
                        tmpStr = string.Format("{0}{1}", nameNoExt, ExportUtil.DOTUNITY3D);
                        pathList.Add(tmpStr);
                        bundleParam.m_pathName = ExportUtil.getStreamingDataPath(ExportUtil.combine(pathList.ToArray()));
#endif
                        ExportUtil.BuildAssetBundle(bundleParam);
                    }
                    else
                    {
                        LoggerTool.error(string.Format("AssetDatabase.LoadAssetAtPath 不能加载资源 {0}", filePath));
                    }
                }
            }
        }
Example #3
0
    // 打包 Editor 的 Asset Labels 中指定的 AssetBundle
	public static void BuildAssetLabelsAssetBundles()
	{
		// Choose the output path according to the build target.
        string outputPath = Path.Combine(ExportUtil.ASSET_BUNDLES_OUTPUT_PATH, ExportUtil.GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget));
		if (!Directory.Exists(outputPath) )
			Directory.CreateDirectory (outputPath);

        AssetBundleParam param = new AssetBundleParam();
        param.m_pathName = outputPath;
        param.m_assetBundleOptions = 0;
        param.m_targetPlatform = EditorUserBuildSettings.activeBuildTarget;

        ExportUtil.BuildAssetBundle(param);
	}
Example #4
0
        static public void BuildAssetBundle(AssetBundleParam param)
        {
#if UNITY_5
            if (param.m_buildList != null)
            {
                BuildPipeline.BuildAssetBundles(param.m_pathName, param.m_buildList, param.m_assetBundleOptions, param.m_targetPlatform);
            }
            else
            {
                BuildPipeline.BuildAssetBundles(param.m_pathName, param.m_assetBundleOptions, param.m_targetPlatform);
            }
#elif UNITY_4_6 || UNITY_4_5
            BuildPipeline.BuildAssetBundle(param.m_mainAsset, param.m_assets, param.m_pathName, param.m_assetBundleOptions, param.m_targetPlatform);
#endif
        }
Example #5
0
        protected void packOneBundlePack(PackParam param)
        {
            string resPath = "";
            List<Object> objList = new List<Object>();
            List<string> assetNamesList = new List<string>();
            UnityEngine.Object go;

            List<string> pathList = new List<string>();
            foreach (PackItem packItem in m_packList)
            {
                pathList.Clear();
                pathList.Add(param.m_inPath);
                pathList.Add(packItem.m_path);

                resPath = ExportUtil.getRelDataPath(ExportUtil.combine(pathList.ToArray()));
                assetNamesList.Add(resPath);
                go = AssetDatabase.LoadAssetAtPath(resPath, ExportUtil.convResStr2Type(packItem.m_resType));
                if (go)
                {
                    objList.Add(go);
                }
                else
                {
                    LoggerTool.error(string.Format("AssetDatabase.LoadAssetAtPath 不能加载资源 {0}", resPath));
                }
            }

            AssetBundleParam bundleParam = new AssetBundleParam();

#if UNITY_5
            bundleParam.m_buildList = new AssetBundleBuild[1];
            bundleParam.m_buildList[0].assetBundleName = m_name;
            bundleParam.m_buildList[0].assetBundleVariant = ExportUtil.UNITY3D;
            bundleParam.m_buildList[0].assetNames = assetNamesList.ToArray();
            pathList.Clear();
            pathList.Add(param.m_outPath);
            bundleParam.m_pathName = ExportUtil.getStreamingDataPath(ExportUtil.combine(pathList.ToArray()));
#elif UNITY_4_6 || UNITY_4_5
            bundleParam.m_assets = objList.ToArray();
            pathList.Clear();
            pathList.Add(param.m_outPath);
            pathList.Add(m_name);
            bundleParam.m_pathName = ExportUtil.getStreamingDataPath(ExportUtil.combine(pathList.ToArray()));
#endif

            ExportUtil.BuildAssetBundle(bundleParam);
        }
    // 打包 Editor 的 Asset Labels 中指定的 AssetBundle
    public static void BuildAssetLabelsAssetBundles()
    {
        // Choose the output path according to the build target.
        string outputPath = Path.Combine(ExportUtil.ASSET_BUNDLES_OUTPUT_PATH, ExportUtil.GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget));

        if (!Directory.Exists(outputPath))
        {
            Directory.CreateDirectory(outputPath);
        }

        AssetBundleParam param = new AssetBundleParam();

        param.m_pathName           = outputPath;
        param.m_assetBundleOptions = 0;
        param.m_targetPlatform     = EditorUserBuildSettings.activeBuildTarget;

        ExportUtil.BuildAssetBundle(param);
    }
Example #7
0
    // 打包自己指定资源
    public static void BuildCustomAssetBundles()
	{
		// Choose the output path according to the build target.
        string outputPath = ExportUtil.getStreamingDataPath("");
		if (!Directory.Exists(outputPath) )
			Directory.CreateDirectory (outputPath);

        AssetBundleParam param = new AssetBundleParam();
        param.m_buildList = new AssetBundleBuild[1];
        param.m_buildList[0].assetBundleName = "TestExportPrefab";
        param.m_buildList[0].assetBundleVariant = ExportUtil.UNITY3D;
        param.m_buildList[0].assetNames = new string[1];
        param.m_buildList[0].assetNames[0] = "Assets/TestAssets/TestPrefab.prefab";     // 这个目录一定要是 Assets 下面写,并且加上扩展名字
        param.m_pathName = outputPath;
        param.m_assetBundleOptions = 0;
        param.m_targetPlatform = EditorUserBuildSettings.activeBuildTarget;
        ExportUtil.BuildAssetBundle(param);

        // 打包成 unity3d 后文件名字会变成小写,这里修改一下
        ExportUtil.modifyFileName(outputPath, "TestExportPrefab");
	}
    public static void BuildStreamedSceneAssetBundles()
    {
        // Choose the output path according to the build target.
        string outputPath = ExportUtil.getStreamingDataPath("");

        if (!Directory.Exists(outputPath))
        {
            Directory.CreateDirectory(outputPath);
        }

        string[]         levels = ExportUtil.GetLevelsFromBuildSettings();
        AssetBundleParam param  = new AssetBundleParam();

        param.m_buildList = new AssetBundleBuild[1];
        param.m_buildList[0].assetBundleName    = "TestExportScene";
        param.m_buildList[0].assetBundleVariant = UtilApi.UNITY3D;
        param.m_buildList[0].assetNames         = new string[1];
        param.m_buildList[0].assetNames[0]      = levels[3]; // 这个目录一定要是 Assets 下面写,并且加上扩展名字
        param.m_pathName           = outputPath;
        param.m_assetBundleOptions = 0;
        param.m_targetPlatform     = EditorUserBuildSettings.activeBuildTarget;
        ExportUtil.BuildAssetBundle(param);
    }
Example #9
0
    public static void BuildStreamedSceneAssetBundles()
    {
        // Choose the output path according to the build target.
        string outputPath = ExportUtil.getStreamingDataPath("");
        if (!Directory.Exists(outputPath))
            Directory.CreateDirectory(outputPath);

        string[] levels = ExportUtil.GetLevelsFromBuildSettings();
        AssetBundleParam param = new AssetBundleParam();
        param.m_buildList = new AssetBundleBuild[1];
        param.m_buildList[0].assetBundleName = "TestExportScene";
        param.m_buildList[0].assetBundleVariant = ExportUtil.UNITY3D;
        param.m_buildList[0].assetNames = new string[1];
        param.m_buildList[0].assetNames[0] = levels[3];     // 这个目录一定要是 Assets 下面写,并且加上扩展名字
        param.m_pathName = outputPath;
        param.m_assetBundleOptions = 0;
        param.m_targetPlatform = EditorUserBuildSettings.activeBuildTarget;
        ExportUtil.BuildAssetBundle(param);
    }
Example #10
0
        // 遍历一个文件的时候处理
        public void handleFile(string fullFileName)
        {
            fullFileName = ExportUtil.normalPath(fullFileName);
            if (m_ignoreExtList.IndexOf(ExportUtil.getFileExt(fullFileName)) == -1)
            {
                string fineNameNoExt = ExportUtil.getFileNameNoExt(fullFileName);
                string assetPath = fullFileName.Substring(fullFileName.IndexOf(ExportUtil.ASSETS));
                string destPath = "";

                if (m_unity3dExtNameList.IndexOf(ExportUtil.getFileExt(fullFileName)) != -1)
                {
                    if (fullFileName.LastIndexOf('/') != m_srcFullPath.Length)
                    {
                        destPath = fullFileName.Substring(m_srcFullPath.Length + 1, fullFileName.LastIndexOf('/') - (m_srcFullPath.Length + 1));
                    }
                    if (!string.IsNullOrEmpty(m_destRoot))
                    {
                        destPath = Path.Combine(ResExportSys.m_instance.m_pResourcesCfgPackData.m_destFullPath, m_destRoot);
                        destPath = Path.Combine(destPath, destPath);
                    }
                    else
                    {
                        destPath = Path.Combine(ResExportSys.m_instance.m_pResourcesCfgPackData.m_destFullPath, destPath);
                    }

                    AssetBundleParam bundleParam = new AssetBundleParam();
#if UNITY_5
                    bundleParam.m_buildList = new AssetBundleBuild[1];
                    bundleParam.m_buildList[0].assetBundleName = fineNameNoExt;
                    bundleParam.m_buildList[0].assetBundleVariant = ExportUtil.UNITY3D;
                    bundleParam.m_buildList[0].assetNames = new string[1];
                    bundleParam.m_buildList[0].assetNames[0] = assetPath;
                    bundleParam.m_targetPlatform = ResExportSys.m_instance.m_targetPlatform;
                    bundleParam.m_pathName = destPath;
#elif UNITY_4_6 || UNITY_4_5
                    bundleParam.m_assets = objList.ToArray();
                    pathList.Clear();
                    pathList.Add(m_skelMeshParam.m_outPath);
                    pathList.Add(skelNoExt + ".unity3d");
                    bundleParam.m_pathName = ExportUtil.getStreamingDataPath(ExportUtil.combine(pathList.ToArray()));
#endif
                    ExportUtil.BuildAssetBundle(bundleParam);
                    // 打包成 unity3d 后文件名字会变成小写,这里修改一下
                    ExportUtil.modifyFileName(destPath, fineNameNoExt);
                }
                else        // 直接拷贝过去
                {
                    if (fullFileName.LastIndexOf('/') != m_srcFullPath.Length)
                    {
                        destPath = fullFileName.Substring(m_srcFullPath.Length + 1, fullFileName.Length - (m_srcFullPath.Length + 1));
                    }
                    if (!string.IsNullOrEmpty(m_destRoot))
                    {
                        destPath = Path.Combine(ResExportSys.m_instance.m_pResourcesCfgPackData.m_destFullPath, m_destRoot);
                        destPath = Path.Combine(destPath, destPath);
                    }
                    else
                    {
                        destPath = Path.Combine(ResExportSys.m_instance.m_pResourcesCfgPackData.m_destFullPath, destPath);
                        File.Copy(fullFileName, destPath);
                    }
                }

                addResListItem(fullFileName, destPath);
            }
        }