Exemple #1
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(ExportUtil.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;
                }
            }
        }
Exemple #2
0
        public void parseXml(XmlElement elem)
        {
            m_skelMeshParam.m_name = ExportUtil.getXmlAttrStr(elem.Attributes["name"]);
            m_skelMeshParam.m_inPath = ExportUtil.getXmlAttrStr(elem.Attributes["inpath"]);
            m_skelMeshParam.m_outPath = ExportUtil.getXmlAttrStr(elem.Attributes["outpath"]);
            m_skelMeshParam.m_resType = ExportUtil.getXmlAttrStr(elem.Attributes["restype"]);
            m_skelMeshParam.m_modelType = (eModelType)ExportUtil.getXmlAttrInt(elem.Attributes["modeltype"]);
            m_skelMeshParam.m_controllerPath = ExportUtil.getXmlAttrStr(elem.Attributes["controllerpath"]);

            XmlNodeList itemNodeList = elem.ChildNodes;
            XmlElement itemElem;
            SubMesh item;

            foreach (XmlNode itemNode in itemNodeList)
            {
                itemElem = (XmlElement)itemNode;
                item = new SubMesh();
                
                m_subMeshList.Add(item);
                item.parseXml(itemElem);
                item.m_resType = m_skelMeshParam.m_resType;
                item.m_modelType = m_skelMeshParam.m_modelType;
                item.m_outPath = m_skelMeshParam.m_outPath;
            }
        }