Exemple #1
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);
        }
Exemple #2
0
        public void packOnePack(PackParam param)
        {
            List<string> pathList = new List<string>();
            pathList.Add(param.m_outPath);
            pathList.Add(m_name);
            string path = ExportUtil.getStreamingDataPath(ExportUtil.combine(pathList.ToArray()));
            ExportUtil.RecurCreateStreamDirectory(path);

            if (ExportUtil.BUNDLE == param.m_type)
            {
                packOneBundlePack(param);
            }
            else if (ExportUtil.LEVEL == param.m_type)
            {
                packOneLevelPack(param);
            }
        }
Exemple #3
0
        public void exportBoneList()
        {
            XmlDocument xmlDocSave = new XmlDocument();

            xmlDocSave.CreateXmlDeclaration("1.0", "utf-8", null);
            XmlElement root = xmlDocSave.CreateElement("Root");

            foreach (Mesh mesh in m_meshList)
            {
                mesh.exportMeshBone(xmlDocSave, root);
            }

            string xmlName = string.Format("{0}/{1}", m_outPath, "BoneList.xml");

            xmlName = ExportUtil.getDataPath(xmlName);
            xmlDocSave.Save(@xmlName);
        }
Exemple #4
0
        // 获取镜像目录
        public static string getImagePath(string path, BuildTarget buildTarget = defaultValue)
        {
            if (defaultValue == buildTarget)
            {
                buildTarget = EditorUserBuildSettings.activeBuildTarget;
            }

            string outputPath;

            outputPath = Path.Combine(getPkgOutPath(), ExportUtil.IMAGE_PATH);
            outputPath = Path.Combine(outputPath, ExportUtil.GetPlatformFolderForAssetBundles(buildTarget));
            if (string.IsNullOrEmpty(path))
            {
                outputPath = Path.Combine(outputPath, path);
            }
            return(outputPath);
        }
        virtual public void parseXml(string path, XmlRootBase xmlRoot)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(path);

            XmlNode rootNode = xmlDoc.SelectSingleNode("Root");

            xmlRoot.m_outPath = ExportUtil.getXmlAttrStr(rootNode.Attributes["outpath"]);
            if (xmlRoot is XmlSkinMeshRoot)
            {
                (xmlRoot as XmlSkinMeshRoot).m_exportFileType = (eExportFileType)ExportUtil.getXmlAttrInt(rootNode.Attributes["ExportFileType"]);
            }
            //XmlNodeList packNodeList = rootNode.ChildNodes;
            // Mesh 节点
            XmlNodeList packNodeList = rootNode.SelectNodes("Mesh");
            XmlElement  packElem;
            Mesh        mesh;

            foreach (XmlNode packNode in packNodeList)
            {
                packElem = (XmlElement)packNode;
                mesh     = new Mesh();
                xmlRoot.m_meshList.Add(mesh);
                mesh.parseXml(packElem);
            }

            // ModelTypes 节点
            XmlNode xmlModelTypesNode = rootNode.SelectSingleNode("ModelTypes");

            xmlRoot.m_modelTypes.parseXml(xmlModelTypesNode as XmlElement);

            // Path 节点
            ModelPath modelPath;

            packNodeList = rootNode.SelectNodes("ModelPath");
            foreach (XmlNode packNode in packNodeList)
            {
                packElem  = (XmlElement)packNode;
                modelPath = new ModelPath();
                xmlRoot.m_modelPathList.Add(modelPath);
                modelPath.parseXml(packElem);
            }
        }
Exemple #6
0
        protected void onFindOneFile(string fullPath)
        {
            string ext = ExportUtil.getFileExt(fullPath);

            if (m_ignoreExtList.IndexOf(ext) == -1)
            {
                string fileName = ExportUtil.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);
            }
        }
Exemple #7
0
        public void parseXml(XmlElement elem)
        {
            clear();

            m_motion = ExportUtil.getXmlAttrStr(elem.Attributes["motion"]);

            XmlNodeList  condNodeList = elem.SelectNodes("AnyCondition");
            XmlElement   condElem     = null;
            XmlCondition cond;

            foreach (XmlNode condNode in condNodeList)
            {
                condElem = (XmlElement)condNode;
                cond     = new XmlCondition();
                m_anyCondList.Add(cond);
                cond.xmlState = this;
                cond.parseXml(condElem);
            }
        }
        public void parseXml(XmlElement elem)
        {
            clear();

            m_srcStateName  = ExportUtil.getXmlAttrStr(elem.Attributes["srcstate"]);
            m_destStateName = ExportUtil.getXmlAttrStr(elem.Attributes["deststate"]);

            XmlNodeList  condNodeList = elem.SelectNodes("Condition");
            XmlElement   condElem     = null;
            XmlCondition cond;

            foreach (XmlNode condNode in condNodeList)
            {
                condElem = (XmlElement)condNode;
                cond     = new XmlCondition();
                m_condList.Add(cond);
                cond.xmlStateTransition = this;
                cond.parseXml(condElem);
            }
        }
Exemple #9
0
        protected void onFindOneFile(string fullPath)
        {
            string ext       = ExportUtil.getFileExt(fullPath);
            string nameNoExt = ExportUtil.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);
                }
            }
        }
Exemple #10
0
        static public string getStreamingDataPath(string path, BuildTarget buildTarget = defaultValue)
        {
            if (defaultValue == buildTarget)
            {
                buildTarget = EditorUserBuildSettings.activeBuildTarget;
            }
            //return Application.streamingAssetsPath + "/" + path;
            //string outputPath = Application.dataPath.Substring(0, Application.dataPath.IndexOf("Assets"));
            string outputPath;

            //outputPath = Path.Combine(System.Environment.CurrentDirectory, ExportUtil.ASSET_BUNDLES_OUTPUT_PATH);
            outputPath = Path.Combine(getPkgOutPath(), ExportUtil.ASSET_BUNDLES_OUTPUT_PATH);
            outputPath = Path.Combine(outputPath, ExportUtil.GetPlatformFolderForAssetBundles(buildTarget));
            //outputPath = Path.Combine(outputPath, "StreamingAssets");
            //outputPath = Path.Combine(outputPath, Application.streamingAssetsPath);
            if (string.IsNullOrEmpty(path))
            {
                outputPath = Path.Combine(outputPath, path);
            }
            return(outputPath);
        }
Exemple #11
0
        public void save2Files(string parentPath)
        {
            string path = "";

            //path = ExportUtil.getDataPath(string.Format("{0}/{1}/{2}.xml", parentPath, m_subPath, m_outFileName));
            path = ExportUtil.getDataPath(string.Format("{0}/{1}.xml", parentPath, m_outFileName));

            ExportUtil.deleteFile(path);
            FileStream fileStream = new FileStream(path, FileMode.CreateNew);

            byte[] data = new UTF8Encoding().GetBytes(m_content);
            //开始写入
            fileStream.Write(data, 0, data.Length);

            //清空缓冲区、关闭流
            fileStream.Flush();
            fileStream.Close();
            fileStream.Dispose();

            m_content = "";
        }
Exemple #12
0
        public void parseXml(XmlElement elem)
        {
            clear();

            m_name       = ExportUtil.getXmlAttrStr(elem.Attributes["name"]);
            m_fullMotion = string.Format("{0}/{1}", m_stateMachine.layer.xmlLayers.xmlAnimatorController.inPath, m_name);

            XmlNodeList stateNodeList = elem.SelectNodes("State");
            XmlElement  stateElem     = null;
            XmlState    state;

            foreach (XmlNode stateNode in stateNodeList)
            {
                stateElem          = (XmlElement)stateNode;
                state              = new XmlState();
                state.stateMachine = m_stateMachine;
                m_stateList.Add(state);
                m_stateMachine.stateList.Add(state);
                state.parseXml(stateElem);
            }
        }
Exemple #13
0
 // 遍历一个文件夹的时候处理
 public void handleDir(string fullDirName)
 {
     if (m_srcFullPath != fullDirName)
     {
         string destPath = fullDirName.Substring(m_srcFullPath.Length + 1, fullDirName.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);
             ExportUtil.CreateDirectory(destPath);
         }
     }
     else
     {
         ExportUtil.CreateDirectory(ResExportSys.m_instance.m_pResourcesCfgPackData.m_destFullPath);
     }
 }
Exemple #14
0
        public void parseXml(string path, List <ResourcesPathItem> packList)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(path);

            XmlNode rootNode = xmlDoc.SelectSingleNode("Root");

            ResExportSys.m_instance.m_pResourcesCfgPackData.m_resListOutpath = ExportUtil.getXmlAttrStr(rootNode.Attributes["reslistoutpath"]);
            XmlNodeList       packNodeList = rootNode.ChildNodes;
            XmlElement        packElem;
            ResourcesPathItem packType;

            foreach (XmlNode packNode in packNodeList)
            {
                packElem = (XmlElement)packNode;
                packType = new ResourcesPathItem();
                packList.Add(packType);
                packType.parseXml(packElem);
            }
        }
Exemple #15
0
        public void parseXml(XmlElement elem)
        {
            m_packParam.m_type    = ExportUtil.getXmlAttrStr(elem.Attributes["type"]);
            m_packParam.m_inPath  = ExportUtil.getXmlAttrStr(elem.Attributes["inpath"]);
            m_packParam.m_outPath = ExportUtil.getXmlAttrStr(elem.Attributes["outpath"]);

            m_packParam.m_packAllFiles = ExportUtil.getXmlAttrBool(elem.Attributes["packallfiles"]);
            m_packParam.m_extArr       = ExportUtil.getXmlAttrStr(elem.Attributes["infileext"]).Split(',');

            XmlNodeList itemNodeList = elem.ChildNodes;
            XmlElement  itemElem;
            Pack        pack;

            foreach (XmlNode itemNode in itemNodeList)
            {
                itemElem = (XmlElement)itemNode;
                pack     = new Pack();
                m_packList.Add(pack);
                pack.parseXml(itemElem);
            }
        }
Exemple #16
0
        static void CopyAssetBundlesTo(BuildTarget target, string sourcePath, string outputPath)
        {
            FileUtil.DeleteFileOrDirectory(outputPath);
            Directory.CreateDirectory(outputPath);

            string outputFolder = ExportUtil.GetPlatformFolderForAssetBundles(target);
            string source       = Path.Combine(sourcePath, outputFolder);

            if (!System.IO.Directory.Exists(source))
            {
                Debug.Log("No assetBundle output folder, try to build the assetBundles first.");
            }

            string destination = System.IO.Path.Combine(outputPath, outputFolder);

            if (System.IO.Directory.Exists(destination))
            {
                FileUtil.DeleteFileOrDirectory(destination);
            }

            FileUtil.CopyFileOrDirectory(source, destination);
        }
        // 创建所需要的所有的子目录
        protected void createSubDir()
        {
            if (!string.IsNullOrEmpty(m_assetOutPath))
            {
                string path = "";
                path = ExportUtil.getWorkPath(m_assetOutPath);
                if (!ExportUtil.bDirExist(path))
                {
                    ExportUtil.RecurCreateDirectory(path);
                }
            }

            if (!string.IsNullOrEmpty(m_controllerOutPath))
            {
                string path = "";
                path = ExportUtil.getWorkPath(m_controllerOutPath);
                if (!ExportUtil.bDirExist(path))
                {
                    ExportUtil.RecurCreateDirectory(path);
                }
            }
        }
        public void parseXml(XmlElement elem)
        {
            m_inPath            = ExportUtil.getXmlAttrStr(elem.Attributes["inpath"]);
            m_assetOutPath      = ExportUtil.getXmlAttrStr(elem.Attributes["assetoutpath"]);
            m_controllerOutPath = ExportUtil.getXmlAttrStr(elem.Attributes["controlleroutpath"]);
            m_outName           = ExportUtil.getXmlAttrStr(elem.Attributes["outname"]);
            m_outExtName        = ExportUtil.getXmlAttrStr(elem.Attributes["outextname"]);

            m_controllerFullPath = string.Format("{0}/{1}.controller", m_controllerOutPath, m_outName);
            m_assetFullPath      = string.Format("{0}/{1}.{2}", m_assetOutPath, m_outName, m_outExtName);

            XmlNode paramsNode = elem.SelectSingleNode("Params");

            m_params.parseXml(paramsNode as XmlElement);

            XmlNode layersNode = elem.SelectSingleNode("Layers");

            m_layers.parseXml(layersNode as XmlElement);

            // 确保目录都创建
            createSubDir();
        }
Exemple #19
0
        static public void RecurCreateDirectory(string pathAndName)
        {
            string normPath = ExportUtil.normalPath(pathAndName);

            string[] pathArr = normPath.Split(new [] { '/' });

            string curCreatePath = "";
            int    idx           = 0;

            for (; idx < pathArr.Length; ++idx)
            {
                if (curCreatePath.Length == 0)
                {
                    curCreatePath = pathArr[idx];
                }
                else
                {
                    curCreatePath = string.Format("{0}/{1}", curCreatePath, pathArr[idx]);
                }

                CreateDirectory(curCreatePath);
            }
        }
Exemple #20
0
        public void parseXml(XmlElement elem)
        {
            m_name  = ExportUtil.getXmlAttrStr(elem.Attributes["name"]);
            m_value = ExportUtil.getXmlAttrStr(elem.Attributes["value"]);
            string _opMode = ExportUtil.getXmlAttrStr(elem.Attributes["OpMode"]);

            if (XmlCondition.GREATER == _opMode)
            {
                m_opMode = AnimatorConditionMode.Greater;
            }
            else if (XmlCondition.LESS == _opMode)
            {
                m_opMode = AnimatorConditionMode.Less;
            }
            else if (XmlCondition.EQUALS == _opMode)
            {
                m_opMode = AnimatorConditionMode.Equals;
            }
            else if (XmlCondition.NOTEQUAL == _opMode)
            {
                m_opMode = AnimatorConditionMode.NotEqual;
            }
        }
Exemple #21
0
        // 从 Mesh 中添加 SubMesh
        public void addSubMesh()
        {
            List <string> pathList = new List <string>();

            pathList.Add(m_skelMeshParam.m_inPath);
            pathList.Add(m_skelMeshParam.m_name);

            // 目录一定是以 "Assets" 开头的相对目录
            string resPath = ExportUtil.getRelDataPath(UtilPath.combine(pathList.ToArray()));

            UnityEngine.Object go_ = AssetDatabase.LoadAssetAtPath(resPath, ExportUtil.convResStr2Type(m_skelMeshParam.m_resType));
            GameObject         go  = AssetDatabase.LoadAssetAtPath(resPath, ExportUtil.convResStr2Type(m_skelMeshParam.m_resType)) as GameObject;

            int                 childCount = go.transform.childCount;
            int                 idx        = 0;
            Transform           childTrans = null;
            SkinnedMeshRenderer render     = null;
            SubMesh             item       = null;

            for (idx = 0; idx < childCount; ++idx)
            {
                render     = null;
                childTrans = go.transform.GetChild(idx);
                render     = childTrans.gameObject.GetComponent <SkinnedMeshRenderer>();

                if (render != null)
                {
                    item = new SubMesh();
                    m_subMeshList.Add(item);
                    item.m_name      = childTrans.gameObject.name;
                    item.m_part      = item.m_name;
                    item.m_resType   = m_skelMeshParam.m_resType;
                    item.m_modelType = m_skelMeshParam.m_modelType;
                    item.m_outPath   = m_skelMeshParam.m_outPath;
                }
            }
        }
        public void parseXml(XmlElement elem)
        {
            m_srcRoot  = ExportUtil.getXmlAttrStr(elem.Attributes["srcroot"]);
            m_destRoot = ExportUtil.getXmlAttrStr(elem.Attributes["destroot"]);
            char[] splitChar = new char[1] {
                ','
            };
            m_unity3dExtNameList = ExportUtil.getXmlAttrStr(elem.Attributes["unity3dextname"]).Split(splitChar).ToList <string>();
            m_ignoreExtList      = ExportUtil.getXmlAttrStr(elem.Attributes["ignoreext"]).Split(splitChar).ToList <string>();

            int idx = 0;

            if (m_unity3dExtNameList.IndexOf("null") != -1)         // 如果扩展名字有 null ,就说明包括没有扩展名字
            {
                for (idx = 0; idx < m_unity3dExtNameList.Count; ++idx)
                {
                    if (m_unity3dExtNameList[idx] == "null")
                    {
                        m_unity3dExtNameList[idx] = "";
                    }
                }
            }

            if (m_ignoreExtList.IndexOf("null") != -1)         // 如果扩展名字有 null ,就说明包括没有扩展名字
            {
                for (idx = 0; idx < m_ignoreExtList.Count; ++idx)
                {
                    if (m_ignoreExtList[idx] == "null")
                    {
                        m_ignoreExtList[idx] = "";
                    }
                }
            }

            m_srcFullPath = Path.Combine(System.Environment.CurrentDirectory, m_srcRoot);
            m_srcFullPath = UtilPath.normalPath(m_srcFullPath);
        }
Exemple #23
0
        // 解析 Xml
        public void parseXml()
        {
            clear();

            string path = ExportUtil.getDataPath("Res/Config/Tool/ExportSkelAnimatorController.xml");

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(path);
            XmlNode rootNode = xmlDoc.SelectSingleNode("Root");

            XmlNodeList           controllerNodeList = rootNode.SelectNodes("Controller");
            XmlElement            controllerElem;
            XmlAnimatorController controller;

            foreach (XmlNode controllerNode in controllerNodeList)
            {
                controllerElem = (XmlElement)controllerNode;
                controller     = new XmlAnimatorController();
                //m_curXmlAnimatorController = controller;
                m_controllerList.Add(controller);
                controller.parseXml(controllerElem);
            }

            XmlNodeList pathNodeList = rootNode.SelectNodes("Path");
            XmlElement  pathElem     = null;
            XmlPath     xmlPath      = null;

            foreach (XmlNode pathNode in pathNodeList)
            {
                pathElem = (XmlElement)pathNode;
                xmlPath  = new XmlPath();
                m_xmlPathList.Add(xmlPath);
                xmlPath.parseXml(pathElem);
            }
        }
Exemple #24
0
        protected void packOneLevelPack(PackParam param)
        {
            string resPath = "";
            List<string> nameList = new List<string>();
            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()));
                nameList.Add(resPath);
            }

            StreamedSceneAssetBundleParam bundleParam = new StreamedSceneAssetBundleParam();
            bundleParam.m_levels = nameList.ToArray();
            pathList.Clear();
            pathList.Add(param.m_outPath);
            pathList.Add(m_name);
            bundleParam.m_locationPath = ExportUtil.getStreamingDataPath(ExportUtil.combine(pathList.ToArray()));

            ExportUtil.BuildStreamedSceneAssetBundle(bundleParam);
        }
Exemple #25
0
        public void parseXml(XmlElement elem)
        {
            clear();

            m_name = ExportUtil.getXmlAttrStr(elem.Attributes["name"]);
            string typeStr = ExportUtil.getXmlAttrStr(elem.Attributes["type"]);

            if (FLOAT == typeStr)
            {
                m_type = AnimatorControllerParameterType.Float;
            }
            else if (INT == typeStr)
            {
                m_type = AnimatorControllerParameterType.Int;
            }
            else if (BOOL == typeStr)
            {
                m_type = AnimatorControllerParameterType.Bool;
            }
            else if (TRIGGER == typeStr)
            {
                m_type = AnimatorControllerParameterType.Trigger;
            }
        }
Exemple #26
0
        public void packSubMesh(SkelMeshParam param)
        {
            List <string> pathList = new List <string>();

            pathList.Add(param.m_inPath);
            pathList.Add(param.m_name);

            string     resPath   = ExportUtil.getRelDataPath(ExportUtil.combine(pathList.ToArray()));
            GameObject go        = AssetDatabase.LoadAssetAtPath(resPath, ExportUtil.convResStr2Type(m_resType)) as GameObject;
            GameObject subMeshGo = null;
            //GameObject insSubMeshGo = null;

            string        subMeshName    = "";
            string        outPrefabPath  = "";
            List <Object> objList        = new List <Object>();
            List <string> assetNamesList = new List <string>();

            if (go != null)
            {
                subMeshGo = go.transform.Find(m_name).gameObject;
                if (subMeshGo != null)
                {
                    //insSubMeshGo = GameObject.Instantiate(subMeshGo);
                    //insSubMeshGo.transform.parent = null;
                    //subMeshName = ExportUtil.getSubMeshName(param.m_name, m_name);
                    subMeshName = ExportUtil.getSubMeshName(param.m_name, m_name);

                    pathList.Clear();
                    if (string.IsNullOrEmpty(m_outPath))
                    {
                        pathList.Add(SkinAnimSys.m_instance.m_xmlSubMeshRoot.m_outPath);
                    }
                    else
                    {
                        pathList.Add(m_outPath);
                    }
                    //pathList.Add(SkinAnimSys.m_instance.m_xmlSubMeshRoot.m_modelTypes.modelTypeDic[m_modelType].subPath);
                    pathList.Add(subMeshName + ".prefab");

                    outPrefabPath = ExportUtil.getRelDataPath(ExportUtil.combine(pathList.ToArray()));
                    assetNamesList.Add(outPrefabPath);
                    //AssetDatabase.CreateAsset(insSubMeshGo, tmpPrefabPath);
                    //PrefabUtility.CreatePrefab(tmpPrefabPath, insSubMeshGo);
                    PrefabUtility.CreatePrefab(outPrefabPath, subMeshGo);

                    // 现在不打包 AssetBundle ,后期才会打包成 ab
//                    objList.Add(subMeshGo);

//                    AssetBundleParam bundleParam = new AssetBundleParam();
//#if UNITY_5
//                    bundleParam.m_buildList = new AssetBundleBuild[1];
//                    bundleParam.m_buildList[0].assetBundleName = subMeshName;
//                    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(subMeshName + ".unity3d");
//                    bundleParam.m_pathName = ExportUtil.getStreamingDataPath(ExportUtil.combine(pathList.ToArray()));
//#endif

//                    ExportUtil.BuildAssetBundle(bundleParam);

                    // 释放资源
                    //UtilApi.DestroyImmediate(subMeshGo, false, false);
                    //AssetDatabase.Refresh();
                }
            }
        }
Exemple #27
0
        public string m_outPath;       // 输出目录

        public void parseXml(XmlElement elem)
        {
            m_name = ExportUtil.getXmlAttrStr(elem.Attributes["name"]);
            m_part = ExportUtil.getXmlAttrStr(elem.Attributes["part"]);
        }
        // 遍历一个文件的时候处理
        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);
            }
        }
Exemple #29
0
        static public void exportTypt()
        {
            string _path;

            byte[] bytes = null;
            Dictionary <string, bool> namespaceDic = new Dictionary <string, bool>();
            string namespaceStr = "";

            // 打开写入的文件
            _path = ExportUtil.getDataPath("Editor/BindLua.cs");
            FileStream fileStream;

            if (File.Exists(@_path))
            {
                File.Delete(@_path);
            }

            fileStream = new FileStream(_path, FileMode.Create);

            // 遍历类型
            string bindTypeInfo = "";

            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type _type in assembly.GetTypes())
                {
                    if (bNeedExportNS(_type.Namespace))
                    {
                        // 如果是模板类型,名字是 "DynamicBuffer`1",但是 Type.MemberType == MemberTypes.TypeInfo
                        // 如果是内部类,那么 Type.MemberType == MemberTypes.NestedType
                        // 如果是协程(Coroutine),例如 protected IEnumerator initAssetByCoroutine(),Type.MemberType == MemberTypes.NestedType
                        // 去掉模板类、内部类、协程、接口、抽象类
                        // 抽象类导致 ToLuaExport.cs 导出的 bind 文件编译不过
                        // 函数中有模板类, 导致 ToLuaExport.cs 宕机。 static public void newRectSplit(Transform trans, float unitWidth, float areaRadius, float fYDelta, int splitCnt, ref List<Vector3> posList)
                        if (!_type.Name.Contains("`1") &&
                            _type.MemberType == MemberTypes.TypeInfo &&
                            !_type.IsInterface &&
                            !_type.IsAbstract)
                        {
                            if (!bNeedExportClassName(_type.Name))
                            {
                                continue;
                            }

                            if (!namespaceDic.ContainsKey(_type.Namespace))
                            {
                                namespaceDic[_type.Namespace] = true;
                                namespaceStr += string.Format("using {0};\r\n", _type.Namespace);
                            }

                            bindTypeInfo += string.Format("         _GT(typeof({0})),\r\n", _type.Name);
                        }
                    }
                }
            }

            // 写入名字空间
            bytes = Encoding.UTF8.GetBytes(namespaceStr);
            fileStream.Write(bytes, 0, bytes.Length);

            // 首先写入文件前半部分
            _path = ExportUtil.getDataPath("Editor/ExportLuaBind/BindLuaCsOne.txt");
            bytes = File.ReadAllBytes(_path);
            fileStream.Write(bytes, 0, bytes.Length);

            // 写入文件类型
            bytes = Encoding.UTF8.GetBytes(bindTypeInfo);
            fileStream.Write(bytes, 0, bytes.Length);

            // 写入文件后半部分
            _path = ExportUtil.getDataPath("Editor/ExportLuaBind/BindLuaCsTwo.txt");
            bytes = File.ReadAllBytes(_path);
            fileStream.Write(bytes, 0, bytes.Length);

            fileStream.Close();
            fileStream.Dispose();
            fileStream = null;
        }
        protected void addMesh()
        {
            string fullPath = ExportUtil.getDataPath(m_inPath);

            UtilPath.traverseFilesInOneDir(fullPath, onFindOneFile);
        }