public override void ItemSelected(AkWwiseTreeViewItem item) { if (AutoSyncSelection) { SelectObjectInAuthoring(item.objectGuid); } }
void Preload(AkWwiseTreeViewItem parent, TreeViewState treeState) { if (parent == null) { return; } if (!CheckIfFullyLoaded(parent)) { AkWaapiUtilities.GetResultListDelegate <WwiseObjectInfoJsonObject> callback = (List <WwiseObjectInfoJsonObject> items) => { UpdateParentWithLoadedChildren(parent.objectGuid, AkWaapiUtilities.ParseObjectInfo(items)); }; AkWaapiUtilities.GetChildren(parent.objectGuid, waapiWwiseObjectOptions, callback); } //Preload one level of hidden items. if (IsExpanded(treeState, parent.id) || (parent.parent != null && IsExpanded(treeState, parent.parent.id)) || parent.id == ProjectRoot.id) { foreach (AkWwiseTreeViewItem childItem in parent.children) { Preload(childItem, treeState); } } }
public void AddItemWithAncestors(List <WwiseObjectInfo> infoItems, bool selectAfterCreated = false) { var parent = ProjectRoot; //Items obtained from the WAAPI call are sorted by path so we can simply iterate over them foreach (var infoItem in infoItems) { var newItem = Find(infoItem.objectGUID); if (newItem == null) { newItem = new AkWwiseTreeViewItem(infoItem, GenerateUniqueID(), parent.depth + 1); Data.Add(newItem); parent.AddWwiseItemChild(newItem); } if (!CheckIfFullyLoaded(parent)) { System.Guid guid = new System.Guid(parent.objectGuid.ToString()); AkWaapiUtilities.GetResultListDelegate <WwiseObjectInfoJsonObject> callback = (List <WwiseObjectInfoJsonObject> items) => { UpdateParentWithLoadedChildren(guid, AkWaapiUtilities.ParseObjectInfo(items)); }; AkWaapiUtilities.GetChildren(parent.objectGuid, waapiWwiseObjectOptions, callback); } parent = newItem; } if (selectAfterCreated) { treeviewCommandQueue.Enqueue(new TreeViewCommand(() => Expand(parent.objectGuid, true))); } }
void CellGUI(UnityEngine.Rect cellRect, AkWwiseTreeViewItem item, ObjectColumns column, ref RowGUIArgs args) { // Center cell rect vertically (makes it easier to place controls, icons etc in the cells) CenterRectUsingSingleLineHeight(ref cellRect); switch (column) { case ObjectColumns.Name: { UnityEngine.Rect iconRect = new UnityEngine.Rect(cellRect); iconRect.x += GetContentIndent(item); iconRect.width = AkWwisePickerIcons.kIconWidth; UnityEngine.GUI.DrawTexture(iconRect, icons.GetIcon(item.objectType), UnityEngine.ScaleMode.ScaleToFit); //// Default icon and label args.rowRect = cellRect; base.RowGUI(args); } break; case ObjectColumns.Guid: { UnityEngine.GUI.Label(cellRect, item.objectGuid.ToString()); } break; case ObjectColumns.Depth: { UnityEngine.GUI.Label(cellRect, item.depth.ToString()); } break; } }
private void PlayPauseItem(AkWwiseTreeViewItem item) { if (m_treeView != null && m_treeView.CheckWaapi()) { AkWaapiUtilities.TogglePlayEvent(item.objectType, item.objectGuid); } }
public static void TreeToList(AkWwiseTreeViewItem root, IList <AkWwiseTreeViewItem> result) { if (root == null) { return; } if (result == null) { return; } result.Clear(); Stack <AkWwiseTreeViewItem> stack = new Stack <AkWwiseTreeViewItem>(); stack.Push(root); while (stack.Count > 0) { AkWwiseTreeViewItem current = stack.Pop(); result.Add(current); if (current.children != null && current.children.Count > 0) { for (int i = current.children.Count - 1; i >= 0; i--) { if (current.children[i] != null) { stack.Push((AkWwiseTreeViewItem)current.children[i]); } } } } }
void AddChildrenRecursive(AkWwiseTreeViewItem parent, IList <AkWwiseTreeViewItem> newRows) { if (parent == null) { return; } foreach (AkWwiseTreeViewItem child in parent.children) { var item = new AkWwiseTreeViewItem(child); item.parent = parent; item.children = child.children; newRows.Add(item); if (child.children.Count > 0) { if (TestExpanded(child)) { AddChildrenRecursive(child, newRows); } else { item.children = AkWwiseTreeDataSource.CreateCollapsedChild(); } } } }
public override AkWwiseTreeViewItem GetSearchResults() { if (SearchRoot == null) { SearchRoot = new AkWwiseTreeViewItem(ProjectRoot); } return(SearchRoot); }
public string GetProjectPath(AkWwiseTreeViewItem item, string currentpath) { currentpath = $"/{item.name}{currentpath}"; if (item.parent == null || item.parent == ProjectRoot) { return(currentpath); } return(GetProjectPath(item.parent as AkWwiseTreeViewItem, currentpath)); }
public static void CopyTree(AkWwiseTreeViewItem sourceRoot, AkWwiseTreeViewItem destRoot) { for (int i = 0; i < sourceRoot.children.Count(); i++) { var currItem = sourceRoot.children[i]; var newItem = new AkWwiseTreeViewItem(currItem as AkWwiseTreeViewItem); CopyTree(currItem as AkWwiseTreeViewItem, newItem); destRoot.AddWwiseItemChild(newItem); } }
public IList <int> GetDescendantsThatHaveChildren(int id) { AkWwiseTreeViewItem searchFromThis = Find(id); if (searchFromThis != null) { return(GetParentsBelowStackBased(searchFromThis)); } return(new List <int>()); }
public override AkWwiseTreeViewItem GetComponentDataRoot(WwiseObjectType objectType) { if (!wwiseObjectFolders.ContainsKey(objectType)) { ProjectRoot.AddWwiseItemChild(BuildObjectTypeTree(objectType)); } var tempProjectRoot = new AkWwiseTreeViewItem(ProjectRoot); tempProjectRoot.AddWwiseItemChild(wwiseObjectFolders[objectType]); return(tempProjectRoot); }
void OnWaapiChildAdded(string json) { var added = AkWaapiUtilities.ParseChildAddedOrRemoved(json); if (added.childInfo.type == WwiseObjectType.None) { return; } var parent = Find(added.parentInfo.objectGUID); // New object created, but parent is not loaded yet, so we can ignore it if (parent == null) { return; } var child = Find(added.childInfo.objectGUID); if (child == null) { child = new AkWwiseTreeViewItem(added.childInfo, GenerateUniqueID(), parent.depth + 1); } else { child.numChildren = added.childInfo.childrenCount; child.displayName = added.childInfo.name; } parent.AddWwiseItemChild(child); Data.Add(child); parent.numChildren = added.parentInfo.childrenCount; child.depth = parent.depth + 1; if (!CheckIfFullyLoaded(parent)) { AkWaapiUtilities.GetResultListDelegate <WwiseObjectInfoJsonObject> callback = (List <WwiseObjectInfoJsonObject> items) => { UpdateParentWithLoadedChildren(parent.objectGuid, AkWaapiUtilities.ParseObjectInfo(items)); }; AkWaapiUtilities.GetChildren(parent.objectGuid, waapiWwiseObjectOptions, callback); } if (!CheckIfFullyLoaded(child)) { AkWaapiUtilities.GetResultListDelegate <WwiseObjectInfoJsonObject> callback = (List <WwiseObjectInfoJsonObject> items) => { UpdateParentWithLoadedChildren(child.objectGuid, AkWaapiUtilities.ParseObjectInfo(items)); }; AkWaapiUtilities.GetChildren(child.objectGuid, waapiWwiseObjectOptions, callback); } ScheduleRebuild(); }
private bool TestExpanded(AkWwiseTreeViewItem node) { if (node.children.Count > 0) { if (node.depth == -1) { return(true); } return(IsExpanded(node.id)); } return(false); }
public void HighlightItem(AkWwiseTreeViewItem item, bool select) { if (item != null) { FrameItem(item.id); if (select) { SetSelection(new List <int>() { item.id }); } SetDirty(); } }
private void FireSearch(object sender, System.Timers.ElapsedEventArgs e) { if (SearchRoot == null) { SearchRoot = new AkWwiseTreeViewItem(ProjectRoot); } SearchRoot.children.Clear(); SearchItems = new List <AkWwiseTreeViewItem>(new[] { SearchRoot }); TreeUtility.TreeToList(SearchRoot, SearchItems); AkWaapiUtilities.GetResultListDelegate <WwiseObjectInfoJsonObject> callback = (List <WwiseObjectInfoJsonObject> items) => { AddSearchResults(AkWaapiUtilities.ParseObjectInfo(items)); }; AkWaapiUtilities.Search(searchString, searchObjectTypeFilter, waapiWwiseObjectOptions, callback); }
public override void UpdateSearchResults(string searchString, WwiseObjectType objectType) { SearchRoot = new AkWwiseTreeViewItem(ProjectRoot); if (objectType != WwiseObjectType.None) { SearchRoot = new AkWwiseTreeViewItem(ProjectRoot); var objectRoot = new AkWwiseTreeViewItem(wwiseObjectFolders[objectType]); TreeUtility.CopyTree(wwiseObjectFolders[objectType], objectRoot); SearchRoot.AddWwiseItemChild(objectRoot); } else { TreeUtility.CopyTree(ProjectRoot, SearchRoot); } FilterTree(SearchRoot, searchString); }
private AkWwiseTreeViewItem AddTreeItem(AkWwiseTreeViewItem parentWorkUnit, List <AkWwiseProjectData.PathElement> pathAndIcons) { var pathDepth = pathAndIcons.Count; var treeDepth = pathDepth + 1; AkWwiseTreeViewItem newItem; AkWwiseProjectData.PathElement pathElem; var parent = parentWorkUnit; if (pathDepth > parentWorkUnit.depth) { var unaccountedDepth = pathDepth - parentWorkUnit.depth; for (; unaccountedDepth > 0; unaccountedDepth--) { var pathIndex = pathAndIcons.Count - unaccountedDepth; pathElem = pathAndIcons[pathIndex]; if (pathElem.ObjectGuid == System.Guid.Empty) { var path = AkWwiseProjectData.PathElement.GetProjectPathString(pathAndIcons, pathIndex); newItem = Find(pathElem.ObjectGuid, pathElem.ElementName, path); } else { newItem = Find(pathElem.ObjectGuid, pathElem.ElementName); } if (newItem == null) { newItem = new AkWwiseTreeViewItem(pathElem.ElementName, treeDepth - unaccountedDepth, GenerateUniqueID(), pathElem.ObjectGuid, pathElem.ObjectType); parent.AddWwiseItemChild(newItem); Data.Add(newItem); } parent = newItem; } } pathElem = pathAndIcons.Last(); newItem = Find(pathElem.ObjectGuid); if (newItem == null) { newItem = new AkWwiseTreeViewItem(pathElem.ElementName, treeDepth, GenerateUniqueID(), pathElem.ObjectGuid, pathElem.ObjectType); parent.AddWwiseItemChild(newItem); Data.Add(newItem); } return(newItem); }
private AkWwiseTreeViewItem BuildTree(string name, List <AkWwiseProjectData.AkInfoWorkUnit> workUnits) { var rootFolder = new AkWwiseTreeViewItem(name, 1, GenerateUniqueID(), System.Guid.Empty, WwiseObjectType.PhysicalFolder); foreach (var wwu in workUnits) { var wwuElement = AddTreeItem(rootFolder, wwu.PathAndIcons); if (wwu.List.Count > 0) { foreach (var akInfo in wwu.List) { AddTreeItem(wwuElement, akInfo.PathAndIcons); } } } return(rootFolder); }
internal static void FindReferencesInScene(AkWwiseTreeViewItem item) { var reference = WwiseObjectReference.FindWwiseObject(item.objectType, item.objectGuid); var path = UnityEditor.AssetDatabase.GetAssetPath(reference); if (path.IndexOf(' ') != -1) { path = '"' + path + '"'; } if (path == string.Empty) { UnityEngine.Debug.Log($"No references to {item.displayName} in scene."); return; } #if !UNITY_2019_1_OR_NEWER //drop "Assets" part of path path = string.Join("/", path.Split('/').Skip(1)); #endif var searchFilter = "ref:" + path; System.Type type = typeof(UnityEditor.SearchableEditorWindow); System.Reflection.FieldInfo info = type.GetField("searchableWindows", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); var searchableWindows = info.GetValue(null) as List <UnityEditor.SearchableEditorWindow>; foreach (UnityEditor.SearchableEditorWindow sw in searchableWindows) { info = type.GetField("m_HierarchyType", System.Reflection.BindingFlags.NonPublic); if (sw.GetType().ToString() == "UnityEditor.SceneHierarchyWindow") { if (sw.GetType().ToString() == "UnityEditor.SceneHierarchyWindow") { System.Reflection.MethodInfo setSearchFilter = typeof(UnityEditor.SearchableEditorWindow).GetMethod( "SetSearchFilter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); object[] parameters = new object[] { searchFilter, 0, false, false }; setSearchFilter.Invoke(sw, parameters); sw.Repaint(); } } } }
protected AkWwiseTreeViewItem BuildObjectTypeTree(WwiseObjectType objectType) { var rootElement = new AkWwiseTreeViewItem(); switch (objectType) { case WwiseObjectType.AuxBus: rootElement = BuildTree("Master-Mixer Hierarchy", AkWwiseProjectInfo.GetData().AuxBusWwu); break; case WwiseObjectType.Event: rootElement = BuildTree("Events", AkWwiseProjectInfo.GetData().EventWwu); break; case WwiseObjectType.Soundbank: rootElement = BuildTree("SoundBanks", AkWwiseProjectInfo.GetData().BankWwu); break; case WwiseObjectType.State: rootElement = BuildTree("States", AkWwiseProjectInfo.GetData().StateWwu); break; case WwiseObjectType.Switch: case WwiseObjectType.SwitchGroup: rootElement = BuildTree("Switches", AkWwiseProjectInfo.GetData().SwitchWwu); break; case WwiseObjectType.GameParameter: rootElement = BuildTree("Game Parameters", AkWwiseProjectInfo.GetData().RtpcWwu); break; case WwiseObjectType.Trigger: rootElement = BuildTree("Triggers", AkWwiseProjectInfo.GetData().TriggerWwu); break; case WwiseObjectType.AcousticTexture: rootElement = BuildTree("Virtual Acoustics", AkWwiseProjectInfo.GetData().AcousticTextureWwu); break; } wwiseObjectFolders[objectType] = rootElement; return(rootElement); }
void FilterTree(AkWwiseTreeViewItem treeElement, string searchFilter) { var ItemsToRemove = new List <AkWwiseTreeViewItem>(); for (int i = 0; i < treeElement.children.Count(); i++) { var current = treeElement.children[i] as AkWwiseTreeViewItem; FilterTree(current, searchFilter); if (current.name.IndexOf(searchFilter, System.StringComparison.OrdinalIgnoreCase) == -1 && current.children.Count == 0) { ItemsToRemove.Add(current); } } for (int i = 0; i < ItemsToRemove.Count(); i++) { treeElement.children.Remove(ItemsToRemove[i]); } }
bool CheckIfFullyLoaded(AkWwiseTreeViewItem item) { if (item == ProjectRoot) { return(true); } if (item.objectType == WwiseObjectType.Event) { return(true); } if (item.numChildren != item.children.Count) { return(false); } if (item.children.Contains(null)) { return(false); } return(true); }
public AkWwiseTreeViewItem BuildTree(string name, List <AkWwiseProjectData.GroupValWorkUnit> workUnits) { var rootFolder = new AkWwiseTreeViewItem(name, 1, GenerateUniqueID(), System.Guid.Empty, WwiseObjectType.PhysicalFolder); foreach (var wwu in workUnits) { var wwuItem = AddTreeItem(rootFolder, wwu.PathAndIcons); foreach (var group in wwu.List) { var groupElement = AddTreeItem(wwuItem, group.PathAndIcons); foreach (var child in group.values) { AddTreeItem(groupElement, child.PathAndIcons); } } } return(rootFolder); }
bool ValidateNameChange(AkWwiseTreeViewItem item, string newName) { if (item == null) { UnityEngine.Debug.LogWarning("Tree item no longer exists"); return(false); } if (newName.Trim() == System.String.Empty) { UnityEngine.Debug.LogWarning("Names cannot be left blank"); return(false); } if (newName.Trim().Length >= MAX_NAME_LENGTH) { UnityEngine.Debug.LogWarning($"Names must be less than {MAX_NAME_LENGTH} characters long."); return(false); } // If the new name is the same as the old name, consider this to be unchanged if (item.displayName == newName) { return(false); } if (newName.Contains('/') || newName.Contains('\\')) { UnityEngine.Debug.LogWarning("Item names cannot contain / or \\."); return(false); } // Validate that an item with this name doesn't exist already if (item.parent.children.Find((i) => i.displayName == newName) != null) { UnityEngine.Debug.LogWarning("An item with this name already exists at this level"); return(false); } return(true); }
IList <int> GetParentsBelowStackBased(AkWwiseTreeViewItem searchFromThis) { Stack <AkWwiseTreeViewItem> stack = new Stack <AkWwiseTreeViewItem>(); stack.Push(searchFromThis); var parentsBelow = new List <int>(); while (stack.Count > 0) { AkWwiseTreeViewItem current = stack.Pop(); if (current.hasChildren) { parentsBelow.Add(current.id); foreach (AkWwiseTreeViewItem el in current.children) { stack.Push(el); } } } return(parentsBelow); }
private void AddItemToSearch(AkWwiseTreeViewItem sourceItem) { var matchItem = new AkWwiseTreeViewItem(sourceItem); SearchItems.Add(matchItem); var sourceParent = sourceItem.parent as AkWwiseTreeViewItem; var parentCopy = Find(SearchItems, sourceParent.objectGuid); if (parentCopy != null) { parentCopy.AddWwiseItemChild(matchItem); return; } else { parentCopy = new AkWwiseTreeViewItem(sourceParent); parentCopy.AddWwiseItemChild(matchItem); SearchItems.Add(parentCopy); var nextParent = sourceParent.parent as AkWwiseTreeViewItem; while (nextParent != null) { var parentInSearchItems = Find(SearchItems, nextParent.objectGuid); if (parentInSearchItems != null) { parentInSearchItems.AddWwiseItemChild(parentCopy); break; } parentInSearchItems = new AkWwiseTreeViewItem(nextParent); parentInSearchItems.AddWwiseItemChild(parentCopy); SearchItems.Add(parentInSearchItems); parentCopy = parentInSearchItems; nextParent = nextParent.parent as AkWwiseTreeViewItem; } } }
public void AddItems(List <WwiseObjectInfo> infoItems) { foreach (var infoItem in infoItems) { if (infoItem.type == WwiseObjectType.None) { continue; } var tParent = Find(infoItem.parentID); if (tParent == null || tParent == ProjectRoot) { tParent = ProjectRoot; } var tChild = Find(infoItem.objectGUID); if (tChild == null) { tChild = new AkWwiseTreeViewItem(infoItem, GenerateUniqueID(), tParent.depth + 1); Data.Add(tChild); tParent.AddWwiseItemChild(tChild); } } }
public virtual void ItemSelected(AkWwiseTreeViewItem itemID) { }