Esempio n. 1
0
        protected void LoadData(string name, AssetBundle bundle, Object resObj, System.Object userData)
        {
            IsLoaded = true;

            string strData = "";

            if (bundle != null)
            {
                Object    obj  = bundle.mainAsset;
                TextAsset text = obj as TextAsset;
                strData = CommonTool.BytesToUtf8(text.bytes);
                Resources.UnloadAsset(text);
                //strData = ta.text;
            }
            else
            {
                TextAsset text = resObj as TextAsset;
                if (text != null)
                {
                    strData = CommonTool.BytesToUtf8(text.bytes);
                    Resources.UnloadAsset(text);
                }
                else
                {
                    GameDebug.LogError("db file load fail:" + name);
                }
            }

            if (strData != "")
            {
                ParseData(strData);
            }
        }
Esempio n. 2
0
        public override void Load()
        {
            string path = PathHelp.GetFullPaltformPath(mStrPath, false);

            if (System.IO.File.Exists(path))
            {
                System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.Open);
                if (stream != null)
                {
                    byte[] content = new byte[stream.Length];
                    stream.Read(content, 0, (int)stream.Length);

                    IsLoaded = true;

                    string strData = CommonTool.BytesToUtf8(content);
                    ParseData(strData);
                    stream.Close();
                }
            }
        }
Esempio n. 3
0
        public override void Load()
        {
#if UNITY_EDITOR
            string resName = DBManager.AssetsResPath + "/" + mStrPath;

            TextAsset textObj = EditorResourceLoader.LoadAssetAtPath(resName, typeof(TextAsset)) as TextAsset;
            if (textObj != null)
            {
                string strData = CommonTool.BytesToUtf8(textObj.bytes);
                if (strData != "")
                {
                    ParseData(strData);
                }

                IsLoaded = true;
            }
            else
            {
                GameDebug.LogError("DB file load failed: " + mStrPath);
            }
#else
            AssetBundle db_bundle = DBManager.GetInstance().DBBundle;
            if (db_bundle != null)
            {
                string fileName = Path.GetFileNameWithoutExtension(mStrPath);
                Object resObj   = db_bundle.LoadAsset(fileName);

                TextAsset text = resObj as TextAsset;
                if (text != null)
                {
                    string strData = CommonTool.BytesToUtf8(text.bytes);
                    if (strData != "")
                    {
                        ParseData(strData);
                    }

                    IsLoaded = true;
                    Resources.UnloadAsset(text);
                }
                else
                {
                    GameDebug.LogError("DB file load failed: " + mStrPath);
                }
            }
            else
            {
                GameDebug.LogError("DB asset is null!!!");
            }
#endif

            /*AssetManager manager = Game.GetInstance().MainInterface.GetAssetManager();
             * if (manager== null)
             * {
             *      GameDebug.LogError("No AssetManager!");
             *      return;
             * }*/

            /*if (xc.Game.GetInstance().IsUsePackage() || Application.platform != RuntimePlatform.WindowsPlayer)
             * {
             *      string path = mStrPath;
             *      //string ext = Path.GetExtension(mStrPath).ToLower();
             *      manager.LoadAsset(path, LoadData);
             * }
             * else
             * {
             *      string path = "";
             *      string nameNoExtend = PathHelp.GetPathWithNoExtend(mStrPath);
             *
             *      path = "Resources/" + mStrPath;
             *      path = PathHelp.GetFullPaltformPath(path, false);
             *
             *      System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.Open);
             *      byte[] content = new byte[stream.Length];
             *      stream.Read(content, 0, (int)stream.Length);
             *
             *      IsLoaded = true;
             *
             *      string strData = AssetManager.BinToUtf8(content);
             *      ParseData(strData);
             *      stream.Close();
             * }*/
        }