public void LoadBank(string bankName, CSoundManager.BankType bankType) { if (!this.m_isPrepared) { return; } if (this.m_loadedBanks[(int)bankType].Contains(bankName)) { return; } if (AkInitializer.s_loadBankFromMemory) { string soundBankPathInResources = AkInitializer.GetSoundBankPathInResources(bankName); CBinaryObject cBinaryObject = Singleton <CResourceManager> .GetInstance().GetResource(soundBankPathInResources, typeof(TextAsset), 2, false, false).m_content as CBinaryObject; if (cBinaryObject != null) { AkBankManager.LoadBank(bankName, cBinaryObject.m_data); } Singleton <CResourceManager> .GetInstance().RemoveCachedResource(soundBankPathInResources); } else { AkBankManager.LoadBank(bankName); } this.m_loadedBanks[(int)bankType].Add(bankName); }
public virtual byte[] FileOpen(string filePath, string ext) { try { filePath += ext; int num = filePath.IndexOf("Resources"); if (num != -1) { num += 10; string text = filePath.Substring(num); CBinaryObject cBinaryObject = Singleton <CResourceManager> .GetInstance().GetResource(text, typeof(TextAsset), 0, false, false).m_content as CBinaryObject; byte[] result; if (cBinaryObject == null) { string text2 = string.Format("FileManager::FileOpen failed:'{0}' not loaded", filePath); result = null; return(result); } byte[] data = cBinaryObject.m_data; result = data; return(result); } else { string text3 = string.Format("FileManager::FileOpen failed:'{0}' should be in /Resources", filePath); } } catch { string text4 = string.Format("FileManager::FileOpen exception:'{0}'", filePath); } return(null); }
public void Load() { if (this.m_isAbandon) { this.m_state = enResourceState.Unload; } else { if (this.m_contentType == null) { this.m_content = Resources.Load(CFileManager.EraseExtension(this.m_fullPathInResources)); } else { this.m_content = Resources.Load(CFileManager.EraseExtension(this.m_fullPathInResources), this.m_contentType); } this.m_state = enResourceState.Loaded; if ((this.m_content != null) && (this.m_content.GetType() == typeof(TextAsset))) { CBinaryObject obj2 = ScriptableObject.CreateInstance <CBinaryObject>(); obj2.m_data = (this.m_content as TextAsset).bytes; this.m_content = obj2; } } }
public virtual byte[] FileOpen(string filePath, string ext) { try { filePath = filePath + ext; int index = filePath.IndexOf("Resources"); if (index != -1) { index += 10; string fullPathInResources = filePath.Substring(index); CBinaryObject content = Singleton <CResourceManager> .GetInstance().GetResource(fullPathInResources, typeof(TextAsset), enResourceType.BattleScene, false, false).m_content as CBinaryObject; if (content == null) { string str2 = string.Format("FileManager::FileOpen failed:'{0}' not loaded", filePath); return(null); } return(content.m_data); } string str3 = string.Format("FileManager::FileOpen failed:'{0}' should be in /Resources", filePath); } catch { string str4 = string.Format("FileManager::FileOpen exception:'{0}'", filePath); } return(null); }
public void Load(AssetBundle assetBundle) { if (this.m_isAbandon) { this.m_state = enResourceState.Unload; } else { string name = this.m_name; if (this.m_contentType == null) { this.m_content = assetBundle.Load(name); } else { this.m_content = assetBundle.Load(name, this.m_contentType); } this.m_state = enResourceState.Loaded; if ((this.m_content != null) && (this.m_content.GetType() == typeof(TextAsset))) { CBinaryObject obj2 = ScriptableObject.CreateInstance <CBinaryObject>(); obj2.m_data = (this.m_content as TextAsset).bytes; this.m_content = obj2; } } }
public static string[] LoadLoginUrl() { CBinaryObject cBinaryObject = Singleton <CResourceManager> .GetInstance().GetResource(ApolloConfig.serverUrlPath, typeof(TextAsset), enResourceType.Numeric, false, false).m_content as CBinaryObject; if (cBinaryObject == null) { Debug.LogError(string.Format("Can't find file: {0}", ApolloConfig.serverUrlPath)); Singleton <CResourceManager> .GetInstance().RemoveCachedResource(ApolloConfig.serverUrlPath); return(null); } string @string = Encoding.get_UTF8().GetString(cBinaryObject.m_data); Singleton <CResourceManager> .GetInstance().RemoveCachedResource(ApolloConfig.serverUrlPath); string[] array = @string.Split(new char[] { '\r', '\t', ' ', '\n', ';' }, 1); List <string> list = new List <string>(); for (int i = 0; i < array.Length; i++) { string text = array[i]; string[] array2 = text.Split(new char[] { '.' }, 1); if (array2.Length == 4) { bool flag = true; for (int j = 0; j < array2.Length; j++) { try { Convert.ToUInt16(array2[j]); } catch { flag = false; break; } } if (flag) { list.Add(text); } } } if (list.get_Count() != 3) { Debug.LogError(string.Format("Invalid server list file: {0}", ApolloConfig.serverUrlPath)); return(null); } return(list.ToArray()); }
public void LoadFromAssetBundle(CResourcePackerInfo resourcePackerInfo) { if (this.m_isAbandon) { this.m_state = enResourceState.Unload; } else { string name = this.m_name; string rename = resourcePackerInfo.GetRename(this.m_fullPathInResourcesWithoutExtension); if (!string.IsNullOrEmpty(rename)) { name = CFileManager.GetFullName(rename); } if (this.m_contentType == null) { this.m_content = resourcePackerInfo.m_assetBundle.Load(name); } else { this.m_content = resourcePackerInfo.m_assetBundle.Load(name, this.m_contentType); } this.m_state = enResourceState.Loaded; if ((this.m_content != null) && (this.m_content.GetType() == typeof(TextAsset))) { CBinaryObject obj2 = ScriptableObject.CreateInstance <CBinaryObject>(); obj2.m_data = (this.m_content as TextAsset).bytes; this.m_content = obj2; } } }
public void CheckLoadAddressBook() { if (this.m_addressBook == null) { string text = "Config/Address.json"; CBinaryObject cBinaryObject = Singleton <CResourceManager> .GetInstance().GetResource(text, typeof(TextAsset), enResourceType.Numeric, false, false).m_content as CBinaryObject; if (cBinaryObject == null) { Debug.LogError(string.Format("Can't find file: {0}", text)); Singleton <CResourceManager> .GetInstance().RemoveCachedResource(text); } else { string @string = Encoding.get_UTF8().GetString(cBinaryObject.m_data); this.m_addressBook = (Json.Deserialize(@string) as List <object>); if (this.m_addressBook != null && this.m_searchStrings[5] == null) { int num = 0; this.m_searchStrings[5] = new string[this.m_addressBook.get_Count()]; using (List <object> .Enumerator enumerator = this.m_addressBook.GetEnumerator()) { while (enumerator.MoveNext()) { Dictionary <string, object> dictionary = (Dictionary <string, object>)enumerator.get_Current(); this.m_searchStrings[5][num] = (dictionary.get_Item("name") as string); num++; } } } Singleton <CResourceManager> .GetInstance().RemoveCachedResource(text); } } }
private void InitConfig() { CResource resource = Singleton <CResourceManager> .GetInstance().GetResource("Config/ParticleLimit", typeof(TextAsset), enResourceType.Numeric, false, true); if (resource == null) { return; } CBinaryObject cBinaryObject = resource.m_content as CBinaryObject; if (null == cBinaryObject) { return; } string text = StringHelper.ASCIIBytesToString(cBinaryObject.m_data); string[] array = text.Split(new char[] { '\r', '\n' }); array = Array.FindAll <string>(array, (string x) => !string.IsNullOrEmpty(x)); for (int i = 0; i < array.Length; i++) { string text2 = array[i]; if (!string.IsNullOrEmpty(text2)) { text2 = text2.Trim(); if (text2.Contains("//")) { text2 = text2.Substring(0, text2.IndexOf("//")); } text2 = text2.Trim(); if (!string.IsNullOrEmpty(text2)) { string[] array2 = text2.Split(new char[] { ':' }); if (array2 == null || array2.Length != 2) { return; } int[] array3 = new int[2]; for (int j = 0; j < array2.Length; j++) { array3[j] = Mathf.Abs(int.Parse(array2[j])); } if (array3[0] != 0 && array3[0] != 1) { return; } this.LIMIT_CONFIG[i] = array3[1]; } } } }
private void Start() { CBinaryObject content = Singleton <CResourceManager> .GetInstance().GetResource("Revision.txt", typeof(TextAsset), enResourceType.Numeric, false, false).m_content as CBinaryObject; if (null != content) { this.revision = Encoding.UTF8.GetString(content.m_data); } Singleton <CResourceManager> .GetInstance().RemoveCachedResource("Revision.txt"); }
public void LoadDatabin(string name, BinLoadCompletedDelegate finishDelegate) { CBinaryObject content = Singleton <CResourceManager> .GetInstance().GetResource(name, typeof(TextAsset), enResourceType.Numeric, false, false).m_content as CBinaryObject; object[] inParameters = new object[] { name }; DebugHelper.Assert(content != null, "load databin fail {0}", inParameters); byte[] data = content.m_data; if (finishDelegate != null) { finishDelegate(ref data); } Singleton <CResourceManager> .GetInstance().RemoveCachedResource(name); }
public static string[] LoadLoginUrl() { CBinaryObject content = Singleton <CResourceManager> .GetInstance().GetResource(serverUrlPath, typeof(TextAsset), enResourceType.Numeric, false, false).m_content as CBinaryObject; if (content == null) { Debug.LogError(string.Format("Can't find file: {0}", serverUrlPath)); Singleton <CResourceManager> .GetInstance().RemoveCachedResource(serverUrlPath); return(null); } string str = Encoding.UTF8.GetString(content.m_data); Singleton <CResourceManager> .GetInstance().RemoveCachedResource(serverUrlPath); string[] strArray = str.Split(new char[] { '\r', '\t', ' ', '\n', ';', '\0' }, StringSplitOptions.RemoveEmptyEntries); List <string> list = new List <string>(); for (int i = 0; i < strArray.Length; i++) { string item = strArray[i]; char[] separator = new char[] { '.' }; string[] strArray2 = item.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (strArray2.Length == 4) { bool flag = true; for (int j = 0; j < strArray2.Length; j++) { try { Convert.ToUInt16(strArray2[j]); } catch { flag = false; break; } } if (flag) { list.Add(item); } } } if (list.Count != 3) { Debug.LogError(string.Format("Invalid server list file: {0}", serverUrlPath)); return(null); } return(list.ToArray()); }
public void LoadDatabin(string name, ResourceLoader.BinLoadCompletedDelegate finishDelegate) { CBinaryObject cBinaryObject = Singleton <CResourceManager> .GetInstance().GetResource(name, typeof(TextAsset), 1, false, false).m_content as CBinaryObject; DebugHelper.Assert(cBinaryObject != null, "load databin fail {0}", new object[] { name }); byte[] data = cBinaryObject.m_data; if (finishDelegate != null) { finishDelegate(ref data); } Singleton <CResourceManager> .GetInstance().RemoveCachedResource(name); }
private void InitConfig() { CResource resource = Singleton <CResourceManager> .GetInstance().GetResource("Config/ParticleLimit", typeof(TextAsset), enResourceType.Numeric, false, true); if (resource != null) { CBinaryObject content = resource.m_content as CBinaryObject; if (null != content) { char[] separator = new char[] { '\r', '\n' }; foreach (string str2 in StringHelper.UTF8BytesToString(ref content.m_data).Split(separator)) { if (!string.IsNullOrEmpty(str2)) { str2 = str2.Trim(); if (str2.Contains("//")) { str2 = str2.Substring(0, str2.IndexOf("//")); } str2 = str2.Trim(); if (!string.IsNullOrEmpty(str2)) { char[] chArray2 = new char[] { ':', ',' }; string[] strArray2 = str2.Split(chArray2); if ((strArray2 == null) || (strArray2.Length != 3)) { return; } int[] numArray = new int[3]; for (int i = 0; i < strArray2.Length; i++) { numArray[i] = Mathf.Abs(int.Parse(strArray2[i])); } if ((numArray[0] != 0) && (numArray[0] != 1)) { return; } if (numArray[1] >= numArray[2]) { return; } this.LIMIT_CONFIG[numArray[0]] = new int[] { numArray[1], numArray[2] }; } } } } } }
private void InitForm() { if (this.m_form == null) { return; } Text component = this.m_form.GetWidget(0).GetComponent <Text>(); Text component2 = this.m_form.GetWidget(1).transform.FindChild("Text").GetComponent <Text>(); this.m_stepList = this.m_form.GetWidget(2).GetComponent <CUIStepListScript>(); this.m_BottomBtn = this.m_form.GetWidget(1).gameObject; this.m_PickObject = this.m_form.GetWidget(3).gameObject; this.m_BtnLeft = this.m_form.GetWidget(4).gameObject; this.m_BtnRight = this.m_form.GetWidget(5).gameObject; this.m_timer = this.m_form.GetWidget(6).GetComponent <CUITimerScript>(); if (this.m_title != null) { component.set_text(this.m_title); } if (this.m_btnName != null) { component2.set_text(this.m_btnName); } this.m_stepList.SetElementAmount(this.m_totalImgNum); for (int i = 0; i < this.m_totalImgNum; i++) { if (this.m_stepList.GetElemenet(i) != null) { Image component3 = this.m_stepList.GetElemenet(i).transform.FindChild("Image").GetComponent <Image>(); CBinaryObject cBinaryObject = Singleton <CResourceManager> .GetInstance().GetResource(this.m_imgPath[i] + ".bytes", typeof(TextAsset), enResourceType.UISprite, false, false).m_content as CBinaryObject; if (cBinaryObject != null) { byte[] data = cBinaryObject.m_data; Texture2D texture2D = new Texture2D(0, 0, TextureFormat.RGB24, false); texture2D.LoadImage(data); Sprite sprite = Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), new Vector2(0.5f, 0.5f)); component3.set_sprite(sprite); } else { component3.SetSprite(this.m_imgPath[i], this.m_form, true, false, false, false); } } } this.m_stepList.SetDontUpdate(true); }
public void Load(string ifsExtractPath) { if (this.m_isAbandon) { this.m_state = enResourceState.Unload; return; } byte[] array = CFileManager.ReadFile(CFileManager.CombinePath(ifsExtractPath, this.m_fileFullPathInResources)); this.m_state = enResourceState.Loaded; if (array != null) { CBinaryObject cBinaryObject = ScriptableObject.CreateInstance <CBinaryObject>(); cBinaryObject.m_data = array; cBinaryObject.name = this.m_name; this.m_content = cBinaryObject; } }
public void Load(string ifsExtractPath) { if (this.m_isAbandon) { this.m_state = enResourceState.Unload; } else { byte[] buffer = CFileManager.ReadFile(CFileManager.CombinePath(ifsExtractPath, this.m_fileFullPathInResources)); this.m_state = enResourceState.Loaded; if (buffer != null) { CBinaryObject obj2 = ScriptableObject.CreateInstance <CBinaryObject>(); obj2.m_data = buffer; obj2.name = this.m_name; this.m_content = obj2; } } }
public Dictionary <string, int> LoadTemplateObjectList(Action action) { string actionName = action.actionName; CBinaryObject cBinaryObject = ActionManager.Instance.resLoader.LoadAge(actionName) as CBinaryObject; if (cBinaryObject == null) { return(new Dictionary <string, int>()); } SecurityParser securityParser = new SecurityParser(); securityParser.LoadXml(Encoding.get_UTF8().GetString(cBinaryObject.m_data)); Singleton <CResourceManager> .GetInstance().RemoveCachedResource(actionName); SecurityElement securityElement = securityParser.SelectSingleNode("Project"); SecurityElement securityElement2 = (securityElement != null) ? securityElement.SearchForChildByTag("TemplateObjectList") : null; if (securityElement2 != null) { action.templateObjectIds.Clear(); if (securityElement2.get_Children() != null) { for (int i = 0; i < securityElement2.get_Children().get_Count(); i++) { SecurityElement securityElement3 = securityElement2.get_Children().get_Item(i) as SecurityElement; string text = securityElement3.Attribute("objectName"); string text2 = securityElement3.Attribute("id"); int num = int.Parse(text2); string text3 = securityElement3.Attribute("isTemp"); if (text3 == "false") { action.templateObjectIds.Add(text, num); } } } } return(action.templateObjectIds); }
public Action LoadActionResource(string _actionName) { Action action = null; if (_actionName == null) { DebugHelper.Assert(_actionName != null, "can't load action with name = null"); return(null); } if (this.actionResourceSet.TryGetValue(_actionName, out action)) { if (action != null) { return(action); } this.actionResourceSet.Remove(_actionName); } CBinaryObject cBinaryObject = ActionManager.Instance.resLoader.LoadAge(_actionName) as CBinaryObject; if (cBinaryObject == null) { return(null); } SecurityParser securityParser = new SecurityParser(); try { securityParser.LoadXml(Encoding.get_UTF8().GetString(cBinaryObject.m_data)); } catch (Exception ex) { DebugHelper.Assert(false, "Load xml Exception for action name = {0}, exception = {1}", new object[] { _actionName, ex.get_Message() }); return(null); } action = new Action(); action.name = _actionName; action.enabled = false; action.actionName = _actionName; this.actionResourceSet.Add(_actionName, action); Singleton <CResourceManager> .GetInstance().RemoveCachedResource(_actionName); SecurityElement securityElement = securityParser.SelectSingleNode("Project"); SecurityElement securityElement2 = (securityElement != null) ? securityElement.SearchForChildByTag("TemplateObjectList") : null; SecurityElement securityElement3 = (securityElement != null) ? securityElement.SearchForChildByTag("Action") : null; SecurityElement securityElement4 = (securityElement != null) ? securityElement.SearchForChildByTag("RefParamList") : null; DebugHelper.Assert(securityElement3 != null, "actionNode!=null"); if (securityElement3 != null) { action.length = ActionUtility.SecToMs(float.Parse(securityElement3.Attribute("length"))); action.loop = bool.Parse(securityElement3.Attribute("loop")); } if (securityElement2 != null && securityElement2.get_Children() != null) { for (int i = 0; i < securityElement2.get_Children().get_Count(); i++) { SecurityElement securityElement5 = securityElement2.get_Children().get_Item(i) as SecurityElement; string str = securityElement5.Attribute("objectName"); string text = securityElement5.Attribute("id"); int id = int.Parse(text); action.AddTemplateObject(str, id); } } if (securityElement4 != null && securityElement4.get_Children() != null) { for (int j = 0; j < securityElement4.get_Children().get_Count(); j++) { this.LoadRefParamNode(action, securityElement4.get_Children().get_Item(j) as SecurityElement); } } if (securityElement3 != null && securityElement3.get_Children() != null) { for (int k = 0; k < securityElement3.get_Children().get_Count(); k++) { SecurityElement securityElement6 = securityElement3.get_Children().get_Item(k) as SecurityElement; string text2 = securityElement6.Attribute("eventType"); if (!text2.Contains(".") && text2.get_Length() > 0) { text2 = "AGE." + text2; } Type type = Utility.GetType(text2); if (type != null) { string name = string.Empty; bool flag = false; if (securityElement6.Attribute("refParamName") != null) { name = securityElement6.Attribute("refParamName"); } if (securityElement6.Attribute("useRefParam") != null) { flag = bool.Parse(securityElement6.Attribute("useRefParam")); } bool enabled = bool.Parse(securityElement6.Attribute("enabled")); if (flag) { action.refParams.GetRefParam(name, ref enabled); } Track track = action.AddTrack(type); track.enabled = enabled; track.trackName = securityElement6.Attribute("trackName"); if (securityElement6.Attribute("execOnActionCompleted") != null) { track.execOnActionCompleted = bool.Parse(securityElement6.Attribute("execOnActionCompleted")); } if (securityElement6.Attribute("execOnForceStopped") != null) { track.execOnForceStopped = bool.Parse(securityElement6.Attribute("execOnForceStopped")); } if (flag) { FieldInfo field = type.GetField(securityElement6.Attribute("enabled")); action.refParams.AddRefData(name, field, track); } if (securityElement6.Attribute("r") != null) { track.color.r = float.Parse(securityElement6.Attribute("r")); } if (securityElement6.Attribute("g") != null) { track.color.g = float.Parse(securityElement6.Attribute("g")); } if (securityElement6.Attribute("b") != null) { track.color.b = float.Parse(securityElement6.Attribute("b")); } ListView <SecurityElement> listView = new ListView <SecurityElement>(); if (securityElement6.get_Children() != null) { for (int l = 0; l < securityElement6.get_Children().get_Count(); l++) { SecurityElement securityElement7 = securityElement6.get_Children().get_Item(l) as SecurityElement; if (securityElement7.get_Tag() != "Event" && securityElement7.get_Tag() != "Condition") { listView.Add(securityElement7); } } for (int m = 0; m < securityElement6.get_Children().get_Count(); m++) { SecurityElement securityElement8 = securityElement6.get_Children().get_Item(m) as SecurityElement; if (securityElement8.get_Tag() == "Condition") { SecurityElement securityElement9 = securityElement8; int num = int.Parse(securityElement9.Attribute("id")); bool flag2 = bool.Parse(securityElement9.Attribute("status")); if (track.waitForConditions == null) { track.waitForConditions = new Dictionary <int, bool>(); } track.waitForConditions.Add(num, flag2); } else if (!(securityElement8.get_Tag() != "Event")) { int time = ActionUtility.SecToMs(float.Parse(securityElement8.Attribute("time"))); int length = 0; if (track.IsDurationEvent) { length = ActionUtility.SecToMs(float.Parse(securityElement8.Attribute("length"))); } BaseEvent baseEvent = track.AddEvent(time, length); for (int n = 0; n < listView.Count; n++) { this.SetEventField(action, baseEvent, listView[n]); } if (securityElement8.get_Children() != null) { for (int num2 = 0; num2 < securityElement8.get_Children().get_Count(); num2++) { this.SetEventField(action, baseEvent, securityElement8.get_Children().get_Item(num2) as SecurityElement); } } baseEvent.OnLoaded(); } } } } else { Debug.LogError("Invalid event type \"" + securityElement6.Attribute("eventType") + "\"!"); } } } return(action); }
public bool GetActionTemplateObjectsAndPredefRefParams(string actionName, ref List <TemplateObject> objs, ref List <string> refnames) { if (actionName == null) { return(false); } ActionCommonData actionCommonData; if (this.actionCommonDataSet.ContainsKey(actionName)) { actionCommonData = this.actionCommonDataSet[actionName]; } else { CBinaryObject cBinaryObject = ActionManager.Instance.resLoader.LoadAge(actionName) as CBinaryObject; if (cBinaryObject == null) { return(false); } actionCommonData = new ActionCommonData(); SecurityParser securityParser = new SecurityParser(); securityParser.LoadXml(Encoding.get_UTF8().GetString(cBinaryObject.m_data)); Singleton <CResourceManager> .GetInstance().RemoveCachedResource(actionName); SecurityElement securityElement = securityParser.SelectSingleNode("Project"); SecurityElement securityElement2 = (securityElement != null) ? securityElement.SearchForChildByTag("TemplateObjectList") : null; if (securityElement2 != null) { using (IEnumerator enumerator = securityElement2.get_Children().GetEnumerator()) { while (enumerator.MoveNext()) { SecurityElement securityElement3 = (SecurityElement)enumerator.get_Current(); if (!(securityElement3.get_Tag() != "TemplateObject")) { TemplateObject templateObject = new TemplateObject(); templateObject.name = securityElement3.Attribute("objectName"); templateObject.id = int.Parse(securityElement3.Attribute("id")); templateObject.isTemp = bool.Parse(securityElement3.Attribute("isTemp")); actionCommonData.templateObjects.Add(templateObject); } } } } SecurityElement securityElement4 = (securityElement != null) ? securityElement.SearchForChildByTag("RefParamList") : null; if (securityElement4 != null) { using (IEnumerator enumerator2 = securityElement4.get_Children().GetEnumerator()) { while (enumerator2.MoveNext()) { SecurityElement securityElement5 = (SecurityElement)enumerator2.get_Current(); string text = securityElement5.Attribute("name"); if (text.StartsWith("_")) { actionCommonData.predefRefParamNames.Add(text); } } } } this.actionCommonDataSet.Add(actionName, actionCommonData); } if (actionCommonData != null) { objs.Clear(); refnames.Clear(); for (int i = 0; i < actionCommonData.templateObjects.Count; i++) { objs.Add(actionCommonData.templateObjects[i]); } for (int j = 0; j < actionCommonData.predefRefParamNames.Count; j++) { refnames.Add(actionCommonData.predefRefParamNames[j]); } } return(true); }
private void Awake() { if (ms_Instance != null) { if (ms_Instance != this) { UnityEngine.Object.DestroyImmediate(base.gameObject); } } else { Debug.Log("WwiseUnity: Initialize sound engine ..."); AkMemSettings settings = new AkMemSettings { uMaxNumPools = 40 }; AkDeviceSettings settings2 = new AkDeviceSettings(); AkSoundEngine.GetDefaultDeviceSettings(settings2); AkStreamMgrSettings settings3 = new AkStreamMgrSettings { uMemorySize = (uint)(this.streamingPoolSize * 0x400) }; AkInitSettings settings4 = new AkInitSettings(); AkSoundEngine.GetDefaultInitSettings(settings4); settings4.uDefaultPoolSize = (uint)(this.defaultPoolSize * 0x400); AkPlatformInitSettings settings5 = new AkPlatformInitSettings(); AkSoundEngine.GetDefaultPlatformInitSettings(settings5); settings5.uLEngineDefaultPoolSize = (uint)(this.lowerPoolSize * 0x400); settings5.fLEngineDefaultPoolRatioThreshold = this.memoryCutoffThreshold; AkMusicSettings settings6 = new AkMusicSettings(); AkSoundEngine.GetDefaultMusicSettings(settings6); if (AkSoundEngine.Init(settings, settings3, settings2, settings4, settings5, settings6) != AKRESULT.AK_Success) { Debug.LogError("WwiseUnity: Failed to initialize the sound engine. Abort."); } else { ms_Instance = this; AkBankPathUtil.UsePlatformSpecificPath(); string platformBasePath = AkBankPathUtil.GetPlatformBasePath(); if (!s_loadBankFromMemory) { } AkSoundEngine.SetBasePath(platformBasePath); AkSoundEngine.SetCurrentLanguage(this.language); if (AkCallbackManager.Init() != AKRESULT.AK_Success) { Debug.LogError("WwiseUnity: Failed to initialize Callback Manager. Terminate sound engine."); AkSoundEngine.Term(); ms_Instance = null; } else { AKRESULT akresult; uint num; Debug.Log("WwiseUnity: Sound engine initialized."); UnityEngine.Object.DontDestroyOnLoad(this); if (s_loadBankFromMemory) { string soundBankPathInResources = GetSoundBankPathInResources("Init.bytes"); CBinaryObject content = Singleton <CResourceManager> .GetInstance().GetResource(soundBankPathInResources, typeof(TextAsset), enResourceType.Sound, false, false).m_content as CBinaryObject; GCHandle handle = GCHandle.Alloc(content.m_data, GCHandleType.Pinned); IntPtr ptr = handle.AddrOfPinnedObject(); if (ptr != IntPtr.Zero) { akresult = AkSoundEngine.LoadBank(ptr, (uint)content.m_data.Length, -1, out num); handle.Free(); } else { akresult = AKRESULT.AK_Fail; } Singleton <CResourceManager> .GetInstance().RemoveCachedResource(soundBankPathInResources); } else { akresult = AkSoundEngine.LoadBank("Init.bnk", -1, out num); } if (akresult != AKRESULT.AK_Success) { Debug.LogError("WwiseUnity: Failed load Init.bnk with result: " + akresult.ToString()); } } } } }
private void Awake() { if (AkInitializer.ms_Instance != null) { if (AkInitializer.ms_Instance != this) { Object.DestroyImmediate(base.gameObject); } return; } Debug.Log("WwiseUnity: Initialize sound engine ..."); AkMemSettings akMemSettings = new AkMemSettings(); akMemSettings.uMaxNumPools = 40u; AkDeviceSettings akDeviceSettings = new AkDeviceSettings(); AkSoundEngine.GetDefaultDeviceSettings(akDeviceSettings); AkStreamMgrSettings akStreamMgrSettings = new AkStreamMgrSettings(); akStreamMgrSettings.uMemorySize = (uint)(this.streamingPoolSize * 1024); AkInitSettings akInitSettings = new AkInitSettings(); AkSoundEngine.GetDefaultInitSettings(akInitSettings); akInitSettings.uDefaultPoolSize = (uint)(this.defaultPoolSize * 1024); AkPlatformInitSettings akPlatformInitSettings = new AkPlatformInitSettings(); AkSoundEngine.GetDefaultPlatformInitSettings(akPlatformInitSettings); akPlatformInitSettings.uLEngineDefaultPoolSize = (uint)(this.lowerPoolSize * 1024); akPlatformInitSettings.fLEngineDefaultPoolRatioThreshold = this.memoryCutoffThreshold; AkMusicSettings akMusicSettings = new AkMusicSettings(); AkSoundEngine.GetDefaultMusicSettings(akMusicSettings); AKRESULT aKRESULT = AkSoundEngine.Init(akMemSettings, akStreamMgrSettings, akDeviceSettings, akInitSettings, akPlatformInitSettings, akMusicSettings); if (aKRESULT != AKRESULT.AK_Success) { Debug.LogError("WwiseUnity: Failed to initialize the sound engine. Abort."); return; } AkInitializer.ms_Instance = this; AkBankPathUtil.UsePlatformSpecificPath(); string platformBasePath = AkBankPathUtil.GetPlatformBasePath(); if (!AkInitializer.s_loadBankFromMemory) { } AkSoundEngine.SetBasePath(platformBasePath); AkSoundEngine.SetCurrentLanguage(this.language); aKRESULT = AkCallbackManager.Init(); if (aKRESULT != AKRESULT.AK_Success) { Debug.LogError("WwiseUnity: Failed to initialize Callback Manager. Terminate sound engine."); AkSoundEngine.Term(); AkInitializer.ms_Instance = null; return; } Debug.Log("WwiseUnity: Sound engine initialized."); Object.DontDestroyOnLoad(this); if (AkInitializer.s_loadBankFromMemory) { string soundBankPathInResources = AkInitializer.GetSoundBankPathInResources("Init.bytes"); CBinaryObject cBinaryObject = Singleton <CResourceManager> .GetInstance().GetResource(soundBankPathInResources, typeof(TextAsset), enResourceType.Sound, false, false).m_content as CBinaryObject; GCHandle gCHandle = GCHandle.Alloc(cBinaryObject.m_data, 3); IntPtr intPtr = gCHandle.AddrOfPinnedObject(); if (intPtr != IntPtr.Zero) { uint num; aKRESULT = AkSoundEngine.LoadBank(intPtr, (uint)cBinaryObject.m_data.Length, -1, out num); gCHandle.Free(); } else { aKRESULT = AKRESULT.AK_Fail; } Singleton <CResourceManager> .GetInstance().RemoveCachedResource(soundBankPathInResources); } else { uint num2; aKRESULT = AkSoundEngine.LoadBank("Init.bnk", -1, out num2); } if (aKRESULT != AKRESULT.AK_Success) { Debug.LogError("WwiseUnity: Failed load Init.bnk with result: " + aKRESULT.ToString()); } }