Exemplo n.º 1
0
        protected void packOneLevelPack()
        {
            string        resPath  = "";
            List <string> nameList = new List <string>();
            List <string> pathList = new List <string>();

            List <string> filesList = UtilPath.GetAll(ExportUtil.getDataPath(m_packParam.m_inPath));
            string        ext       = "";
            string        nameNoExt = "";
            string        tmpStr    = "";
            StreamedSceneAssetBundleParam bundleParam = new StreamedSceneAssetBundleParam();

            foreach (string filePath in filesList)
            {
                ext       = UtilPath.getFileExt(filePath);
                nameNoExt = UtilPath.getFileNameNoExt(filePath);
                if (ExportUtil.isArrContainElem(ext, m_packParam.m_extArr))
                {
                    resPath = ExportUtil.convFullPath2AssetsPath(filePath);
                    nameList.Add(resPath);
                    bundleParam.m_levels = nameList.ToArray();
                    pathList.Clear();
                    pathList.Add(m_packParam.m_outPath);
                    tmpStr = string.Format("{0}{1}", nameNoExt, UtilApi.DOTUNITY3D);
                    pathList.Add(tmpStr);
                    bundleParam.m_locationPath = ExportUtil.getStreamingDataPath(UtilPath.combine(pathList.ToArray()));

                    ExportUtil.BuildStreamedSceneAssetBundle(bundleParam);
                }
            }
        }
        protected void addResListItem(string srcFullPath, string destFullPath)
        {
            ResListItem item = new ResListItem();

            item.m_srcName = ExportUtil.rightSubStr(srcFullPath, m_srcRoot);
            if (m_unity3dExtNameList.IndexOf(UtilPath.getFileExt(srcFullPath)) != -1)     // 如果需要打包成 unity3d
            {
                item.m_destName = string.Format("{0}{1}", item.m_srcName.Substring(0, item.m_srcName.IndexOf('.')), UtilApi.DOTUNITY3D);
            }
            else
            {
                item.m_destName = item.m_srcName;
            }

            if (m_destRoot.Length > 0)
            {
                item.m_destName = string.Format("{0}/{1}", m_destRoot, item.m_destName);
            }

            // 如果是 unity 扩展名字的场景文件,需要在原始文件名字前面添加 Scenes 子目录
            if (UtilPath.getFileExt(item.m_srcName) == "unity")
            {
                item.m_srcName = string.Format("Scenes/{0}", item.m_srcName);
            }
            ResExportSys.m_instance.m_pResourcesCfgPackData.m_exportResList.addItem(item);
        }
Exemplo n.º 3
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 = UtilPath.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       = UtilPath.getFileExt(filePath);
                nameNoExt = UtilPath.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 = UtilApi.UNITY3D;
                        bundleParam.m_buildList[0].assetNames         = assetNamesList.ToArray();
                        pathList.Clear();
                        pathList.Add(m_packParam.m_outPath);
                        bundleParam.m_pathName = ExportUtil.getStreamingDataPath(UtilPath.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));
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void onFindFile(string path, string name)
        {
            path = UtilPath.normalPath(path);
            string extName = UtilPath.getFileExt(path);

            if (m_xmlPath.includeExtList.IndexOf(extName) != -1)         // 如果在包含的扩展名列表中
            {
                AssetBundleNameFileData file = new AssetBundleNameFileData(path, this);
                m_filesList.Add(file);
                file.buildData();
            }
        }
Exemplo n.º 5
0
        protected void onFindFile(string path, string name)
        {
            path = UtilPath.normalPath(path);
            string extName = UtilPath.getFileExt(path);

            if (m_xmlPath.ignoreExtList.IndexOf(extName) == -1)         // 如果没有在或略的扩展名列表中
            {
                FileData file = new FileData(path, this);
                m_filesList.Add(file);
                file.buildData();
            }
        }
Exemplo n.º 6
0
        protected void onFindOneFile(string fullPath, string name)
        {
            string ext = UtilPath.getFileExt(fullPath);

            if (m_ignoreExtList.IndexOf(ext) == -1)
            {
                string fileName = UtilPath.getFileNameWithExt(fullPath);
                Mesh   mesh     = new Mesh();
                mesh.skelMeshParam.m_name           = fileName;
                mesh.skelMeshParam.m_inPath         = m_inPath;
                mesh.skelMeshParam.m_outPath        = m_outPath;
                mesh.skelMeshParam.m_resType        = m_resType;
                mesh.skelMeshParam.m_controllerPath = m_controllerPath;

                mesh.addSubMesh();

                SkinAnimSys.m_instance.m_xmlSkinMeshRoot.m_meshList.Add(mesh);
            }
        }
Exemplo n.º 7
0
        protected void onFindOneFile(string fullPath, string name)
        {
            string ext       = UtilPath.getFileExt(fullPath);
            string nameNoExt = UtilPath.getFileNameNoExt(fullPath);

            XmlAnimatorController controller = null;

            if (ExportUtil.FBX == ext)
            {
                if (!nameNoExt.Contains(ExportUtil.AT))      // 如果包含 @ ,就说明是一个动画
                {
                    m_xmlTmp.SetAttribute("outname", nameNoExt);
                    controller = new XmlAnimatorController();
                    ExportAnimatorControllerSys.m_instance.controllerList.Add(controller);
                    controller.parseXml(m_xmlTmp);

                    // 调整完整的文件名字
                    controller.adjustFileName(nameNoExt);
                }
            }
        }
        // 遍历一个文件的时候处理
        public void handleFile(string fullFileName, string name)
        {
            fullFileName = UtilPath.normalPath(fullFileName);
            if (m_ignoreExtList.IndexOf(UtilPath.getFileExt(fullFileName)) == -1)
            {
                string fineNameNoExt = UtilPath.getFileNameNoExt(fullFileName);
                string assetPath     = fullFileName.Substring(fullFileName.IndexOf(ExportUtil.ASSETS));
                string destPath      = "";

                if (m_unity3dExtNameList.IndexOf(UtilPath.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 = UtilApi.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 后文件名字会变成小写,这里修改一下
                    UtilPath.modifyFileNameToCapital(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);
            }
        }