using System; using UnityEngine; using UnityEngine.Events; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Xml; using assetBundleUtility; using DragonBones; #if UNITY_EDITOR using UnityEditor; #endif using Debug = UnityEngine.Debug; using Object = UnityEngine.Object; public class Bundle : MonoBehaviour { #region public static string version = "1_3_7"; public static bool CopyComplete { get { return CopyCount == 0; } } public static bool UpdateComplete; //public static AssetBundle NewDressConfig; public static AssetBundle NewDressSke; public static AssetBundle NewDressTex; //public static AssetBundle NewLanguage; //public static AssetBundle NewFlowerConfig; public static AssetBundle NewFlowerTex; //public static List NewDressroomConfigs = new List(); //public static List NewFlowerConfigs = new List(); public static List HotUpdateAssetBundleNames=new List { ResourceLabel.Config, //ResourceLabel.NewDressConfig, ResourceLabel.NewDressSke, ResourceLabel.NewDressTex, //ResourceLabel.NewLanguage, //ResourceLabel.NewFlowerConfig, ResourceLabel.NewFlowerTex, }; //public List NewDressConfigList; public List NewDressSkeList; public List NewDressTexList; public List NewDressTexConfigList; public List NewDressSpriteList; //public List NewLanguageList; //public List NewFlowerConfigList; public List NewFlowerSpriteList; public static Bundle Instance; public static bool Complete; public static AssetBundle Atlas; public static AssetBundle Atlas2; public static AssetBundle Defaul; public static AssetBundle UI; public static AssetBundle Effect; public static AssetBundle Audio; public static AssetBundle Scene; public static AssetBundle Config; public static AssetBundle Discard; public static AssetBundle PlazaRoom; public Texture2D AtlasTexture; public Texture2D ExpressionTexture; public List DefaultList; public List UiList; public List AtlasList; public List Atlas2List; public List EffectList; public List AudioList; public List SceneList; public List ConfigList; public List DiscardList; public List PlazaRoomList; #endregion public void Begin() { Instance = this; LoadAll ( () => Complete = true ); } public static T Load(string goName, Folder folder) where T : Object { if (Initializer.Instance.DebugMode) { #region MyRegion if (folder == Folder.UI) { for (int i = 0; i < Instance.UiList.Count; i++) { if (Instance.UiList[i].name == goName) { return (T) Instance.UiList[i]; } } } if (folder == Folder.Default) { for (int i = 0; i < Instance.DefaultList.Count; i++) { if (Instance.DefaultList[i].name == goName) { return (T)Instance.DefaultList[i]; } } } else if (folder == Folder.Audio) { for (int i = 0; i < Instance.AudioList.Count; i++) { if (Instance.AudioList[i].name == goName) { return (T) Instance.AudioList[i]; } } } else if (folder == Folder.Config) { for (int i = 0; i < Instance.ConfigList.Count; i++) { if (Instance.ConfigList[i].name == goName) { return (T) Instance.ConfigList[i]; } } } else if (folder == Folder.Effect) { for (int i = 0; i < Instance.EffectList.Count; i++) { if (Instance.EffectList[i].name == goName) { return (T) Instance.EffectList[i]; } } } else if (folder == Folder.Scene) { if (goName == "Expression") { return (T) (Object) Sprite.Create(Instance.ExpressionTexture, new Rect(0, 0, Instance.AtlasTexture.width, Instance.AtlasTexture.height), new Vector2(0.5f, 0.5f)); } for (int i = 0; i < Instance.SceneList.Count; i++) { if (Instance.SceneList[i].name == goName) { return (T) Instance.SceneList[i]; } } } else if (folder == Folder.Discard) { for (int i = 0; i < Instance.DiscardList.Count; i++) { if (Instance.DiscardList[i].name == goName) { return (T) Instance.DiscardList[i]; } } } else if (folder == Folder.Atlas) { if (goName == "Atlas") { return (T) (Object) Sprite.Create(Instance.AtlasTexture, new Rect(0, 0, Instance.AtlasTexture.width, Instance.AtlasTexture.height), new Vector2(0.5f, 0.5f)); } for (int i = 0; i < Instance.AtlasList.Count; i++) { if (Instance.AtlasList[i].name == goName) { return (T) Instance.AtlasList[i]; } } } else if (folder == Folder.PlazaRoom) { for (int i = 0; i < Instance.PlazaRoomList.Count; i++) { if (Instance.PlazaRoomList[i].name == goName) { return (T) Instance.PlazaRoomList[i]; } } } //else if (folder == Folder.Dress) //{ // for (int i = 0; i < Instance.DressList.Count; i++) // { // if (Instance.DressList[i].name == goName) // { // return (T)Instance.DressList[i]; // } // } //} #endregion } else { #region MyRegion if (folder == Folder.UI) { return UI.LoadAsset(goName); } else if (folder == Folder.Audio) { return Audio.LoadAsset(goName); } else if (folder == Folder.Default) { return Defaul.LoadAsset(goName); } else if (folder == Folder.Config) { return Config.LoadAsset(goName); } else if (folder == Folder.Effect) { return Effect.LoadAsset(goName); } else if (folder == Folder.Scene) { return Scene.LoadAsset(goName); } else if (folder == Folder.Atlas) { return Atlas.LoadAsset(goName); } else if (folder == Folder.Atlas2) { return Atlas2.LoadAsset(goName); } else if (folder == Folder.Discard) { return Discard.LoadAsset(goName); } else if (folder == Folder.PlazaRoom) { return PlazaRoom.LoadAsset(goName); } #endregion } DebugManager.Log(goName + " " + folder); throw new Exception(goName + " " + folder); } public static void LoadAtlasSprites() { if (Initializer.Instance.DebugMode) { for (int i = 0; i < Instance.Atlas2List.Count; i++) { ResourceManager.ObjectDictionary.UniqueAdd(Instance.Atlas2List[i].name, Instance.Atlas2List[i]); } #if UNITY_EDITOR List objects = new List(); string assetPath = AssetDatabase.GetAssetPath(ResourceManager.Load("stand_texture_0", Folder.Scene)); objects.AddRange(AssetDatabase.LoadAllAssetsAtPath(assetPath)); assetPath = AssetDatabase.GetAssetPath(ResourceManager.Load("stand_texture_1", Folder.Scene)); objects.AddRange(AssetDatabase.LoadAllAssetsAtPath(assetPath)); for (int i = 0; i < objects.Count; i++) { Sprite sprite = objects[i] as Sprite; if (sprite != null) { PlayerManager.CloseSpriteDictionary.Add(sprite.name, sprite); ResourceManager.ObjectDictionary.UniqueAdd(sprite.name, sprite); } } #endif } else { #region MyRegion Sprite[] sprites = Atlas2.LoadAllAssets(); for (int i = 0; i < sprites.Length; i++) { ResourceManager.ObjectDictionary.UniqueAdd(sprites[i].name, sprites[i]); } sprites = Atlas.LoadAllAssets(); for (int i = 0; i < sprites.Length; i++) { ResourceManager.ObjectDictionary.UniqueAdd(sprites[i].name, sprites[i]); } sprites = Scene.LoadAssetWithSubAssets("FlowerItemAtlas1"); for (int i = 0; i < sprites.Length; i++) { ResourceManager.ObjectDictionary.UniqueAdd(sprites[i].name, sprites[i]); } List objects = new List(); objects.AddRange(Scene.LoadAssetWithSubAssets("stand_texture_0", typeof(Sprite))); objects.AddRange(Scene.LoadAssetWithSubAssets("stand_texture_1", typeof(Sprite))); for (int i = 0; i < objects.Count; i++) { Sprite sprite = (Sprite) objects[i]; PlayerManager.CloseSpriteDictionary.Add(sprite.name, sprite); ResourceManager.SpriteDictionary.UniqueAdd(sprite.name, sprite); } #endregion } } //public static void LoadAllDressBundleAssetsIntoDragonbone() //{ // UnityFactory.factory.LoadDragonBonesData(ResourceManager.Load(DressLabel.Dress_ske, Folder.Dress)); // foreach (var dressName in DressLabel.dressNames) // { // ResourceManager.Load(dressName, Folder.Dress); // UnityFactory.factory.LoadTextureAtlasData(ResourceManager.Load(dressName + "_tex", Folder.Dress), dressName); // } // Sprite[] sprites = Dress.LoadAllAssets(); // if (Initializer.Instance.DebugMode) // { // for (int i = 0; i < Instance.DressList.Count; i++) // { // Sprite sprite = Instance.DressList[i] as Sprite; // if (sprite != null) // { // PlayerManager.CloseSpriteDictionary.Add(sprite.name, sprite); // ResourceManager.ObjectDictionary.UniqueAdd(sprite.name, sprite); // } // } // } // else // { // for (int i = 0; i < sprites.Length; i++) // { // PlayerManager.CloseSpriteDictionary.Add(sprites[i].name, sprites[i]); // ResourceManager.ObjectDictionary.UniqueAdd(sprites[i].name, sprites[i]); // } // } //} public static AssetBundleRequest LoadAsync(string goName, Folder folder) { if (folder == Folder.UI) { return UI.LoadAssetAsync(goName); } else if (folder == Folder.Audio) { return Audio.LoadAssetAsync(goName); } else if (folder == Folder.Default) { return Defaul.LoadAssetAsync(goName); } else if (folder == Folder.Config) { return Config.LoadAssetAsync(goName); } else if (folder == Folder.Effect) { return Effect.LoadAssetAsync(goName); } else if (folder == Folder.Scene) { return Scene.LoadAssetAsync(goName); } else if (folder == Folder.Atlas) { return Atlas.LoadAssetAsync(goName); } else if (folder == Folder.Discard) { return Discard.LoadAssetAsync(goName); } else { throw new Exception(); } } public static AssetBundleRequest LoadAllAsync(Folder folder) { if (folder == Folder.Atlas2) { return Atlas2.LoadAllAssetsAsync(); } else { throw new Exception(); } } public static string GetStreamPath() { if (Application.isEditor) // return "file://" + System.Environment.CurrentDirectory.Replace("\\", "/"); // Use the build output folder directly. return "file://" + Application.streamingAssetsPath + "/Bundle/Windows/"; //user local stream //else if (Application.isWebPlayer) // return System.IO.Path.GetDirectoryName(Application.absoluteURL).Replace("\\", "/") + "/StreamingAssets"; else if (Application.platform == RuntimePlatform.IPhonePlayer) return "file://" + Application.streamingAssetsPath + "/Bundle/IOS/"; else if (Application.isMobilePlatform || Application.isConsolePlatform) return Application.streamingAssetsPath + "/Bundle/Android/"; else // For standalone player. return "file://" + Application.streamingAssetsPath; //return "file://" + Application.streamingAssetsPath + "/Bundle/Windows/"; } public static string GetPersistingPath() { if (Application.platform == RuntimePlatform.IPhonePlayer) return "file://" + Application.persistentDataPath; else if (Application.isMobilePlatform) return Application.streamingAssetsPath; else return "file://" + Application.persistentDataPath; } public static string GetStreamingUrlPath() { if (Application.platform == RuntimePlatform.IPhonePlayer) return "file://" + Application.streamingAssetsPath; else if (Application.isMobilePlatform) return Application.streamingAssetsPath; else return "file://" + Application.streamingAssetsPath; } public void LoadAll(UnityAction callback) { Initializer.Instance.StartCoroutine(ILoadAll(callback)); } public static IEnumerator ILoadAll(UnityAction callback) { yield return LoadDefaul(); if (!Logo.Complete && !Initializer.Instance.DebugMode) { ResourceManager.AddAsyncLoad(ResourceLabel.PlayerConfig, Folder.Default, () => { ConfigManager.ConfigDocument = ConfigManager.ConfigDocument; HttpManager.GetBuyPackLimitFlag(); }); } else { ConfigManager.ConfigDocument = ConfigManager.ConfigDocument; HttpManager.GetBuyPackLimitFlag(); } //yield return LoadDiscard(); yield return LoadUI(); //if (!Logo.Complete && !Initializer.Instance.DebugMode) //{ // ResourceManager.AddAsyncLoad(ResourceLabel.Canvas, 1, Folder.UI, ObjType.Canvas); // //ResourceManager.AddAsyncLoad(ResourceLabel.GroupA, 1, Folder.UI, ObjType.GroupA, true); // //ResourceManager.AddAsyncLoad(ResourceLabel.GroupB, 1, Folder.UI, ObjType.GroupB, true); // //ResourceManager.AddAsyncLoad(ResourceLabel.GroupC, 1, Folder.UI, ObjType.GroupC, true); // //ResourceManager.AddAsyncLoad(ResourceLabel.GroupE, 1, Folder.UI, ObjType.GroupE, true); // //ResourceManager.AddAsyncLoad(ResourceLabel.GroupD, 1, Folder.UI, ObjType.GroupD, true); // ResourceManager.AddAsyncLoad(ResourceLabel.EventSystem, 1, Folder.UI, ObjType.EventSystem); // ResourceManager.AddAsyncLoad(ResourceLabel.MainCamera, 1, Folder.UI, ObjType.MainCamera); // //ResourceManager.AddAsyncLoad("SkillItem", 31, Folder.UI, ObjType.SkillItem, true); // //ResourceManager.AddAsyncLoad("SignItem", 21, Folder.UI, ObjType.SignItem, true); // //ResourceManager.AddAsyncLoad("FlowerItem", 17, Folder.UI, ObjType.FlowerItem, true); // //ResourceManager.AddAsyncLoad("AchieveItem", 2, Folder.UI, ObjType.AchieveItem, true); //} yield return LoadScene(); //if (!Logo.Complete && !Initializer.Instance.DebugMode) //{ // ResourceManager.AddAsyncLoad(ResourceLabel.Flower, 9, Folder.Scene, ObjType.Flower); // ResourceManager.AddAsyncLoad(ResourceLabel.Page, 2, Folder.Scene, ObjType.SlotPage); // ResourceManager.AddAsyncLoad(ResourceLabel.Garden, 1, Folder.Scene, ObjType.Garden); // ResourceManager.AddAsyncLoad(ResourceLabel.DressRoom, 1, Folder.UI, ObjType.DressRoom); //} yield return LoadAudio(); //if (!Logo.Complete && !Initializer.Instance.DebugMode) //{ // ResourceManager.AddAsyncLoad(ResourceLabel.Music, 1, Folder.Audio, ObjType.Music); //} yield return LoadAtlas2(); //if (!Logo.Complete && !Initializer.Instance.DebugMode) //{ // ResourceManager.AddAsyncLoad(ResourceLabel.SkillConfig, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.PackConfig, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.AbilityConfig, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.AchieveConfig, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.VisitConfig, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.AwardConfig, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.FlowerConfig, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.OfflineConfig, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.SigninConfig, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.DressroomConfig, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.English, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.ChineseSimplified, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.ChineseTraditional, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.BtnClip, Folder.Audio); // ResourceManager.AddAsyncLoad(ResourceLabel.SkillClip, Folder.Audio); // ResourceManager.AddAsyncLoad(ResourceLabel.ErrorClip, Folder.Audio); // ResourceManager.AddAsyncLoad(ResourceLabel.DropClip, Folder.Audio); // ResourceManager.AddAsyncLoad(ResourceLabel.CloseClip, Folder.Audio); // ResourceManager.AddAsyncLoad(ResourceLabel.FlowerClip, Folder.Audio); // ResourceManager.AddAsyncLoad(ResourceLabel.BubbleClip, Folder.Audio); // ResourceManager.AddAsyncLoad(ResourceLabel.CurrentClip, Folder.Audio); // ResourceManager.AddAsyncLoad(ResourceLabel.MiniEndClip, Folder.Audio); // ResourceManager.AddAsyncLoad(ResourceLabel.StandTex, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.StandSke, Folder.Config); // ResourceManager.AddAsyncLoad(ResourceLabel.StandTexture, Folder.Scene); //} yield return LoadAtlas(); yield return LoadEffect(); SpriteAsset.AddAllBundleSpriteInfo(); if (callback != null) { callback.Invoke(); } } public static IEnumerator LoadUI() { WWW www = new WWW(GetStreamPath() + "ui"); yield return www; if (string.IsNullOrEmpty(www.error)) { UI = www.assetBundle; } else { Debug.Log(www.error); } } public static IEnumerator LoadAtlas() { WWW www = new WWW(GetStreamPath() + "atlas"); yield return www; if (string.IsNullOrEmpty(www.error)) { Atlas = www.assetBundle; } else { Debug.Log(www.error); } } public static IEnumerator LoadAtlas2() { WWW www = new WWW(GetStreamPath() + "atlas2"); yield return www; if (string.IsNullOrEmpty(www.error)) { Atlas2 = www.assetBundle; } else { Debug.Log(www.error); } } public static IEnumerator LoadAudio() { WWW www = new WWW(GetStreamPath() + "audio"); yield return www; if (string.IsNullOrEmpty(www.error)) { Audio = www.assetBundle; } else { Debug.Log(www.error); } } public static IEnumerator LoadDefaul() { WWW www = new WWW(GetStreamPath() + "default"); yield return www; if (string.IsNullOrEmpty(www.error)) { Defaul = www.assetBundle; } else { Debug.Log(www.error); } } public static IEnumerator LoadEffect() { WWW www = new WWW(GetStreamPath() + "effect"); yield return www; if (string.IsNullOrEmpty(www.error)) { Effect = www.assetBundle; } else { Debug.Log(www.error); } } public static IEnumerator LoadScene() { WWW www = new WWW(GetStreamPath() + "scene"); yield return www; if (string.IsNullOrEmpty(www.error)) { Scene = www.assetBundle; } else { Debug.Log(www.error); } } public static IEnumerator LoadDiscard() { WWW www = new WWW(GetStreamPath() + "discard"); yield return www; if (string.IsNullOrEmpty(www.error)) { Discard = www.assetBundle; } else { Debug.Log(www.error); } } public static IEnumerator LoadPlazaRoom() { WWW www = new WWW(GetStreamPath() + "plazaroom"); yield return www; if (string.IsNullOrEmpty(www.error)) { PlazaRoom = www.assetBundle; } else { Debug.Log(www.error); } } private static int CopyCount = 0; public static void CopyAssetBundles() { string persistentFolderPath = string.Format("{0}{1}HotUpdate", Application.persistentDataPath, Path.DirectorySeparatorChar); if (!Directory.Exists(persistentFolderPath)) { Directory.CreateDirectory(persistentFolderPath); } string streamingFolder; if (Application.platform == RuntimePlatform.IPhonePlayer) { streamingFolder = "IOS"; } else if (Application.platform == RuntimePlatform.Android) { streamingFolder = "Android"; } else { streamingFolder = "Windows"; } foreach (var assetBundleName in HotUpdateAssetBundleNames) { if (!File.Exists(persistentFolderPath + Path.DirectorySeparatorChar + assetBundleName)) { CopyCount++; Initializer.Instance.StartCoroutine ( LoadAssetBundleFromStream ( streamingFolder, assetBundleName, www => { File.WriteAllBytes(persistentFolderPath + Path.DirectorySeparatorChar + assetBundleName, www.bytes); CopyOneAssetBundleFinish(); } ) ); } } } private static void CopyOneAssetBundleFinish() { CopyCount--; } public static IEnumerator LoadAssetBundleFromStream(string folder, string name, Action callback) { WWW www = new WWW(GetStreamingUrlPath() + Path.DirectorySeparatorChar + "Bundle" + Path.DirectorySeparatorChar + folder + Path.DirectorySeparatorChar + "HotUpdate" + Path.DirectorySeparatorChar + name); yield return www; if (string.IsNullOrEmpty(www.error)) { callback.Invoke(www); } else { Debug.Log(www.error); Initializer.DebugText.text = www.error; Initializer.DebugText.SetActive(true); Initializer.DebugText.enabled = true; } } public static int UpdateAmt; public static int UpdateFinishAmt; public static bool UpdateAssetBundles() { //Debug.Log(HttpManager.Md5); //Debug.Log(HttpManager.Md5Dictionnary); //Debug.Log(HttpManager.AssetbundleUrl); try { Initializer.DebugText.text = "U0"; if (Initializer.Instance.DebugMode) { SkipUpdateForDebugMode(); return false; } Initializer.DebugText.text = "U1"; string persistentFolderPath = string.Format("{0}{1}HotUpdate", Application.persistentDataPath, Path.DirectorySeparatorChar); Initializer.DebugText.text = "U2"; List assetBundleSets = AssetBundleUtility.GetAssetBundleSetsFromFolders ( persistentFolderPath ); Initializer.DebugText.text = "U3"; string localMD5 = AssetBundleUtility.GetMD5OfAssetBundleSets(assetBundleSets); bool needUpdate; if (string.IsNullOrEmpty(HttpManager.Md5) || string.IsNullOrEmpty(HttpManager.Md5Dictionnary) || string.IsNullOrEmpty(HttpManager.AssetbundleUrl)) { needUpdate = false; Debug.LogWarning(string.Format("NeedUpdate : {0} connection error", needUpdate)); } else { //Debug.Log(localMD5); //Debug.Log(HttpManager.Md5); needUpdate = localMD5 != HttpManager.Md5; Debug.LogWarning(string.Format("NeedUpdate : {0}", needUpdate)); } //if (Application.isEditor || Application.isMobilePlatform) //{ // needUpdate = false; //} AssetBundleUtility.OnDownloadOrUpdateFinish += FinishDownloadAndLoad; if (needUpdate) { Initializer.DebugText.text = "U4"; UpdateAmt = AssetBundleUtility.UpdateAllAssetBundle ( HttpManager.Md5Dictionnary, persistentFolderPath, assetBundleSets, DownloadAllAssetBundleSucceed, DownloadAllAssetBundleFailed, DownloadAssetBundleSucceed, DownloadAssetBundleFailed ); UpdatePanel.Show(); UpdatePanel.SetProgress(UpdateAmt, 0); } else { Initializer.DebugText.text = "U5"; AssetBundleUtility.LoadAllAssetBundle ( assetBundleSets, DownloadAllAssetBundleSucceed, DownloadAllAssetBundleFailed, DownloadAssetBundleSucceed, DownloadAssetBundleFailed ); } return false; } catch (Exception e) { Initializer.EnableDebugLab(); Initializer.DebugText.text = e.ToString(); return true; } } private static void FinishDownloadAndLoad() { try { Initializer.DebugText.text = "01"; //NewDressroomConfigs = ConfigManager.GetDressRoomConfig(NewDressConfig.LoadAsset(ResourceLabel.NewDressroomConfig)); Initializer.DebugText.text = "02"; TextAsset[] textAssets = NewDressSke.LoadAllAssets(); foreach (var textAsset in textAssets) { UnityFactory.factory.LoadDragonBonesData(textAsset); } Initializer.DebugText.text = "03"; textAssets = NewDressTex.LoadAllAssets(); Texture2D[] textures = NewDressTex.LoadAllAssets(); for (int i = 0; i < textAssets.Length; i++) { ResourceManager.ObjectDictionary.Add(textures[i].name, textures[i]); UnityFactory.factory.LoadTextureAtlasData(textAssets[i], textures[i].name); } Initializer.DebugText.text = "04"; Sprite[] sprites = NewDressTex.LoadAllAssets(); for (int i = 0; i < sprites.Length; i++) { PlayerManager.CloseSpriteDictionary.Add(sprites[i].name, sprites[i]); ResourceManager.ObjectDictionary.UniqueAdd(sprites[i].name, sprites[i]); } Initializer.DebugText.text = "051"; TextAsset language = Config.LoadAsset(ResourceLabel.English); XmlDocument document = new XmlDocument(); document.LoadXml(language.text); Language.AddLanguageDocument(CurrentLanguage.English, document); Initializer.DebugText.text = "061"; language = Config.LoadAsset(ResourceLabel.ChineseSimplified); document = new XmlDocument(); document.LoadXml(language.text); Language.AddLanguageDocument(CurrentLanguage.ChineseSimplified, document); Initializer.DebugText.text = "071"; language = Config.LoadAsset(ResourceLabel.ChineseTraditional); document = new XmlDocument(); document.LoadXml(language.text); Language.AddLanguageDocument(CurrentLanguage.ChineseTraditional, document); //Initializer.DebugText.text = "052"; //language = NewLanguage.LoadAsset(ResourceLabel.NewEnglish); //document = new XmlDocument(); //document.LoadXml(language.text); //Language.AddLanguageDocument(CurrentLanguage.English, document); //Initializer.DebugText.text = "062"; //language = NewLanguage.LoadAsset(ResourceLabel.NewChineseSimplified); //document = new XmlDocument(); //document.LoadXml(language.text); //Language.AddLanguageDocument(CurrentLanguage.ChineseSimplified, document); //Initializer.DebugText.text = "072"; //language = NewLanguage.LoadAsset(ResourceLabel.NewChineseTraditional); //document = new XmlDocument(); //document.LoadXml(language.text); //Language.AddLanguageDocument(CurrentLanguage.ChineseTraditional, document); Initializer.DebugText.text = "08"; //NewFlowerConfigs = ConfigManager.GetFlowerConfig(NewFlowerConfig.LoadAsset(ResourceLabel.NewFlowerConfig)); Initializer.DebugText.text = "09"; sprites = NewFlowerTex.LoadAllAssets(); for (int i = 0; i < sprites.Length; i++) { ResourceManager.ObjectDictionary.UniqueAdd(sprites[i].name, sprites[i]); } UpdateComplete = true; DelayCall.Call(1f, UpdatePanel.Hide); } catch (Exception e) { Debug.Log(e); Initializer.DebugText.text += e.ToString(); Initializer.EnableDebugLab(); } } public static void DownloadAllAssetBundleSucceed() { //Debug.Log("succeed"); } public static void DownloadAllAssetBundleFailed() { Debug.Log("failed"); } public static void DownloadAssetBundleSucceed(AssetBundleSet assetBundleSet, bool isDownload) { //Debug.Log(assetBundleSet.AssetBundle.name); //if (assetBundleSet.Name == ResourceLabel.NewDressConfig) //{ // NewDressConfig = assetBundleSet.AssetBundle; //} if (assetBundleSet.Name == ResourceLabel.NewDressSke) { NewDressSke = assetBundleSet.AssetBundle; } else if (assetBundleSet.Name == ResourceLabel.NewDressTex) { NewDressTex = assetBundleSet.AssetBundle; } else if (assetBundleSet.Name == ResourceLabel.Config) { Config = assetBundleSet.AssetBundle; } //else if (assetBundleSet.Name == ResourceLabel.NewLanguage) //{ // NewLanguage = assetBundleSet.AssetBundle; //} //else if (assetBundleSet.Name == ResourceLabel.NewFlowerConfig) //{ // NewFlowerConfig = assetBundleSet.AssetBundle; //} else if (assetBundleSet.Name == ResourceLabel.NewFlowerTex) { NewFlowerTex = assetBundleSet.AssetBundle; } if (isDownload) { UpdateFinishAmt++; UpdatePanel.SetProgress(UpdateAmt, UpdateFinishAmt); } } public static void DownloadAssetBundleFailed(AssetBundleSet assetBundleSet, string error) { Debug.Log(assetBundleSet.Name + " " + error); string path = assetBundleSet.PersistentPath; path = path.Replace("/", Path.DirectorySeparatorChar.ToString()); path = path.Replace("\\", Path.DirectorySeparatorChar.ToString()); path = path.Replace("\\\\", Path.DirectorySeparatorChar.ToString()); path = "file://" + path; WWW www = new WWW(path); AssetBundleSet bundleSet = new AssetBundleSet(); bundleSet.Name = assetBundleSet.Name; bundleSet.AssetBundle = www.assetBundle; DownloadAssetBundleSucceed(bundleSet, false); //string str = Language.GetStr(LanguageLabel.UI__AJ_UpdateFailed, Application.systemLanguage) + " " + error; //UpdatePanel.SetContent(str); //Initializer.DebugText.text = assetBundleSet.Name; //Initializer.DebugText.text += error; //Initializer.EnableDebugLab(); } public static void SkipUpdateForDebugMode() { //NewDressroomConfigs = ConfigManager.GetDressRoomConfig(Instance.NewDressConfigList[0] as TextAsset); foreach (var textAsset in Instance.NewDressSkeList) { UnityFactory.factory.LoadDragonBonesData(textAsset as TextAsset); } for (int i = 0; i < Instance.NewDressTexList.Count; i++) { TextAsset textAsset = Instance.NewDressTexConfigList[i] as TextAsset; Texture2D texture = Instance.NewDressTexList[i] as Texture2D; ResourceManager.ObjectDictionary.Add(texture.name, texture); UnityFactory.factory.LoadTextureAtlasData(textAsset, texture.name); } for (int i = 0; i < Instance.NewDressSpriteList.Count; i++) { Sprite sprite = Instance.NewDressSpriteList[i] as Sprite; PlayerManager.CloseSpriteDictionary.Add(sprite.name, sprite); ResourceManager.ObjectDictionary.UniqueAdd(sprite.name, sprite); } for (int i = 0; i < Instance.ConfigList.Count; i++) { TextAsset textAsset = Instance.ConfigList[i] as TextAsset; if (textAsset.name == ResourceLabel.English) { XmlDocument document = new XmlDocument(); document.LoadXml(textAsset.text); Language.AddLanguageDocument(CurrentLanguage.English, document); } else if (textAsset.name == ResourceLabel.ChineseSimplified) { XmlDocument document = new XmlDocument(); document.LoadXml(textAsset.text); Language.AddLanguageDocument(CurrentLanguage.ChineseSimplified, document); } else if (textAsset.name == ResourceLabel.ChineseTraditional) { XmlDocument document = new XmlDocument(); document.LoadXml(textAsset.text); Language.AddLanguageDocument(CurrentLanguage.ChineseTraditional, document); } } for (int i = 0; i < Instance.DefaultList.Count; i++) { TextAsset textAsset = Instance.ConfigList[i] as TextAsset; if (textAsset.name == ResourceLabel.English) { XmlDocument document = new XmlDocument(); document.LoadXml(textAsset.text); Language.AddLanguageDocument(CurrentLanguage.English, document); } else if (textAsset.name == ResourceLabel.ChineseSimplified) { XmlDocument document = new XmlDocument(); document.LoadXml(textAsset.text); Language.AddLanguageDocument(CurrentLanguage.ChineseSimplified, document); } else if (textAsset.name == ResourceLabel.ChineseTraditional) { XmlDocument document = new XmlDocument(); document.LoadXml(textAsset.text); Language.AddLanguageDocument(CurrentLanguage.ChineseTraditional, document); } } //NewFlowerConfigs = ConfigManager.GetDressRoomConfig(Instance.NewFlowerConfigList[0] as TextAsset); foreach (var obj in Instance.NewFlowerSpriteList) { Sprite sprite = obj as Sprite; ResourceManager.ObjectDictionary.UniqueAdd(sprite.name, sprite); } UpdateComplete = true; } }