Exemple #1
0
        /**
         * @language zh_CN
         * 加载、解析并添加贴图集数据。
         * @param path 贴图集数据在 Resources 中的路径。(其他形式的加载可自行扩展,使用 factory.ParseTextureAtlasData(JSONObject, Material))
         * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
         * @param scale 为贴图集设置一个缩放值。
         * @returns 贴图集数据
         * @see #ParseTextureAtlasData()
         * @see #GetTextureAtlasData()
         * @see #AddTextureAtlasData()
         * @see #RemoveTextureAtlasData()
         * @see DragonBones.UnityTextureAtlasData
         */
        public UnityTextureAtlasData LoadTextureAtlasData(string path, string name = null, float scale = 0.0f)
        {
            var index = path.LastIndexOf("Assets/");

            if (index > -1)
            {
                path = path.Substring(index + 7);
            }

            //index = path.LastIndexOf(".");
            //if (index > 0)
            //{
            //    path = path.Substring(0, index);
            //}

            UnityTextureAtlasData textureAtlasData = null;

            if (_pathTextureAtlasDataMap.ContainsKey(path))
            {
                textureAtlasData = _pathTextureAtlasDataMap[path] as UnityTextureAtlasData;
                _refreshTextureAtlas(textureAtlasData);
            }
            else
            {
                _textureAtlasPath = path;
                TextAsset ta = CAssetManager.GetAsset(path) as TextAsset;
                textureAtlasData = LoadTextureAtlasData(ta, name, scale);
                if (textureAtlasData != null)
                {
                    _pathTextureAtlasDataMap[path] = textureAtlasData;
                }
            }

            return(textureAtlasData);
        }
Exemple #2
0
    static int GetAsset(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                string             arg0 = ToLua.CheckString(L, 1);
                UnityEngine.Object o    = CAssetManager.GetAsset(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2)
            {
                string             arg0 = ToLua.CheckString(L, 1);
                System.Type        arg1 = ToLua.CheckMonoType(L, 2);
                UnityEngine.Object o    = CAssetManager.GetAsset(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: CAssetManager.GetAsset"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemple #3
0
        /**
         * @language zh_CN
         * 加载、解析并添加龙骨数据。
         * @param path 龙骨数据在 Resources 中的路径。(其他形式的加载可自行扩展)
         * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
         * @param scale 为所有骨架设置一个缩放值。
         * @returns 龙骨数据
         * @see #ParseDragonBonesData()
         * @see #GetDragonBonesData()
         * @see #AddDragonBonesData()
         * @see #RemoveDragonBonesData()
         * @see DragonBones.DragonBonesData
         */
        public DragonBonesData LoadDragonBonesData(string path, string name = null, float scale = 0.01f)
        {
            var index = path.LastIndexOf("Assets/");

            if (index > -1)
            {
                path = path.Substring(index + 7);
            }

            //index = path.LastIndexOf(".");
            //if (index > 0)
            //{
            //    path = path.Substring(0, index);
            //}

            if (_pathDragonBonesDataMap.ContainsKey(path))
            {
                return(_pathDragonBonesDataMap[path]);
            }
            TextAsset ta = CAssetManager.GetAsset(path) as TextAsset;
            var       dragonBonesData = LoadDragonBonesData(ta, name);

            if (dragonBonesData != null)
            {
                _pathDragonBonesDataMap[path] = dragonBonesData;
            }

            return(dragonBonesData);
        }
Exemple #4
0
    public static Dictionary <string, string> m_taskMap     = new Dictionary <string, string>(); //任务配置里面的文字

    public static void Initialize()
    {
        //加载模板文字
        TextAsset   xmlAsset = CAssetManager.GetAsset("config/language/lang_tpl.xml", typeof(TextAsset)) as TextAsset; //Resources.Load<TextAsset>("config/language/lang_tpl");
        XmlDocument xmlDoc   = new XmlDocument();

        xmlDoc.LoadXml(xmlAsset.text);

        XmlNode xmlData = xmlDoc.SelectSingleNode("/root/data");

        if (xmlData != null)
        {
            foreach (XmlElement dor in xmlData.ChildNodes)
            {
                m_tplMap.Add(dor.Attributes["id"].Value, dor.Attributes["str"].Value);
            }
        }

        //加载错误码
        //xmlAsset = Resources.Load<TextAsset>("config/language/errorcode");
        xmlAsset = CAssetManager.GetAsset("config/language/errorcode.xml", typeof(TextAsset)) as TextAsset;
        XmlDocument xmlDoc1 = new XmlDocument();

        xmlDoc1.LoadXml(xmlAsset.text);

        XmlNode xmlData1 = xmlDoc1.SelectSingleNode("/errorcode");

        if (xmlData1 != null)
        {
            foreach (XmlElement dor in xmlData1.ChildNodes)
            {
                if (!m_errorMap.ContainsKey(dor.Attributes["id"].Value))
                {
                    m_errorMap.Add(dor.Attributes["id"].Value, dor.Attributes["text"].Value);
                }
            }
        }

        ////加载任务文字
        //xmlAsset = Resources.Load<TextAsset>("config/language/task_txt");
        //XmlDocument xmlDoc2 = new XmlDocument();
        //xmlDoc2.LoadXml(xmlAsset.text);
        //XmlNode xmlData2 = xmlDoc2.SelectSingleNode("/data");
        //if (xmlData2 != null)
        //{
        //    foreach (XmlElement dor in xmlData2.ChildNodes)
        //    {
        //        m_taskMap.Add(dor.Attributes["id"].Value, dor.Attributes["str"].Value);
        //    }
        //}

        InitLanguageData();
        //InitConfigLanguage();
    }
Exemple #5
0
    public static string LoadXml(string strXmlPath)
    {
        //TextAsset xmlAsset = Resources.Load<TextAsset>(strXmlPath);
        TextAsset xmlAsset = CAssetManager.GetAsset(strXmlPath + ".xml", typeof(TextAsset)) as TextAsset;

        if (xmlAsset == null)
        {
            return("");
        }

        return(LoadXmlForText(xmlAsset.text));
    }
Exemple #6
0
        /**
         * @private
         */
        protected void _refreshTextureAtlas(UnityTextureAtlasData textureAtlasData)
        {
            if (textureAtlasData.texture == null)
            {
                //Texture2D textureAtlas = Resources.Load<Texture2D>(textureAtlasData.imagePath);
                Texture2D textureAtlas = CAssetManager.GetAsset(textureAtlasData.imagePath) as Texture2D;
                var       shader       = Shader.Find(defaultShaderName);
                var       material     = new Material(shader);
                material.mainTexture = textureAtlas;

                textureAtlasData.texture = material;
            }
        }
Exemple #7
0
    // 语言配置文件加载
    public static void InitLanguageData()
    {
        TextAsset   xmlAsset = CAssetManager.GetAsset("config/language/languagedata.xml", typeof(TextAsset)) as TextAsset; //Resources.Load<TextAsset>("config/language/languagedata");
        XmlDocument xmlDoc1  = new XmlDocument();

        xmlDoc1.LoadXml(xmlAsset.text);

        XmlNode xmlData1 = xmlDoc1.SelectSingleNode("/data");

        if (xmlData1 != null)
        {
            foreach (XmlElement dor in xmlData1.ChildNodes)
            {
                if (!m_languageMap.ContainsKey(dor.Attributes["id"].Value))
                {
                    m_languageMap.Add(dor.Attributes["id"].Value, dor.Attributes["str"].Value);
                }
            }
        }
    }