// Token: 0x060002BE RID: 702 RVA: 0x00026DA4 File Offset: 0x00024FA4 public bool LoadTable(string in_DataName) { if (!DataManager.Instance.bLoadingTableSuccess) { return(false); } bool result = false; if (in_DataName.Length == 0) { DataManager.Instance.bLoadingTableSuccess = false; return(result); } AssetBundle tableAB = DataManager.Instance.GetTableAB(); if (tableAB == null) { DataManager.Instance.bLoadingTableSuccess = false; return(result); } TextAsset textAsset = tableAB.Load(in_DataName) as TextAsset; if (textAsset == null) { DataManager.Instance.bLoadingTableSuccess = false; return(result); } Stream stream = new MemoryStream(textAsset.bytes); if (stream.Length <= 4L) { DataManager.Instance.bLoadingTableSuccess = false; return(result); } GCHandle gchandle = GCHandle.Alloc(textAsset.bytes, GCHandleType.Pinned); this.BytesIntPtr = gchandle.AddrOfPinnedObject(); int num = (int)stream.Length - 4; int num2 = Marshal.SizeOf(typeof(R)); if (num < num2 || num % num2 != 0) { if (gchandle.IsAllocated) { gchandle.Free(); this.BytesIntPtr = IntPtr.Zero; } stream.Close(); Resources.UnloadUnusedAssets(); DataManager.Instance.bLoadingTableSuccess = false; return(result); } this.RecordAmount = num / num2; using (BinaryReader binaryReader = new BinaryReader(stream)) { binaryReader.ReadUInt16(); ushort num3 = binaryReader.ReadUInt16(); if (this.RecordAmount > (int)num3) { this.RecordAmount = (int)num3; } int startIdx = 4 + (this.RecordAmount - 1) * num2; this.MaxKey = GameConstants.ConvertBytesToUShort(textAsset.bytes, startIdx); this.MaxKey += 1; ushort[] array = new ushort[(int)this.MaxKey]; Array.Clear(array, 0, (int)this.MaxKey); int num4 = 4; ushort num5 = 0; while ((int)num5 < this.RecordAmount) { array[(int)GameConstants.ConvertBytesToUShort(textAsset.bytes, num4)] = num5; num4 += num2; num5 += 1; } this.KeyMapIndex = GCHandle.Alloc(array, GCHandleType.Pinned).AddrOfPinnedObject(); binaryReader.Close(); } stream.Close(); return(true); }
byte[] ReadZipFile(string fileName) { //AssetBundle zipFile = null; byte[] buffer = null; //string zipName = null; // using (CString.Block()) // { // CString sb = CString.Alloc(256); // sb.Append("lua"); // int pos = fileName.LastIndexOf('/'); // if (pos > 0) // { // sb.Append("_"); // sb.Append(fileName, 0, pos).ToLower().Replace('/', '_'); // fileName = fileName.Substring(pos + 1); // } // if (!fileName.EndsWith(".lua")) // { // fileName += ".lua"; // } //#if UNITY_5 || UNITY_5_3_OR_NEWER // fileName += ".bytes"; //#endif // zipName = sb.ToString(); // zipMap.TryGetValue(zipName, out zipFile); // } // if (zipFile != null) // { //#if UNITY_4_6 || UNITY_4_7 // TextAsset luaCode = zipFile.Load(fileName, typeof(TextAsset)) as TextAsset; //#else // TextAsset luaCode = zipFile.LoadAsset<TextAsset>(fileName); //#endif // if (luaCode != null) // { // buffer = luaCode.bytes; // Resources.UnloadAsset(luaCode); // } // } using (CString.Block()) { fileName = fileName.Replace("/", "."); if (!fileName.EndsWith(".lua")) { fileName += ".lua"; } #if UNITY_5 || UNITY_5_3_OR_NEWER fileName += ".bytes"; #endif } foreach (var bundleName in AppConst.LuaBundles) { AssetBundle bundle = null; if (zipMap.TryGetValue(bundleName, out bundle)) { #if UNITY_4_6 || UNITY_4_7 TextAsset luaCode = bundle.Load(fileName, typeof(TextAsset)) as TextAsset; #else TextAsset luaCode = bundle.LoadAsset <TextAsset>(fileName); #endif if (null == luaCode) { continue; } if (luaCode != null) { buffer = luaCode.bytes; Resources.UnloadAsset(luaCode); break; } } } if (null == buffer) { Debug.LogError("Load lua file from bundle error! luafile name is:" + fileName); } return(buffer); }
private IEnumerator DownloadVersion(string url, HandleVersionDownload callback1, HandleVersionLoaded callback2) { this._server_Version = new WWW(url); yield return(this._server_Version); XSingleton <XLoadingUI> .singleton.SetStatus(XSingleton <XStringTable> .singleton.GetString("XUPDATE_INFO_CHECKUPDATING"), 255, 255, 255); XSingleton <XTimerMgr> .singleton.KillTimer(this._time_out_token); if (this._server_Version != null) { if (string.IsNullOrEmpty(this._server_Version.error)) { if (callback1 != null) { AssetBundle assetBundle = this._server_Version.assetBundle; if (assetBundle == null) { XSingleton <XDebug> .singleton.AddErrorLog("load server manifest bundle error.", null, null, null, null, null); XSingleton <XLoadingUI> .singleton.SetStatus(XSingleton <XStringTable> .singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), 255, 255, 255); XSingleton <XUpdater> .singleton.OnError(); } else { UnityEngine.Object @object = assetBundle.Load("manifest", typeof(TextAsset)); if (@object == null) { XSingleton <XDebug> .singleton.AddErrorLog("load server manifest bundle error.", null, null, null, null, null); XSingleton <XLoadingUI> .singleton.SetStatus(XSingleton <XStringTable> .singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), 255, 255, 255); XSingleton <XUpdater> .singleton.OnError(); } else { AsyncVersionProcessRequest asyncVersionProcessRequest = callback1(@object as TextAsset); while (!asyncVersionProcessRequest.IsDone) { Thread.Sleep(1); } if (callback2 != null) { callback2(asyncVersionProcessRequest.IsCorrect); } assetBundle.Unload(false); } } } } else if (XUpdater.LaunchMode == XLaunchMode.Dev) { XSingleton <XUpdater> .singleton.DevStart(); XSingleton <XUpdater> .singleton.XApolloManager.SetGSDKEvent(1, true, "0"); } else { XSingleton <XDebug> .singleton.AddErrorLog(this._server_Version.error, null, null, null, null, null); XSingleton <XUpdater> .singleton.XApolloManager.SetGSDKEvent(1, false, XSingleton <XStringTable> .singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR")); XSingleton <XLoadingUI> .singleton.SetStatus(XSingleton <XStringTable> .singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), 255, 255, 255); XSingleton <XUpdater> .singleton.OnError(); } this._server_Version.Dispose(); this._server_Version = null; } else { XSingleton <XDebug> .singleton.AddErrorLog("ERROR: _server_Version is NULL!", null, null, null, null, null); XSingleton <XLoadingUI> .singleton.SetStatus(XSingleton <XStringTable> .singleton.GetString("XUPDATE_ERROR_FETCHMANIFESTERROR"), 255, 255, 255); XSingleton <XUpdater> .singleton.OnError(); } yield break; }
private IEnumerator WaitForEventBundleRequest(WWW www) { yield return(www); if (www.error == null) { yield return(www); Logger.trace("<< Loading Event Bundle . . ."); AssetBundle assetBundle = www.assetBundle; if (assetBundle == null) { mBundleIsLoading = false; getGameData(); state = waitForGameDataLoaded; yield break; } AssetBundleRequest abr = assetBundle.LoadAsync("event_manifest", typeof(TextAsset)); yield return(abr); if (abr != null) { GameData.EventManifest = (abr.asset as TextAsset); } Debug.Log("manifest: " + GameData.EventManifest); string[] num_events = GameData.EventManifest.text.Split(new char[1] { '\n' }, StringSplitOptions.RemoveEmptyEntries); string[] array = num_events; foreach (string events in array) { if (events == null || events == string.Empty) { continue; } string[] info = events.Split(','); string key2 = Convert.ToString(info[0]); string val3 = Convert.ToString(info[1]); string type2 = Convert.ToString(info[2]); key2 = key2.Replace(" ", string.Empty); val3 = val3.Replace(" ", string.Empty); type2 = type2.Replace(" ", string.Empty); string[] objandextension = val3.Split('.'); val3 = objandextension[0]; Debug.Log("<< val: " + val3); EventTypes LoadType = EventTypes.Unknown; try { LoadType = (EventTypes)(int)Enum.Parse(typeof(EventTypes), type2); } catch (ArgumentException) { Logger.traceError(type2 + " is not a valid type"); } switch (LoadType) { case EventTypes.GameObject: { GameObject go = assetBundle.Load(val3, typeof(GameObject)) as GameObject; if (go == null) { Debug.Log("<< couldn't find " + val3); } else { Debug.Log("adding gameobject [" + key2 + "] = " + go.name); } GameData.eventObjects.Add(key2, go); break; } case EventTypes.Texture2D: { Texture2D t2D = assetBundle.Load(val3, typeof(Texture2D)) as Texture2D; Debug.Log("adding texture2d [" + key2 + "] = " + t2D.name); GameData.eventObjects.Add(key2, t2D); break; } case EventTypes.AudioClip: { AudioClip Clip = assetBundle.Load(val3, typeof(AudioClip)) as AudioClip; if (Clip == null) { Debug.Log("clip " + key2 + " is null"); break; } Debug.Log("adding audioclip [" + key2 + "] = " + Clip.name); GameData.eventObjects.Add(key2, Clip); break; } case EventTypes.TextAsset: { TextAsset Text = assetBundle.Load(val3, typeof(TextAsset)) as TextAsset; Debug.Log("adding textasset [" + key2 + "] = " + Text.name); GameData.eventObjects.Add(key2, Text); break; } default: Logger.traceError("unknown type: [" + key2 + "] = " + val3); break; } } if (GameData.DoesEventExist("titlecard_particle")) { GameObject particle = GameData.eventObjects["titlecard_particle"] as GameObject; GameObject particleObject = UnityEngine.Object.Instantiate(particle) as GameObject; particleObject.transform.position = new Vector3(0f, 3f, 9f); } mStatus += " ... Event Bundle Loaded!"; mBundleIsLoading = false; getGameData(); state = waitForGameDataLoaded; OnEventLoaded(); } else { mBundleIsLoading = false; getGameData(); state = waitForGameDataLoaded; } }
// Token: 0x060028C1 RID: 10433 RVA: 0x00449004 File Offset: 0x00447204 public unsafe void LoadBannedWordTable() { int num = 0; IntPtr intPtr = IntPtr.Zero; IntPtr intPtr2 = IntPtr.Zero; int key = 0; AssetBundle assetBundle = AssetManager.GetAssetBundle("Loading/Table", out key, false); if (assetBundle == null) { return; } TextAsset textAsset = assetBundle.Load("BannedWord_CN") as TextAsset; TextAsset textAsset2 = assetBundle.Load("BannedWord2_CN") as TextAsset; if (textAsset == null || textAsset2 == null) { return; } Stream input = new MemoryStream(textAsset2.bytes); using (BinaryReader binaryReader = new BinaryReader(input)) { num = binaryReader.ReadInt32(); intPtr = GCHandle.Alloc(textAsset2.bytes, GCHandleType.Pinned).AddrOfPinnedObject(); } Stream stream = new MemoryStream(textAsset.bytes); GCHandle gchandle; using (BinaryReader binaryReader2 = new BinaryReader(stream)) { int num2 = binaryReader2.ReadInt32(); gchandle = GCHandle.Alloc(textAsset.bytes, GCHandleType.Pinned); intPtr2 = gchandle.AddrOfPinnedObject(); int num3 = num2 / 8 + 1; this.BMStringArray = new BoyerMooreStringMatcher[num3]; int num4 = num / 2 + 1; for (int i = 1; i < num4; i++) { int num5 = 4 + i * 2; byte *ptr = (byte *)intPtr.ToPointer(); ptr += num5; IntPtr intPtr3 = new IntPtr((void *)ptr); ushort num6 = (ushort)Marshal.PtrToStructure(intPtr3, typeof(ushort)); if (num6 > 0 && (int)num6 < num3 && this.BMStringArray[(int)num6] == null) { ptr = (byte *)intPtr2.ToPointer(); num5 = (int)(4 + (num6 - 1) * 8); ptr += num5; intPtr3 = new IntPtr((void *)ptr); int num7 = (int)Marshal.PtrToStructure(intPtr3, typeof(int)); ptr += 4; intPtr3 = new IntPtr((void *)ptr); ushort length = (ushort)Marshal.PtrToStructure(intPtr3, typeof(ushort)); num5 = 4 + num2 + num7; ptr = (byte *)intPtr2.ToPointer(); ptr += num5; intPtr3 = new IntPtr((void *)ptr); this.BMStringArray[(int)num6] = new BoyerMooreStringMatcher(new string((sbyte *)((void *)intPtr3), 0, (int)length, Encoding.UTF8)); } } binaryReader2.Close(); } stream.Close(); if (gchandle.IsAllocated) { gchandle.Free(); } AssetManager.UnloadAssetBundle(key, true); }
internal object GetItemAsset(PackageItem item) { switch (item.type) { case PackageItemType.Image: if (!item.decoded) { item.decoded = true; AtlasSprite sprite; if (_sprites.TryGetValue(item.id, out sprite)) { item.texture = CreateSpriteTexture(sprite); } else { item.texture = NTexture.Empty; } } return(item.texture); case PackageItemType.Atlas: if (!item.decoded) { item.decoded = true; string fileName = string.IsNullOrEmpty(item.file) ? (item.id + ".png") : item.file; string filePath = _assetNamePrefix + Path.GetFileNameWithoutExtension(fileName); string ext = Path.GetExtension(fileName); Texture2D tex; if (_resBundle != null) { #if UNITY_5 tex = _resBundle.LoadAsset <Texture2D>(filePath); #else tex = (Texture2D)_resBundle.Load(filePath, typeof(Texture2D)); #endif } else { tex = (Texture2D)_loadFunc(filePath, ext, typeof(Texture2D)); } if (tex == null) { Debug.LogWarning("FairyGUI: texture '" + fileName + "' not found in " + this.name); item.texture = NTexture.Empty; } else { if (tex.mipmapCount > 1) { Debug.LogWarning("FairyGUI: texture '" + fileName + "' in " + this.name + " is mipmaps enabled."); } item.texture = new NTexture(tex, (float)tex.width / item.width, (float)tex.height / item.height); filePath = filePath + "!a"; if (_resBundle != null) { #if UNITY_5 tex = _resBundle.LoadAsset <Texture2D>(filePath); #else tex = (Texture2D)_resBundle.Load(filePath, typeof(Texture2D)); #endif } else { tex = (Texture2D)_loadFunc(filePath, ext, typeof(Texture2D)); } if (tex != null) { item.texture.alphaTexture = tex; } } } return(item.texture); case PackageItemType.Sound: if (!item.decoded) { item.decoded = true; string fileName = _assetNamePrefix + Path.GetFileNameWithoutExtension(item.file); string ext = Path.GetExtension(item.file); if (_resBundle != null) { #if UNITY_5 item.audioClip = _resBundle.LoadAsset <AudioClip>(fileName); #else item.audioClip = (AudioClip)_resBundle.Load(fileName, typeof(AudioClip)); #endif } else { item.audioClip = (AudioClip)_loadFunc(fileName, ext, typeof(AudioClip)); } } return(item.audioClip); case PackageItemType.Font: if (!item.decoded) { item.decoded = true; LoadFont(item); } return(item.bitmapFont); case PackageItemType.MovieClip: if (!item.decoded) { item.decoded = true; LoadMovieClip(item); } return(item.frames); case PackageItemType.Component: if (!item.decoded) { item.decoded = true; string str = _descPack[item.id + ".xml"]; XML xml = new XML(str); if (_stringsSource != null) { Dictionary <string, string> strings; if (_stringsSource.TryGetValue(this.id + item.id, out strings)) { TranslateComponent(xml, strings); } } item.componentData = xml; } return(item.componentData); default: if (!item.decoded) { item.decoded = true; item.binary = LoadBinary(item.file); } return(item.binary); } }
/// <summary> /// Add a UI package from two assetbundles with a optional main asset name. /// </summary> /// <param name="desc">A assetbunble contains description file.</param> /// <param name="res">A assetbundle contains resources.</param> /// <param name="mainAssetName">Main asset name. e.g. Basics_fui.bytes</param> /// <returns>UIPackage</returns> public static UIPackage AddPackage(AssetBundle desc, AssetBundle res, string mainAssetName) { byte[] source = null; #if (UNITY_5 || UNITY_5_3_OR_NEWER) if (mainAssetName != null) { TextAsset ta = desc.LoadAsset <TextAsset>(mainAssetName); if (ta != null) { source = ta.bytes; } } else { string[] names = desc.GetAllAssetNames(); string searchPattern = "_fui"; foreach (string n in names) { if (n.IndexOf(searchPattern) != -1) { TextAsset ta = desc.LoadAsset <TextAsset>(n); if (ta != null) { source = ta.bytes; mainAssetName = Path.GetFileNameWithoutExtension(n); break; } } } } #else if (mainAssetName != null) { TextAsset ta = (TextAsset)desc.Load(mainAssetName, typeof(TextAsset)); if (ta != null) { source = ta.bytes; } } else { source = ((TextAsset)desc.mainAsset).bytes; mainAssetName = desc.mainAsset.name; } #endif if (source == null) { throw new Exception("FairyGUI: no package found in this bundle."); } if (desc != res) { desc.Unload(true); } ByteBuffer buffer = new ByteBuffer(source); UIPackage pkg = new UIPackage(); pkg._resBundle = res; pkg._fromBundle = true; int pos = mainAssetName.IndexOf("_fui"); string assetNamePrefix; if (pos != -1) { assetNamePrefix = mainAssetName.Substring(0, pos); } else { assetNamePrefix = mainAssetName; } if (!pkg.LoadPackage(buffer, res.name, assetNamePrefix)) { return(null); } _packageInstById[pkg.id] = pkg; _packageInstByName[pkg.name] = pkg; _packageList.Add(pkg); return(pkg); }
byte[] ReadZipFile(string fileName) { AssetBundle zipFile = null; byte[] buffer = null; string zipName = null; using (CString.Block()) { //CString sb = CString.Alloc(256); //sb.Append("lua"); //int pos = fileName.LastIndexOf('/'); //if (pos > 0) //{ // sb.Append("_"); // sb.Append(fileName, 0, pos).ToLower().Replace('/', '_'); // fileName = fileName.Substring(pos + 1); //} //if (!fileName.EndsWith(".lua")) //{ // fileName += ".lua"; //} CString sb = CString.Alloc(256); sb.Append("lua_"); if (fileName.IndexOf("message/") != -1) { sb.Append("message"); } else if (fileName.IndexOf("Template/") != -1) { sb.Append("template"); } else { sb.Append("script"); } int pos = fileName.LastIndexOf('/'); if (pos > 0) { fileName = fileName.Substring(pos + 1); } if (!fileName.EndsWith(".lua")) { fileName += ".lua"; } #if UNITY_5 || UNITY_2017 fileName += ".bytes"; #endif zipName = sb.ToString(); zipMap.TryGetValue(zipName, out zipFile); } if (zipFile != null) { #if UNITY_5 || UNITY_2017 TextAsset luaCode = zipFile.LoadAsset <TextAsset>(fileName); #else TextAsset luaCode = zipFile.Load(fileName, typeof(TextAsset)) as TextAsset; #endif if (luaCode != null) { buffer = luaCode.bytes; Resources.UnloadAsset(luaCode); } } return(buffer); }
public static Object LoadAsset(this AssetBundle assetBundle, string name, Type type) { return(assetBundle.Load(name, type)); }
// Token: 0x0600219C RID: 8604 RVA: 0x00401468 File Offset: 0x003FF668 private void initCorpsStage() { ushort num; CorpsStage recordByKey; if (DataManager.Instance.lastBattleResult == 1) { num = DataManager.StageDataController.StageRecord[2]; recordByKey = DataManager.StageDataController.CorpsStageTable.GetRecordByKey(num); } else { if (DataManager.StageDataController.StageRecord[2] >= DataManager.StageDataController.limitRecord[2]) { if (this.CorpsStageGameObject != null) { this.CorpsStageGameObject.SetActive(false); } return; } num = DataManager.StageDataController.StageRecord[2] + 1; recordByKey = DataManager.StageDataController.CorpsStageTable.GetRecordByKey(num); } if (this.CorpsStageGameObject == null) { if (num != this.currentCorpsStageRecord) { this.currentCorpsStageRecord = num; } this.CorpsStageGameObject = new GameObject("CorpsStage"); } else { if (num == this.currentCorpsStageRecord) { return; } this.currentCorpsStageRecord = num; this.CastleModelEff.transform.SetParent(null); this.CastleModel.transform.SetParent(null); this.LordModel.transform.SetParent(null); UnityEngine.Object.Destroy(this.LordModel); AssetManager.UnloadAssetBundle(this.LordassetKey, true); this.LordModel = null; AssetManager.UnloadAssetBundle(this.ShadowassetKey, true); this.ShadowassetKey = 0; } CString cstring = StringManager.Instance.SpawnString(30); Transform transform = this.CorpsStageGameObject.transform; transform.position = GameConstants.WordToVector3(recordByKey.CastlePos.X, recordByKey.CastlePos.Y, recordByKey.CastlePos.Z, -100, 0.01f); if (this.CastleModel == null) { cstring.ClearString(); cstring.AppendFormat("Role/npccastle"); AssetBundle assetBundle = AssetManager.GetAssetBundle(cstring, out this.CastleassetKey); this.CastleModel = (UnityEngine.Object.Instantiate(assetBundle.mainAsset) as GameObject); } Transform transform2 = this.CastleModel.transform; transform2.SetParent(transform); transform2.localScale = Vector3.one * (float)recordByKey.CastleScale * 0.01f; Vector3 eulerAngles = transform2.eulerAngles; eulerAngles.y = (float)recordByKey.CastleRotY * 0.01f; transform2.eulerAngles = eulerAngles; transform2.position = GameConstants.WordToVector3(recordByKey.CastlePos.X, recordByKey.CastlePos.Y, recordByKey.CastlePos.Z, -100, 0.01f); ushort num2 = 0; if (this.LordModel == null) { Hero recordByKey2 = DataManager.Instance.HeroTable.GetRecordByKey(recordByKey.Heros[0].HeroID); ushort num3 = recordByKey2.Modle; if (!DataManager.Instance.CheckHero3DMesh(recordByKey.Heros[0].HeroID)) { num3 = 1; } num2 = recordByKey2.Radius; cstring.ClearString(); cstring.StringToFormat("Role/hero_"); cstring.IntToFormat((long)num3, 5, false); cstring.AppendFormat("{0}{1}"); AssetBundle assetBundle = AssetManager.GetAssetBundle(cstring, out this.LordassetKey); if (assetBundle) { this.LordModel = (UnityEngine.Object.Instantiate(assetBundle.Load("m")) as GameObject); } } if (this.LordModel) { transform2 = this.LordModel.transform; } transform2.SetParent(transform); transform2.localScale = Vector3.one * (float)recordByKey.LordScale * 0.01f; transform2.position = GameConstants.WordToVector3(recordByKey.LordPos.X, recordByKey.LordPos.Y, recordByKey.LordPos.Z, -100, 0.01f); if (this.ShadowassetKey == 0) { AssetBundle assetBundle = AssetManager.GetAssetBundle("UI/shadow", out this.ShadowassetKey, false); GameObject gameObject = UnityEngine.Object.Instantiate(assetBundle.mainAsset) as GameObject; this.ShadowTransform = gameObject.transform; this.ShadowTransform.SetParent(transform2, false); MeshFilter component = gameObject.GetComponent <MeshFilter>(); component.mesh = GameConstants.CreatePlane(transform2.forward, transform2.right, new Rect(0f, 0f, 1f, 1f), new Color(1f, 1f, 1f, 0.6f), (float)num2 * 0.015f); this.LordBipTransform = transform2.GetChild(0); } ParticleManager.Instance.DeSpawn(this.CastleModelEff); this.CastleModelEff = ParticleManager.Instance.Spawn(309, transform, Vector3.zero, (float)recordByKey.CastleScale * 0.01f, true, true, true); this.CastleModelEff.SetActive(true); StringManager.Instance.DeSpawnString(cstring); }
public void LoadTextures() { AssetBundle assetBundle = mTextureBundles.assetBundle; mBanzaiSuits = (int[])GameData.BanzaiDefaultSuits.Clone(); mAtlasSuits = (int[])GameData.AtlasDefaultSuits.Clone(); mAtlasSuits[0] = GameData.AtlasDefaultSuits[2]; mAtlasSuits[2] = GameData.AtlasDefaultSuits[0]; int[] atlasDefaultSuits = GameData.AtlasDefaultSuits; foreach (int suitId in atlasDefaultSuits) { AssetLoader.AddSuitToLoad(suitId, AssetLoader.SuitAsset.SuitType.high, 100); } int[] banzaiDefaultSuits = GameData.BanzaiDefaultSuits; foreach (int suitId2 in banzaiDefaultSuits) { AssetLoader.AddSuitToLoad(suitId2, AssetLoader.SuitAsset.SuitType.high, 100); } BanzaiSuitTextures = new Texture2D[mBanzaiSuits.Length]; BanzaiSuitOutlineTextures = new Texture2D[mBanzaiSuits.Length]; BanzaiSuitText = new Texture2D[mBanzaiSuits.Length]; BanzaiSuitIcons = new Texture2D[mBanzaiSuits.Length]; for (int k = 0; k < mBanzaiSuits.Length; k++) { string text = GameData.getExosuit(mBanzaiSuits[k]).mSuitFileName.ToLower(); BanzaiSuitTextures[k] = (assetBundle.Load(text) as Texture2D); BanzaiSuitOutlineTextures[k] = (assetBundle.Load(text + "_over") as Texture2D); BanzaiSuitText[k] = (assetBundle.Load(text + "_text") as Texture2D); BanzaiSuitIcons[k] = (assetBundle.Load(text + "_icon") as Texture2D); } AtlasSuitTextures = new Texture2D[mAtlasSuits.Length]; AtlasSuitOutlineTextures = new Texture2D[mAtlasSuits.Length]; AtlasSuitText = new Texture2D[mAtlasSuits.Length]; AtlasSuitIcons = new Texture2D[mAtlasSuits.Length]; for (int l = 0; l < mAtlasSuits.Length; l++) { string text2 = GameData.getExosuit(mAtlasSuits[l]).mSuitFileName.ToLower(); AtlasSuitTextures[l] = (assetBundle.Load(text2) as Texture2D); AtlasSuitOutlineTextures[l] = (assetBundle.Load(text2 + "_over") as Texture2D); AtlasSuitText[l] = (assetBundle.Load(text2 + "_text") as Texture2D); AtlasSuitIcons[l] = (assetBundle.Load(text2 + "_icon") as Texture2D); } mBackground = (assetBundle.Load("Background") as Texture2D); FactionTextBG = new Texture2D[2]; FactionTextBG[0] = (assetBundle.Load("BanzaiSlidingBar") as Texture2D); FactionTextBG[1] = (assetBundle.Load("AtlasSlidingBar") as Texture2D); ChooseYourExosuit = (assetBundle.Load("ChooseYourExosuit") as Texture2D); ChooseYourFaction = (assetBundle.Load("ChooseYourFaction") as Texture2D); for (int m = 0; m < AtlasSuitIconRect.Length; m++) { AtlasSuitIconRect[m].height = AtlasSuitIcons[m].height; AtlasSuitIconRect[m].width = AtlasSuitIcons[m].width; } for (int n = 0; n < BanzaiSuitIconRect.Length; n++) { BanzaiSuitIconRect[n].height = BanzaiSuitIcons[n].height; BanzaiSuitIconRect[n].width = BanzaiSuitIcons[n].width; } for (int num = 0; num < BanzaiSuitOutlineRects.Length; num++) { BanzaiSuitOutlineRects[num] = new Rect(BanzaiSuitRects[num].x - 3f, BanzaiSuitRects[num].y - 3f, BanzaiSuitOutlineTextures[num].width, BanzaiSuitOutlineTextures[num].height); AtlasSuitOutlineRects[num] = new Rect(AtlasSuitRects[num].x - 3f, AtlasSuitRects[num].y - 3f, AtlasSuitOutlineTextures[num].width, AtlasSuitOutlineTextures[num].height); } bTexturesLoaded = true; }
// Token: 0x0600018C RID: 396 RVA: 0x00018AF8 File Offset: 0x00016CF8 public bool PlaySFXLoop(ushort NameID, out byte Key, Transform PlayObj = null, SFXEffect Effect = SFXEffect.Normal, float delay = 0f) { Key = 0; if (this.MuteSFXVol || NameID == 0) { return(false); } int num = (int)(NameID / 100); this.GetEmptyIndex(); CString cstring = StringManager.Instance.StaticString1024(); cstring.StringToFormat(this.Path); cstring.IntToFormat((long)num, 3, true); cstring.AppendFormat("{0}{1}"); if (Effect == SFXEffect.HighPassFilter) { return(this.PlaySFXLoopHighPass(NameID, out Key, PlayObj)); } AssetBundle assetBundle = AssetManager.GetAssetBundle(cstring, out this.SFXBundleKey[(int)this.poolIndex]); if (!assetBundle) { AssetManager.UnloadAssetBundle(this.SFXBundleKey[(int)this.poolIndex], true); this.SFXBundleKey[(int)this.poolIndex] = 0; return(false); } cstring.ClearString(); cstring.IntToFormat((long)NameID, 1, false); cstring.AppendFormat("{0}"); this.SFXClip.clip = (assetBundle.Load(cstring.ToString(), typeof(AudioClip)) as AudioClip); if (this.SFXClip.clip == null) { AssetManager.UnloadAssetBundle(this.SFXBundleKey[(int)this.poolIndex], true); this.SFXBundleKey[(int)this.poolIndex] = 0; return(false); } if (PlayObj != null) { this.AttachAudioSound(this.poolIndex, PlayObj); this.SFXClip.PanLevel = 1f; } else { this.SFXClip.PanLevel = 0f; } this.SFXClip.Loop = true; this.SFXClip.Volume = 1f; this.SFXClip.Pitch = 1f; this.SFXClip.DelaySecond = new float?(delay); Key = this.poolIndex; AudioSource[] sfxsource = this.SFXSource; byte b; this.poolIndex = (b = this.poolIndex) + 1; this.PlayAudio(sfxsource[(int)b], this.SFXClip); this.ChangeDuckingState(AudioManager.DuckingState.Start); if (this.poolIndex >= 20) { this.poolIndex = 0; } return(true); }
// Token: 0x0600018A RID: 394 RVA: 0x00018718 File Offset: 0x00016918 public void PlaySFX(ushort NameID, float delay = 0f, PitchKind pitchkind = PitchKind.NoPitch, Transform PlayObj = null, Vector3?Position = null) { if (this.MuteSFXVol || NameID == 0) { return; } int num = (int)(NameID / 100); if (num == 37 || num == 77) { PlayObj = null; } this.GetEmptyIndex(); CString cstring = StringManager.Instance.StaticString1024(); cstring.StringToFormat(this.Path); cstring.IntToFormat((long)num, 3, true); cstring.AppendFormat("{0}{1}"); AssetBundle assetBundle = AssetManager.GetAssetBundle(cstring, out this.SFXBundleKey[(int)this.poolIndex]); if (assetBundle) { cstring.ClearString(); cstring.IntToFormat((long)NameID, 1, false); cstring.AppendFormat("{0}"); this.SFXClip.clip = (assetBundle.Load(cstring.ToString(), typeof(AudioClip)) as AudioClip); if (this.SFXClip.clip == null) { AssetManager.UnloadAssetBundle(this.SFXBundleKey[(int)this.poolIndex], true); this.SFXBundleKey[(int)this.poolIndex] = 0; return; } this.SFXClip.DelaySecond = new float?(delay); if (pitchkind != PitchKind.SpeechSound) { if (pitchkind != PitchKind.Hit) { this.SFXClip.Pitch = 1f; } else { this.SFXClip.Pitch = 0.8909f + 0.2316f * UnityEngine.Random.value; } } else { byte b = (byte)Mathf.Max(0f, 30f * UnityEngine.Random.value / 10f); if (b == this.SpeechSoundPrev) { b += 1; if (b >= 3) { b = 0; } } this.SpeechSoundPrev = b; this.SFXClip.Pitch = this.SpeechSoundPitchVal[(int)this.SpeechSoundPrev]; } if (PlayObj != null) { this.AttachAudioSound(this.poolIndex, PlayObj); this.SFXClip.PanLevel = 1f; } else if (Position != null) { this.AttachAudioSound(this.poolIndex, Position.Value); this.SFXClip.PanLevel = 1f; } else { this.SFXClip.PanLevel = 0f; } this.SFXClip.Volume = 1f; this.SFXClip.Loop = false; AudioSource[] sfxsource = this.SFXSource; byte b2; this.poolIndex = (b2 = this.poolIndex) + 1; this.PlayAudio(sfxsource[(int)b2], this.SFXClip); this.ChangeDuckingState(AudioManager.DuckingState.Start); if (this.poolIndex >= 20) { this.poolIndex = 0; } } else { if (this.SFXSource[(int)this.poolIndex] == null) { Debug.LogWarning(string.Format("bundle_AbName({0}Null)", NameID)); } AssetManager.UnloadAssetBundle(this.SFXBundleKey[(int)this.poolIndex], true); this.SFXBundleKey[(int)this.poolIndex] = 0; } }
// Token: 0x06000188 RID: 392 RVA: 0x00018480 File Offset: 0x00016680 public bool PlayUISFX(UIKind Kind = UIKind.Normal) { if (this.MuteSFXVol || Kind == UIKind.None || this.AudioAssetBundleKey == 0) { return(false); } this.GetEmptyIndex(); CString cstring = StringManager.Instance.StaticString1024(); ushort num = (ushort)Kind; if (num == 0) { return(false); } int num2 = (int)(num / 100); cstring.StringToFormat(this.Path); cstring.IntToFormat((long)num2, 3, false); cstring.AppendFormat("{0}{1}"); if (num == 40030 && this.bPlayOnlyOneClip >= 0) { return(false); } AssetBundle assetBundle = AssetManager.GetAssetBundle(cstring, out this.SFXBundleKey[(int)this.poolIndex]); if (assetBundle) { if (num == 40030) { this.bPlayOnlyOneClip = (short)this.poolIndex; } cstring.ClearString(); cstring.IntToFormat((long)num, 1, false); cstring.AppendFormat("{0}"); this.SFXClip.clip = (assetBundle.Load(cstring.ToString(), typeof(AudioClip)) as AudioClip); if (this.SFXClip.clip == null) { AssetManager.UnloadAssetBundle(this.SFXBundleKey[(int)this.poolIndex], true); this.SFXBundleKey[(int)this.poolIndex] = 0; return(false); } this.SFXClip.DelaySecond = null; if (num2 == 300 && num != 30005) { this.SFXClip.Pitch = 0.8909f + 0.553f * UnityEngine.Random.value; } else { this.SFXClip.Pitch = 1f; } this.SFXClip.PanLevel = 0f; this.SFXClip.Loop = false; this.SFXClip.Volume = 1f; AudioSource[] sfxsource = this.SFXSource; byte b; this.poolIndex = (b = this.poolIndex) + 1; this.PlayAudio(sfxsource[(int)b], this.SFXClip); this.ChangeDuckingState(AudioManager.DuckingState.Start); if (this.poolIndex >= 20) { this.poolIndex = 0; } } else { AssetManager.UnloadAssetBundle(this.SFXBundleKey[(int)this.poolIndex], true); this.SFXBundleKey[(int)this.poolIndex] = 0; } return(true); }
void OnGUI() { if (GUI.Button(new Rect(0, 0, 100, 50), "Ping")) { Ping ping = new Ping("192.168.50.26"); while (!ping.isDone) { } info += ping.time + ping.isDone.ToString(); //info += "path:" + Application.persistentDataPath; //Player[] list = XmlUtils.AESLoad<Player[]>("myPlay"); //foreach (Player p in list) //{ // info += ("name:" + p.name + " level: " + p.level + " att1:" + p.att1); //} } if (GUI.Button(new Rect(100, 0, 100, 50), "写入")) { Player[] list = new Player[10]; for (int i = 0; i < 10; i++) { Player p = new Player(); p.id = i; p.name = "name"; p.level = i * 2; p.att1 = i; p.att2 = i; p.hp = i; list[i] = p; } XmlUtils.Save("myPlay", list); } if (GUI.Button(new Rect(200, 0, 100, 50), "创建")) { float x = Random.Range(-4f, 4f); float y = Random.Range(-4f, 4f); float z = Random.Range(-4f, 4f); Instantiate((GameObject)ABS.GetRes("Capsule"), new Vector3(x, y, z), Quaternion.identity); } if (GUI.Button(new Rect(300, 0, 100, 50), "打印AESasset")) { info += "path:" + Application.streamingAssetsPath; Player[] list = XmlUtils.AESLoadByStreamingAssetsPath <Player[]>("player"); foreach (Player p in list) { info += ("name:" + p.name + " level: " + p.level + " att1:" + p.att1); } } if (GUI.Button(new Rect(400, 0, 100, 50), "打印asset")) { //info += "path:" + Application.streamingAssetsPath; // List<FileData> list = XmlUtils.LoadByStreamingAssetsPath<List<FileData>>("test1"); // XmlUtils.path = Application.streamingAssetsPath + "/"; //List<FileData> list = XmlUtils.Load<List<FileData>>("test1"); //foreach (FileData p in list) //{ // info += ("name:" +p.fileName+ ",,"); //} //FileStream fs = new FileStream(filePath, FileMode.Open); //StreamReader m_streamReader = new StreamReader(fs, Encoding.UTF8); //string str = m_streamReader.ReadToEnd(); //if (fileStringsDic.ContainsKey(filePath)) // fileStringsDic[filePath] = str; //else // fileStringsDic.Add(filePath, str); //m_streamReader.Close(); //m_streamReader.Dispose(); //info += list[1].fileName; info += ("startTime:" + System.DateTime.Now.ToString() + ":" + System.DateTime.Now.Millisecond.ToString()); //Object o = Resources.Load("test1"); //TextAsset t = o as TextAsset; //XmlSerializer xmls = new XmlSerializer(typeof(List<FileData>)); //using (MemoryStream ms = new MemoryStream(t.bytes)) //{ // List<FileData> list = (List<FileData>)xmls.Deserialize(ms); // info += list[0].fileName; //} Player[] list = XmlUtils.AESLoadByStreamingAssetsPath <Player[]>("player"); info += list[2].name; info += ("endTime:" + System.DateTime.Now.ToString() + ":" + System.DateTime.Now.Millisecond.ToString()); } if (GUI.Button(new Rect(500, 0, 100, 50), "同步asset加载")) { AssetBundle ab = ABS.SynLoadRes("Cube"); GameObject go = (GameObject)ab.Load("Cube"); if (go != null) { float x = Random.Range(-4f, 4f); float y = Random.Range(-4f, 4f); float z = Random.Range(-4f, 4f); Instantiate(go, new Vector3(x, y, z), Quaternion.identity); } } GUI.Label(new Rect(100, 50, 100, 700), info); }
public static UnityEngine.Object Load(string res) { return(Asset.Load(res)); }
byte[] ReadZipFile(string fileName) { AssetBundle zipFile = null; byte[] buffer = null; string zipName = null; using (CString.Block()) { CString sb = CString.Alloc(256); sb.Append("lua"); int startPos = fileName.IndexOf('/'); int pos = fileName.LastIndexOf('/'); if (startPos > 0) //封装出包名 { sb.Append("_"); sb.Append(LuaMgr.Inst.cpuTypeStr); sb.Append(fileName, 0, startPos).ToLower().Replace('/', '_'); } if (pos > 0) //文件名 { fileName = fileName.Substring(pos + 1); } if (!fileName.EndsWith(".lua")) { fileName += ".lua"; } #if UNITY_5 || UNITY_5_3_OR_NEWER fileName += ".bytes"; #endif zipName = sb.ToString(); zipMap.TryGetValue(zipName, out zipFile); //[0] 添加补丁 如果常规下找不到,就在默认的ab包中找lua文件 if (zipFile == null) { zipFile = zipMap["lua_" + LuaMgr.Inst.cpuTypeStr + "tolua"]; } //[0] } if (zipFile != null) { #if UNITY_4_6 || UNITY_4_7 TextAsset luaCode = zipFile.Load(fileName, typeof(TextAsset)) as TextAsset; #else TextAsset luaCode = zipFile.LoadAsset <TextAsset>(fileName); #endif if (luaCode != null) { buffer = luaCode.bytes; Resources.UnloadAsset(luaCode); } } return(buffer); }
// Token: 0x060002C8 RID: 712 RVA: 0x000271D4 File Offset: 0x000253D4 public unsafe bool LoadStringTable(string Table = "Loading/String", bool Seek = false) { bool result = false; int key = 0; AssetBundle assetBundle = AssetManager.GetAssetBundle(Table, out key, Seek); if (assetBundle == null) { return(result); } TextAsset textAsset = assetBundle.Load("StringTable") as TextAsset; TextAsset textAsset2 = assetBundle.Load("StringTable2") as TextAsset; if (textAsset == null || textAsset2 == null) { return(result); } this.RecordAmount = 0; Stream input = new MemoryStream(textAsset2.bytes); using (BinaryReader binaryReader = new BinaryReader(input)) { this.RecordAmount = binaryReader.ReadInt32(); this.BytesIntPtr_Key = GCHandle.Alloc(textAsset2.bytes, GCHandleType.Pinned).AddrOfPinnedObject(); } Stream stream = new MemoryStream(textAsset.bytes); GCHandle gchandle; using (BinaryReader binaryReader2 = new BinaryReader(stream)) { this.MaxKey = binaryReader2.ReadInt32(); gchandle = GCHandle.Alloc(textAsset.bytes, GCHandleType.Pinned); this.BytesIntPtr = gchandle.AddrOfPinnedObject(); int num = this.MaxKey / 8 + 1; this.StringTableData = new string[num]; int num2 = this.RecordAmount / 2; for (int i = 1; i < num2; i++) { int num3 = 4 + i * 2; byte *ptr = (byte *)this.BytesIntPtr_Key.ToPointer(); ptr += num3; IntPtr intPtr = new IntPtr((void *)ptr); ushort num4 = (ushort)Marshal.PtrToStructure(intPtr, typeof(ushort)); if (num4 > 0 && (int)num4 < num && this.StringTableData[(int)num4] == null) { ptr = (byte *)this.BytesIntPtr.ToPointer(); num3 = (int)(4 + (num4 - 1) * 8); ptr += num3; intPtr = new IntPtr((void *)ptr); int num5 = (int)Marshal.PtrToStructure(intPtr, typeof(int)); ptr += 4; intPtr = new IntPtr((void *)ptr); ushort length = (ushort)Marshal.PtrToStructure(intPtr, typeof(ushort)); num3 = 4 + this.MaxKey + num5; ptr = (byte *)this.BytesIntPtr.ToPointer(); ptr += num3; intPtr = new IntPtr((void *)ptr); this.StringTableData[(int)num4] = new string((sbyte *)((void *)intPtr), 0, (int)length, Encoding.UTF8); } } binaryReader2.Close(); } stream.Close(); if (gchandle.IsAllocated) { gchandle.Free(); } AssetManager.UnloadAssetBundle(key, true); return(true); }
void LoadAtlas(PackageItem item) { string ext = Path.GetExtension(item.file); string fileName = item.file.Substring(0, item.file.Length - ext.Length); Texture tex = null; Texture alphaTex = null; DestroyMethod dm; if (_fromBundle) { if (_resBundle != null) { #if (UNITY_5 || UNITY_5_3_OR_NEWER) tex = _resBundle.LoadAsset <Texture>(fileName); #else tex = (Texture2D)_resBundle.Load(fileName, typeof(Texture2D)); #endif } else { Debug.LogWarning("FairyGUI: bundle already unloaded."); } dm = DestroyMethod.None; } else { tex = (Texture)_loadFunc(fileName, ext, typeof(Texture), out dm); } if (tex == null) { Debug.LogWarning("FairyGUI: texture '" + item.file + "' not found in " + this.name); } else if (!(tex is Texture2D)) { Debug.LogWarning("FairyGUI: settings for '" + item.file + "' is wrong! Correct values are: (Texture Type=Default, Texture Shape=2D)"); tex = null; } else { if (((Texture2D)tex).mipmapCount > 1) { Debug.LogWarning("FairyGUI: settings for '" + item.file + "' is wrong! Correct values are: (Generate Mip Maps=unchecked)"); } } if (tex != null) { fileName = fileName + "!a"; if (_fromBundle) { if (_resBundle != null) { #if (UNITY_5 || UNITY_5_3_OR_NEWER) alphaTex = _resBundle.LoadAsset <Texture2D>(fileName); #else alphaTex = (Texture2D)_resBundle.Load(fileName, typeof(Texture2D)); #endif } } else { alphaTex = (Texture2D)_loadFunc(fileName, ext, typeof(Texture2D), out dm); } } if (tex == null) { tex = NTexture.CreateEmptyTexture(); dm = DestroyMethod.Destroy; } if (item.texture == null) { item.texture = new NTexture(tex, alphaTex, (float)tex.width / item.width, (float)tex.height / item.height); item.texture.destroyMethod = dm; } else { item.texture.Reload(tex, alphaTex); item.texture.destroyMethod = dm; } }
protected IEnumerator _loadRes(string url, string method, string dataFmt, string paras, bool unique, Action <object> onFin, Action <float> onProg = null, Action <string> onFail = null) { bool flag = dataFmt == "assetbundle"; if (flag) { this.m_loadingJobs++; } if (unique) { string item = url.Substring(url.LastIndexOf('/') + 1); this.m_uniJobs.Add(item); item = null; } string message = LoaderBehavior._getStreamingFilePath(url, dataFmt); url = "file:///" + LoaderBehavior.DATA_PATH + "OutAssets/" + url; Debug.Log(message); message = null; bool flag2 = paras != null && paras.Length > 0; if (flag2) { url = url + "?" + paras; } WWW wWW = new WWW(url); LoaderBehavior.ms_LoadingProCount++; LoaderBehavior.ms_HasAllLoaded = false; yield return(this._evalWWW(wWW, onProg, 0f, 0.3f)); bool flag3 = wWW.error != null; if (flag3) { Debug.Log("fail: " + url + " : " + wWW.error); bool flag4 = onFail != null; if (flag4) { onFail(wWW.error); } } else { bool flag5 = onFin != null; if (flag5) { bool flag6 = dataFmt == "binary"; if (flag6) { onFin(wWW.bytes); } else { bool flag7 = dataFmt == "text"; if (flag7) { onFin(wWW.text); } else { bool flag8 = dataFmt == "assetbundle"; if (flag8) { AssetBundle assetBundle = null; while (assetBundle == null) { try { assetBundle = wWW.assetBundle; } catch (Exception ex2) { Exception ex = ex2; Debug.Log("URL Error " + ex.Message); } bool flag9 = assetBundle == null; if (flag9) { yield return(new WaitForSeconds(1f)); } } AssetBundleRequest assetBundleRequest = null; bool flag10 = true; bool flag11 = url.IndexOf(".pic") >= 0; if (flag11) { UnityEngine.Object @object = assetBundle.Load(LoaderBehavior._getAssetBundleName(url), typeof(Sprite)); bool flag12 = @object != null; if (flag12) { onFin(@object); } else { bool flag13 = onFail != null; if (flag13) { onFail("AssebBundle.Load Sprite return null!"); } } @object = null; } else { bool flag14 = url.IndexOf(".anipic") >= 0; if (flag14) { UnityEngine.Object[] array = assetBundle.LoadAll(typeof(Sprite)); bool flag15 = array != null; if (flag15) { onFin(array); } else { bool flag16 = onFail != null; if (flag16) { onFail("AssebBundle.LoadAll Sprite return null!"); } } array = null; } else { bool flag17 = url.IndexOf(".unity") >= 0; if (flag17) { onFin(assetBundle); flag10 = false; } else { bool flag18 = url.IndexOf(".anim") >= 0; if (flag18) { assetBundleRequest = assetBundle.LoadAsync(LoaderBehavior._getAssetBundleName(url), typeof(AnimationClip)); } else { bool flag19 = url.IndexOf(".lmp") >= 0; if (flag19) { assetBundleRequest = assetBundle.LoadAsync(LoaderBehavior._getAssetBundleName(url), typeof(Texture)); } else { bool flag20 = url.IndexOf(".lpb") >= 0; if (flag20) { assetBundleRequest = assetBundle.LoadAsync(LoaderBehavior._getAssetBundleName(url), typeof(LightProbes)); } else { bool flag21 = url.IndexOf(".snd") >= 0; if (flag21) { assetBundleRequest = assetBundle.LoadAsync(LoaderBehavior._getAssetBundleName(url), typeof(AudioClip)); } else { assetBundleRequest = assetBundle.LoadAsync(LoaderBehavior._getAssetBundleName(url), typeof(GameObject)); } } } } yield return(this._evalAssetBundleReq(assetBundleRequest, onProg, 0.3f, 0.7f)); onFin(assetBundleRequest.asset); } } } bool flag22 = flag10; if (flag22) { assetBundle.Unload(false); } assetBundle = null; assetBundleRequest = null; } } } } } wWW.Dispose(); bool flag23 = dataFmt == "assetbundle"; if (flag23) { this.m_loadingJobs--; } if (unique) { string item2 = url.Substring(url.LastIndexOf('/') + 1); this.m_uniJobs.Remove(item2); item2 = null; } LoaderBehavior.ms_LoadingProCount--; yield break; }
// Token: 0x0600077B RID: 1915 RVA: 0x000A28C8 File Offset: 0x000A0AC8 public GameObject Load(ushort modelID, AssetBundle ab, ushort texID = 0) { if (modelID <= 0 || ab == null || this.modelDefuse == null) { return(null); } GameObject gameObject = UnityEngine.Object.Instantiate(ab.Load("mwm")) as GameObject; if (gameObject == null) { return(null); } SkinnedMeshRenderer componentInChildren = gameObject.GetComponentInChildren <SkinnedMeshRenderer>(); if (componentInChildren == null) { return(null); } ModelLoader.MatNode matNode = null; ModelLoader.ModelNode modelNode = null; bool flag = this.m_MatList.TryGetValue(modelID, out modelNode); if (!flag || (flag && modelNode.matNode[(int)texID] == null)) { this.sb.Length = 0; this.sb.AppendFormat("m{0:00}", texID); if (!ab.Contains(this.sb.ToString())) { this.sb.Length = 0; this.sb.Append("m00"); } Texture2D texture2D = ab.Load(this.sb.ToString(), typeof(Texture2D)) as Texture2D; if (texture2D != null) { Material material = new Material(this.modelDefuse); material.mainTexture = texture2D; uint value = (uint)((int)modelID << 16 | (int)texID); this.m_MatMap.Add(material.GetInstanceID(), value); matNode = new ModelLoader.MatNode(); matNode.material = material; if (!flag) { modelNode = new ModelLoader.ModelNode(); this.m_MatList.Add(modelID, modelNode); } modelNode.matNode[(int)texID] = matNode; } } else { matNode = modelNode.matNode[(int)texID]; } if (matNode == null || (matNode != null && matNode.material == null)) { return(null); } componentInChildren.material = matNode.material; ModelLoader.MatNode matNode2 = matNode; matNode2.refCount += 1; ModelLoader.ModelNode modelNode2 = modelNode; modelNode2.refCount += 1; return(gameObject); }
byte[] ReadZipFile(string fileName) { AssetBundle zipFile = null; byte[] buffer = null; string zipName = null; TextAsset luaFile = null; string luaFileName = fileName; using (CString.Block()) { CString sb = CString.Alloc(256); sb.Append("lua"); int pos = fileName.LastIndexOf('/'); if (pos > 0) { sb.Append("_"); sb.Append(fileName, 0, pos).ToLower().Replace('/', '_'); fileName = fileName.Substring(pos + 1); } if (!fileName.EndsWith(".lua")) { fileName += ".lua"; } #if UNITY_5 || UNITY_5_3_OR_NEWER fileName += ".bytes"; #endif zipName = sb.ToString(); zipMap.TryGetValue(zipName, out zipFile); } if (zipFile != null) { #if UNITY_4_6 || UNITY_4_7 TextAsset luaCode = zipFile.Load(fileName, typeof(TextAsset)) as TextAsset; #else TextAsset luaCode = zipFile.LoadAsset <TextAsset>(fileName); #endif if (luaCode != null) { buffer = luaCode.bytes; Resources.UnloadAsset(luaCode); } } else { if (!luaFileName.EndsWith(".lua")) { luaFileName = luaFileName.Replace('/', '.'); luaFileName += ".lua"; } fileMap.TryGetValue(luaFileName, out luaFile); if (luaFile != null) { buffer = luaFile.bytes; Resources.UnloadAsset(luaFile); } } return(buffer); }