public void OnBeforeSerialize() { #if WWISE #if UNITY_EDITOR if (eventName.valueGuid != null && (eventName.valueGuid.Length == 16 && eventName.IsValid())) { guid = eventName.valueGuid; } if (guid != null && string.IsNullOrEmpty(eventGuidString) && guid.Length == 16) { WiseEventDropDownEventStart.LoadData(); eventGuidString = new Guid(guid).ToString().ToUpper(); if (WiseEventDropDownEventStart.wwiseEventNames != null) { if (WiseEventDropDownEventStart.wwiseEventNames.ContainsKey(eventGuidString)) { wwiseEventName = WiseEventDropDownEventStart.wwiseEventNames[eventGuidString]; } } } if (reload) { // WwiseEventStart.Populate(); eventGuidString = new Guid(guid).ToString().ToUpper(); if (WiseEventDropDownEventStart.wwiseEventNames != null) { if (WiseEventDropDownEventStart.wwiseEventNames.ContainsKey(eventGuidString)) { wwiseEventName = WiseEventDropDownEventStart.wwiseEventNames[eventGuidString]; } } } #endif #endif }
public static void Populate() { if (!string.IsNullOrEmpty(WiseEventDropDownEventStart.GetXMLPath()) && UnityEditor.EditorPrefs.GetBool("RELOADWWISE", false) == false) { XmlDocument doc = new XmlDocument(); var xmlPath = WiseEventDropDownEventStart.GetXMLPath(); if (string.IsNullOrEmpty(xmlPath)) { return; } string file = File.ReadAllText(WiseEventDropDownEventStart.GetXMLPath(), Encoding.UTF8); doc.LoadXml(file); string jsonText = JsonConvert.SerializeXmlNode(doc); Debug.Log("<color=blue><b>Wwise Path: </b></color> <i>" + WiseEventDropDownEventStart.GetXMLPath() + "</i>"); Model = WwiseEventModel.FromJson(jsonText); if (Model?.WwiseDocument?.Events?.WorkUnit?.ChildrenList?.Event == null) { return; } wwiseEventNames = new Dictionary <string, string>(); foreach (Event @event in Model.WwiseDocument.Events.WorkUnit.ChildrenList.Event) { string cleanID = @event.Id; cleanID = cleanID.Replace("}", ""); cleanID = cleanID.Replace("{", ""); wwiseEventNames.Add(cleanID.ToUpper(), @event.Name); } UnityEditor.EditorPrefs.SetBool("RELOADWWISE", true); } }