public static AkWwiseProjectData GetData() { if (m_Data == null && Directory.Exists(Path.Combine(Application.dataPath, "Wwise"))) { try { m_Data = (AkWwiseProjectData)AssetDatabase.LoadAssetAtPath(AssetsWwiseProjectDataPath, typeof(AkWwiseProjectData)); if (m_Data == null) { if (!Directory.Exists(Path.Combine(Application.dataPath, WwiseEditorProjectDataDirectory))) { Directory.CreateDirectory(Path.Combine(Application.dataPath, WwiseEditorProjectDataDirectory)); } m_Data = ScriptableObject.CreateInstance <AkWwiseProjectData>(); string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(AssetsWwiseProjectDataPath); AssetDatabase.CreateAsset(m_Data, assetPathAndName); } } catch (Exception e) { Debug.Log("WwiseUnity: Unable to load Wwise Data: " + e.ToString()); } } return(m_Data); }
public static AkWwiseProjectData GetData() { if (m_Data == null && Directory.Exists(Path.Combine(Application.dataPath, "Wwise"))) { try { m_Data = (AkWwiseProjectData)AssetDatabase.LoadAssetAtPath("Assets/Wwise/Editor/ProjectData/AkWwiseProjectData.asset", typeof(AkWwiseProjectData)); // Create the asset only when not running in batch mode. string[] arguments = Environment.GetCommandLineArgs(); if (m_Data == null && Array.IndexOf(arguments, "-batchmode") == -1) { m_Data = ScriptableObject.CreateInstance <AkWwiseProjectData>(); string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath("Assets/Wwise/Editor/ProjectData/AkWwiseProjectData.asset"); AssetDatabase.CreateAsset(m_Data, assetPathAndName); } } catch (Exception e) { Debug.Log("Unable to load Wwise Data: " + e.ToString()); } } return(m_Data); }
public static AkWwiseProjectData GetData() { if (m_Data == null && Directory.Exists(Path.Combine(Application.dataPath, "Wwise"))) { try { m_Data = (AkWwiseProjectData)AssetDatabase.LoadAssetAtPath("Assets/Wwise/Editor/ProjectData/AkWwiseProjectData.asset", typeof(AkWwiseProjectData)); // Create the asset only when not running in batch mode. string[] arguments = Environment.GetCommandLineArgs(); if (m_Data == null && Array.IndexOf(arguments, "-batchmode") == -1) { m_Data = ScriptableObject.CreateInstance<AkWwiseProjectData>(); string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath("Assets/Wwise/Editor/ProjectData/AkWwiseProjectData.asset"); AssetDatabase.CreateAsset(m_Data, assetPathAndName); } } catch( Exception e ) { Debug.Log("Unable to load Wwise Data: " + e.ToString()); } } return m_Data; }
public static AkWwiseProjectData GetData() { if (m_Data == null && System.IO.Directory.Exists(System.IO.Path.Combine(UnityEngine.Application.dataPath, "Wwise"))) { try { m_Data = UnityEditor.AssetDatabase.LoadAssetAtPath <AkWwiseProjectData>(AssetsWwiseProjectDataPath); if (m_Data == null) { if (!System.IO.Directory.Exists(System.IO.Path.Combine(UnityEngine.Application.dataPath, WwiseEditorProjectDataDirectory))) { System.IO.Directory.CreateDirectory(System.IO.Path.Combine(UnityEngine.Application.dataPath, WwiseEditorProjectDataDirectory)); } m_Data = UnityEngine.ScriptableObject.CreateInstance <AkWwiseProjectData>(); var assetPathAndName = UnityEditor.AssetDatabase.GenerateUniqueAssetPath(AssetsWwiseProjectDataPath); UnityEditor.AssetDatabase.CreateAsset(m_Data, assetPathAndName); } } catch (System.Exception e) { UnityEngine.Debug.Log("WwiseUnity: Unable to load Wwise Data: " + e); } } return(m_Data); }
public void SetRootItem(string Header, AkWwiseProjectData.WwiseObjectType ObjType) { RootItem.Items.Clear(); RootItem.Header = Header; RootItem.DataContext = new AkTreeInfo(0, ObjType); AddHandlerEvents(RootItem); RootItem.IsExpanded = GetExpansionStatus("/" + RootItem.Header); }
static void SetCurrentConfig(string config) { FieldInfo CurrentPluginConfigField = typeof(AkWwiseProjectData).GetField("CurrentPluginConfig"); AkWwiseProjectData data = AkWwiseProjectInfo.GetData(); if (CurrentPluginConfigField != null) { CurrentPluginConfigField.SetValue(data, config); } EditorUtility.SetDirty(AkWwiseProjectInfo.GetData()); }
public static AkWwiseProjectData GetData() { if (m_Data == null && WwiseFolderExists()) { try { m_Data = UnityEditor.AssetDatabase.LoadAssetAtPath<AkWwiseProjectData>(DataAssetPath); if (m_Data == null) { var dataAbsolutePath = System.IO.Path.Combine(UnityEngine.Application.dataPath, DataRelativePath); var dataExists = System.IO.File.Exists(dataAbsolutePath); if (!dataExists) { var dataAbsoluteDirectory = System.IO.Path.Combine(UnityEngine.Application.dataPath, DataRelativeDirectory); if (!System.IO.Directory.Exists(dataAbsoluteDirectory)) System.IO.Directory.CreateDirectory(dataAbsoluteDirectory); } m_Data = UnityEngine.ScriptableObject.CreateInstance<AkWwiseProjectData>(); if (dataExists) UnityEngine.Debug.LogWarning("WwiseUnity: Unable to load asset at <" + dataAbsolutePath + ">."); else { #if UNITY_2019_3_OR_LATER if (UnityEditor.EditorSettings.assetPipelineMode == UnityEditor.AssetPipelineMode.Version2) { UnityEditor.EditorApplication.delayCall += () => UnityEditor.AssetDatabase.CreateAsset(m_Data, DataAssetPath); } else #else { UnityEditor.AssetDatabase.CreateAsset(m_Data, DataAssetPath); } #endif } } } catch (System.Exception e) { UnityEngine.Debug.LogError("WwiseUnity: Unable to load Wwise Data: " + e); } } return m_Data; }
// Use reflection because projects that were created in Unity 4 won't have the CurrentPluginConfig field public static string GetCurrentConfig() { FieldInfo CurrentPluginConfigField = typeof(AkWwiseProjectData).GetField("CurrentPluginConfig"); string CurrentConfig = string.Empty; AkWwiseProjectData data = AkWwiseProjectInfo.GetData(); if (CurrentPluginConfigField != null && data != null) { CurrentConfig = (string)CurrentPluginConfigField.GetValue(data); } if (string.IsNullOrEmpty(CurrentConfig)) { CurrentConfig = CONFIG_PROFILE; } return(CurrentConfig); }
private static void CreateWwiseProjectData() { ProjectData = UnityEngine.ScriptableObject.CreateInstance <AkWwiseProjectData>(); //ProjectData is null when CreateInstance is called too early during editor initialization if (ProjectData != null) { //Handle edge cases where we might queue up multiple calls to CreateWwiseProjectData //This happens on editor open if the asset is deleted while Unity is closed if (!UnityEditor.AssetDatabase.Contains(ProjectData)) { Debug.Log("WwiseUnity : Created new AkWwiseProjectData asset"); UnityEditor.AssetDatabase.CreateAsset(ProjectData, s_dataAssetPath); } } else { Debug.Log("WwiseUnity : Can't create AkWwiseProjectData asset because it is null"); } }
public static AkWwiseProjectData GetData() { if (m_Data == null && WwiseFolderExists()) { try { m_Data = UnityEditor.AssetDatabase.LoadAssetAtPath <AkWwiseProjectData>(DataAssetPath); if (m_Data == null) { var dataAbsolutePath = System.IO.Path.Combine(UnityEngine.Application.dataPath, DataRelativePath); var dataExists = System.IO.File.Exists(dataAbsolutePath); if (!dataExists) { var dataAbsoluteDirectory = System.IO.Path.Combine(UnityEngine.Application.dataPath, DataRelativeDirectory); if (!System.IO.Directory.Exists(dataAbsoluteDirectory)) { System.IO.Directory.CreateDirectory(dataAbsoluteDirectory); } } m_Data = UnityEngine.ScriptableObject.CreateInstance <AkWwiseProjectData>(); if (dataExists) { UnityEngine.Debug.LogWarning("WwiseUnity: Unable to load asset at <" + dataAbsolutePath + ">."); } else { UnityEditor.AssetDatabase.CreateAsset(m_Data, DataAssetPath); } } } catch (System.Exception e) { UnityEngine.Debug.LogError("WwiseUnity: Unable to load Wwise Data: " + e); } } return(m_Data); }
TreeViewItem AddPathToTreeItem(TreeViewItem item, AkWwiseProjectData.AkInformation AkInfo) { TreeViewItem parentItem = item; string path = "/" + RootItem.Header + "/" + item.Header; for (int i = 0; i < AkInfo.PathAndIcons.Count; i++ ) { AkWwiseProjectData.PathElement PathElem = AkInfo.PathAndIcons[i]; TreeViewItem childItem = parentItem.FindItemByName(PathElem.ElementName); path = path + "/" + PathElem.ElementName; if (childItem == null) { if (i != AkInfo.PathAndIcons.Count - 1) { childItem = parentItem.AddItem(PathElem.ElementName, new AkTreeInfo(0, Guid.Empty.ToByteArray(), PathElem.ObjectType), GetExpansionStatus(path)); } else { if (PathElem.ObjectType == AkWwiseProjectData.WwiseObjectType.STATEGROUP || PathElem.ObjectType == AkWwiseProjectData.WwiseObjectType.SWITCHGROUP) { childItem = parentItem.AddItem(PathElem.ElementName, false, GetExpansionStatus(path), new AkTreeInfo(AkInfo.ID, AkInfo.Guid, PathElem.ObjectType)); } else { childItem = parentItem.AddItem(PathElem.ElementName, true, GetExpansionStatus(path), new AkTreeInfo(AkInfo.ID, AkInfo.Guid, PathElem.ObjectType)); } } } AddHandlerEvents(childItem); parentItem = childItem; } return parentItem; }
public AkTreeInfo(int id, byte[] guid, AkWwiseProjectData.WwiseObjectType objType) { ID = id; ObjectType = objType; Guid = guid; }
public AkTreeInfo(int id, AkWwiseProjectData.WwiseObjectType objType) { ID = id; ObjectType = objType; }
string GetObjectType(AkWwiseProjectData.WwiseObjectType item) { string type = "undefined"; switch (item) { case AkWwiseProjectData.WwiseObjectType.AUXBUS: type = "AuxBus"; break; case AkWwiseProjectData.WwiseObjectType.EVENT: type = "Event"; break; case AkWwiseProjectData.WwiseObjectType.SOUNDBANK: type = "Bank"; break; case AkWwiseProjectData.WwiseObjectType.STATE: type = "State"; break; case AkWwiseProjectData.WwiseObjectType.SWITCH: type = "Switch"; break; } return type; }
public static void Create(AkWwiseProjectData.WwiseObjectType in_type, SerializedProperty[] in_guid, SerializedObject in_serializedObject, Rect in_pos) { if(s_componentPicker == null) { s_componentPicker = ScriptableObject.CreateInstance<AkWwiseComponentPicker> (); //position the window below the button Rect pos = new Rect (in_pos.x, in_pos.yMax, 0, 0); //If the window gets out of the screen, we place it on top of the button instead if(in_pos.yMax > (Screen.currentResolution.height / 2)) { pos.y = in_pos.y - (Screen.currentResolution.height / 2); } //We show a drop down window which is automatically destoyed when focus is lost s_componentPicker.ShowAsDropDown(pos, new Vector2 (in_pos.width >= 250 ? in_pos.width : 250, Screen.currentResolution.height / 2)); s_componentPicker.m_selectedItemGuid = in_guid; s_componentPicker.m_serializedObject = in_serializedObject; s_componentPicker.m_type = in_type; //Make a backup of the tree's expansion status and replace it with an empty list to make sure nothing will get expanded //when we populate the tree List<string> expandedItemsBackUp = AkWwiseProjectInfo.GetData ().ExpandedItems; AkWwiseProjectInfo.GetData ().ExpandedItems = new List<string> (); s_componentPicker.m_treeView.AssignDefaults(); s_componentPicker.m_treeView.SetRootItem(System.IO.Path.GetFileNameWithoutExtension(WwiseSetupWizard.Settings.WwiseProjectPath), AkWwiseProjectData.WwiseObjectType.PROJECT); //Populate the tree with the correct type if(in_type == AkWwiseProjectData.WwiseObjectType.EVENT) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Events", AkWwiseProjectInfo.GetData().EventWwu); } else if(in_type == AkWwiseProjectData.WwiseObjectType.SWITCH) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Switches", AkWwiseProjectInfo.GetData().SwitchWwu); } else if(in_type == AkWwiseProjectData.WwiseObjectType.STATE) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "States", AkWwiseProjectInfo.GetData().StateWwu); } else if(in_type == AkWwiseProjectData.WwiseObjectType.SOUNDBANK) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Banks", AkWwiseProjectInfo.GetData().BankWwu); } else if(in_type == AkWwiseProjectData.WwiseObjectType.AUXBUS) { s_componentPicker.m_treeView.PopulateItem(s_componentPicker.m_treeView.RootItem, "Auxiliary Busses", AkWwiseProjectInfo.GetData().AuxBusWwu); } TreeViewItem item = s_componentPicker.m_treeView.GetItemByGuid(new Guid(AkUtilities.GetByteArrayProperty( in_guid[0]))); if(item != null) { item.ParentControl.SelectedItem = item; int itemIndexFromRoot = 0; //Expand all the parents of the selected item. //Count the number of items that are displayed before the selected item while(true) { item.IsExpanded = true; if(item.Parent != null) { itemIndexFromRoot += item.Parent.Items.IndexOf(item) + 1; item = item.Parent; } else { break; } } //Scroll down the window to make sure that the selected item is always visible when the window opens float itemHeight = item.ParentControl.m_skinSelected.button.CalcSize(new GUIContent(item.Header)).y + 2.0f; //there seems to be 1 pixel between each item so we add 2 pixels(top and bottom) s_componentPicker.m_treeView.SetScrollViewPosition(new Vector2(0.0f, (itemHeight*itemIndexFromRoot)-(Screen.currentResolution.height / 4))); } //Restore the tree's expansion status AkWwiseProjectInfo.GetData ().ExpandedItems = expandedItemsBackUp; } }
static void SortValues(AkWwiseProjectData.GroupValue groupToSort) { if (groupToSort.values.Count > 0) { tmpData[] listToSort = new tmpData[groupToSort.values.Count]; for (int i = 0; i < groupToSort.values.Count; i++) { listToSort[i] = new tmpData(); listToSort[i].valueName = groupToSort.values[i]; listToSort[i].pathElem = groupToSort.ValueIcons[i]; listToSort[i].ID = groupToSort.valueIDs[i]; listToSort[i].Guid = groupToSort.ValueGuids[i]; } Array.Sort(listToSort, s_comparetmpDataByName); for (int i = 0; i < groupToSort.values.Count; i++) { groupToSort.values[i] = listToSort[i].valueName; groupToSort.ValueIcons[i] = listToSort[i].pathElem; groupToSort.valueIDs[i] = listToSort[i].ID; groupToSort.ValueGuids[i] = listToSort[i].Guid; } } }
static void ReplaceWwuEntry(string in_currentPhysicalPath, AssetType in_type, out AkWwiseProjectData.WorkUnit out_wwu, out int out_wwuIndex) { ArrayList list = AkWwiseProjectInfo.GetData ().GetWwuListByString (in_type.RootDirectoryName); out_wwuIndex = list.BinarySearch (new AkWwiseProjectData.WorkUnit (in_currentPhysicalPath), AkWwiseProjectData.s_compareByPhysicalPath); out_wwu = AkWwiseProjectInfo.GetData ().NewChildWorkUnit (in_type.RootDirectoryName); if(out_wwuIndex < 0) { out_wwuIndex = ~out_wwuIndex; list.Insert(out_wwuIndex, out_wwu); } else { list[out_wwuIndex] = out_wwu; } }
static void CreateNewWwuEntry(AssetType in_type, out AkWwiseProjectData.WorkUnit out_wwu, out int out_wwuIndex) { out_wwu = AkWwiseProjectInfo.GetData ().NewChildWorkUnit (in_type.RootDirectoryName); ArrayList list = AkWwiseProjectInfo.GetData ().GetWwuListByString (in_type.RootDirectoryName); list.Add (out_wwu); out_wwuIndex = list.Count - 1; }