public static bool IsLoaded(InAudioBankLink bankLink) { if (bankLink == null) return false; return bankLink.IsLoaded; }
private static void DeleteAllNodesFromBanks(InAudioBankLink audioBankLink) { if (audioBankLink._type == AudioBankTypes.Bank) { audioBankLink._bankData.Clear(); } }
//TODO MUSICUPDATE public static void RebuildBanks() { InAudioBankLink rootBank = InAudioInstanceFinder.DataManager.BankLinkTree; InAudioNode audioRoot = InAudioInstanceFinder.DataManager.AudioTree; InMusicNode musicRoot = InAudioInstanceFinder.DataManager.MusicTree; TreeWalker.ForEach(rootBank, DeleteAllNodesFromBanks); TreeWalker.ForEach(audioRoot, node => { var folderData = node._nodeData as InFolderData; SetBankIfNotNull(folderData, rootBank); }); TreeWalker.ForEach(musicRoot, node => { var folderData = node as InMusicFolder; SetBankIfNotNull(folderData, rootBank); }); TreeWalker.ForEach(audioRoot, AddNodesToBank); TreeWalker.ForEach(musicRoot, AddNodesToBank); //Set the bank of the root node if it is missing InFolderData inFolderData = audioRoot._nodeData as InFolderData; if (inFolderData != null && inFolderData.BankLink == null) { inFolderData.BankLink = TreeWalker.FindFirst(rootBank, link => link._type == AudioBankTypes.Bank); } if (inFolderData.BankLink != null) { TreeWalker.ForEach(audioRoot, SetBanks); } }
public static InAudioBankLink CreateBankLink(GameObject go, InAudioBankLink parent, int guid) { var node = CreateNode(go, parent, guid); node._name = parent._name + " Child"; node._type = AudioBankTypes.Bank; return node; }
private static bool LoadBank(InAudioBankLink bankLink) { if (bankLink == null) return false; var bankData = bankLink._bankData; for (int i = 0; i < bankData.Count; i++) { var audioNode = bankData[i].AudioNode; var musicNode = bankData[i].MusicNode; if (audioNode != null) { var data = audioNode._nodeData as InAudioData; if(data != null && data._clip != null) data._clip.LoadIfPossible(); } else if (musicNode != null) { var clips = musicNode._clips; for (int j = 0; j < clips.Count; j++) { if(clips[j] != null) clips[j].LoadIfPossible(); } } } bankLink.IsLoaded = true; return true; }
private static void SetBankIfNotNull(IBankUsage folderData, InAudioBankLink rootBank) { if (folderData != null && folderData.BankConnection == null) { folderData.BankConnection = rootBank; } }
public static void Unload(InAudioBankLink bank) { var bankData = bank._bankData; for (int i = 0; i < bankData.Count; i++) { var data = bankData[i]; var node = data.AudioNode; if (node != null) { var audioData = node._nodeData as InAudioData; if (audioData != null && audioData._clip != null) { audioData._clip.UnloadIfPossible(); } } else if (data.MusicNode != null) { var clips = data.MusicNode._clips; for (int j = 0; j < clips.Count; j++) { var clip = clips[j]; if (clip != null) clip.UnloadIfPossible(); } } } Resources.UnloadUnusedAssets(); bank.IsLoaded = false; }
public void Load(bool forceReload = false) { if (AudioRoot == null || BankLinkRoot == null || BusRoot == null || EventRoot == null || forceReload) { Component[] audioData; Component[] eventData; Component[] busData; Component[] bankLinkData; SaveAndLoad.LoadManagerData(out audioData, out eventData, out busData, out bankLinkData); BusRoot = CheckData <InAudioBus>(busData); AudioRoot = CheckData <InAudioNode>(audioData); EventRoot = CheckData <InAudioEventNode>(eventData); BankLinkTree = CheckData <InAudioBankLink>(bankLinkData); /*if (BusRoot != null) * BusRootGO = BusRoot.gameObject; * if (AudioRoot != null) * AudioRootGO = AudioRoot.gameObject; * if (EventRoot != null) * EventRootGO = EventRoot.gameObject; * if (BankLinkTree != null) * BankLinkRootGO = BankLinkTree.gameObject;*/ } }
public static bool Load(InAudioBankLink bankLink) { if (bankLink == null) return false; return LoadBank(bankLink); }
public static InAudioBankLink CreateBankLink(GameObject go, InAudioBankLink parent, int guid) { var node = CreateNode(go, parent, guid); node._name = parent._name + " Child"; node._type = AudioBankTypes.Bank; return(node); }
private static InAudioBankLink CreateNode(GameObject go, InAudioBankLink parent, int guid) { var node = go.AddComponentUndo<InAudioBankLink>(); node._guid = guid; node.IsFoldedOut = true; node.AssignParent(parent); return node; }
public static void DeleteFolder(InAudioBankLink toDelete) { InUndoHelper.DoInGroup(() => { InUndoHelper.RecordObjectFull(toDelete._parent, "Delete Bank Folder"); toDelete._parent._getChildren.Remove(toDelete); InUndoHelper.Destroy(toDelete); }); }
private static InAudioBankLink CreateNode(GameObject go, InAudioBankLink parent, int guid) { var node = go.AddComponentUndo <InAudioBankLink>(); node._guid = guid; node.IsFoldedOut = true; node.AssignParent(parent); return(node); }
public static void DeleteBank(InAudioBankLink toDelete) { InUndoHelper.DoInGroup(() => { InUndoHelper.RecordObject(InAudioInstanceFinder.DataManager.AudioTree.gameObject.GetComponents <MonoBehaviour>().Add(toDelete).Add(InAudioInstanceFinder.DataManager.MusicTree.gameObject.GetComponents <MonoBehaviour>()), "Bank detele"); toDelete._parent._getChildren.Remove(toDelete); InUndoHelper.Destroy(toDelete); }); }
public static void ChangeMusicNodeBank(InMusicNode node, InAudioBankLink newBank) { var all = GetAllBanks(); InUndoHelper.RecordObject(all.ToArray().AddObj(node), "Changed Bank"); InMusicFolder data = (node as InMusicFolder); data._bankLink = newBank; RebuildBanks(); }
public static void ChangeAudioNodeBank(InAudioNode node, InAudioBankLink newBank) { var all = GetAllBanks(); InUndoHelper.RecordObject(all.ToArray().AddObj(node._nodeData), "Changed Bank"); InFolderData data = (node._nodeData as InFolderData); data.BankLink = newBank; RebuildBanks(); }
/// <summary> /// Unload all audio clips in this banks. Also calls Resources.UnloadUnusedAssets(). Clips will autoreimport if any audio source still referencs this clip /// </summary> /// <param name="bank">The reference to the bank to unload</param> public static void UnloadBank(InAudioBankLink bank) { if (bank != null) { BankLoader.Unload(bank); } else { InDebug.BankUnloadMissing(); } }
private static int DeleteUnusedBanks(InAudioBankLink bankRoot) { #region Standard cleanup Action <InAudioBankLink, HashSet <MonoBehaviour> > bankAction = null; bankAction = (node, set) => { set.Add(node); for (int i = 0; i < node.Children.Count; ++i) { bankAction(node.Children[i], set); } }; int deleteCount = 0; HashSet <MonoBehaviour> objects = new HashSet <MonoBehaviour>(); if (bankRoot != null) { var allNodes = bankRoot.GetComponents <MonoBehaviour>(); for (int i = 0; i < allNodes.Length; ++i) { objects.Add(allNodes[i]); } HashSet <MonoBehaviour> inUse = new HashSet <MonoBehaviour>(); bankAction(bankRoot, inUse); List <string> toDelete = new List <string>(); //Delete all objects not in use foreach (InAudioBankLink node in objects) { if (!inUse.Contains(node)) { ++deleteCount; toDelete.Add(node.ID.ToString()); UndoHelper.PureDestroy(node); } } } #endregion deleteCount += SystemFolderHelper.DeleteUnusedBanks(bankRoot); return(deleteCount); }
public static void Draw(InAudioBankLink bankLink) { EditorGUILayout.BeginVertical(); InUndoHelper.GUIUndo(bankLink, "Name Change", ref bankLink._name, () => EditorGUILayout.TextField("Name", bankLink._name)); if (bankLink._type == AudioBankTypes.Bank) { EditorGUIHelper.DrawID(bankLink._guid); //UndoHelper.GUIUndo(bankLink, "Load async", ref bankLink.LoadASync, () => // EditorGUILayout.Toggle("Load ASync", bankLink.LoadASync)); bool autoLoad = EditorGUILayout.Toggle("Auto load", bankLink._autoLoad); if (autoLoad != bankLink._autoLoad) //Value has changed { InUndoHelper.RecordObjectFull(bankLink, "Bank Auto Load"); bankLink._autoLoad = autoLoad; } Rect lastArea = GUILayoutUtility.GetLastRect(); lastArea.y += 28; lastArea.width = 200; if(GUI.Button(lastArea, "Find Folders using this bank")) { EditorWindow.GetWindow<InAudioWindow>().Find(audioNode => audioNode.GetBank() != bankLink); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (Application.isPlaying) { EditorGUILayout.Toggle("Is Loaded", bankLink.IsLoaded); } } EditorGUILayout.EndVertical(); //UndoCheck.Instance.CheckDirty(node); }
private static void HandleDragging(AudioEventAction currentAction, Rect dragArea) { if (currentAction != null) { if (currentAction is InEventAudioAction) { InAudioNode dragged = OnDragging.DraggingObject <InAudioNode>(dragArea, node => node.IsPlayable); if (dragged != null) { InUndoHelper.RecordObject(currentAction, "Change Action Type"); currentAction.Target = dragged; } } else if (currentAction is InEventBankLoadingAction) { InAudioBankLink dragged = OnDragging.DraggingObject <InAudioBankLink>(dragArea, bank => bank._type == AudioBankTypes.Bank); if (dragged != null) { InUndoHelper.RecordObject(currentAction, "Change Action Type"); currentAction.Target = dragged; } } else if (currentAction is InEventMixerValueAction) { AudioMixer dragged = OnDragging.DraggingObject <AudioMixer>(dragArea); if (dragged != null) { InUndoHelper.RecordObject(currentAction, "Change Action Type"); currentAction.Target = dragged; } } else if (currentAction is InEventMusicControl || currentAction is InEventMusicFade || currentAction is InEventSoloMuteMusic) { InMusicGroup dragged = OnDragging.DraggingObject <InMusicGroup>(dragArea); if (dragged != null) { InUndoHelper.RecordObject(currentAction, "Change Action Type"); currentAction.Target = dragged; } } } }
public static void Draw(InAudioBankLink bankLink) { EditorGUILayout.BeginVertical(); InUndoHelper.GUIUndo(bankLink, "Name Change", ref bankLink._name, () => EditorGUILayout.TextField("Name", bankLink._name)); if (bankLink._type == AudioBankTypes.Bank) { EditorGUIHelper.DrawID(bankLink._guid); //UndoHelper.GUIUndo(bankLink, "Load async", ref bankLink.LoadASync, () => // EditorGUILayout.Toggle("Load ASync", bankLink.LoadASync)); bool autoLoad = EditorGUILayout.Toggle("Auto load", bankLink._autoLoad); if (autoLoad != bankLink._autoLoad) //Value has changed { InUndoHelper.RecordObjectFull(bankLink, "Bank Auto Load"); bankLink._autoLoad = autoLoad; } Rect lastArea = GUILayoutUtility.GetLastRect(); lastArea.y += 28; lastArea.width = 200; if (GUI.Button(lastArea, "Find Folders using this bank")) { EditorWindow.GetWindow <InAudioWindow>().Find(audioNode => audioNode.GetBank() != bankLink); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (Application.isPlaying) { EditorGUILayout.Toggle("Is Loaded", bankLink.IsLoaded); } } EditorGUILayout.EndVertical(); //UndoCheck.Instance.CheckDirty(node); }
public static Texture LookUpIcon <T>(T node) where T : Object, InITreeNode <T> { if (node is InAudioNode) { InAudioNode audioNode = node as InAudioNode; if (audioNode.Type == AudioNodeType.Audio) { return(EditorResources.Audio); } if (audioNode.Type == AudioNodeType.Folder || audioNode.IsRoot) { return(EditorResources.Folder); } if (audioNode.Type == AudioNodeType.Random) { return(EditorResources.Dice); } if (audioNode.Type == AudioNodeType.Sequence) { return(EditorResources.List); } if (audioNode.Type == AudioNodeType.Multi) { return(EditorResources.Tree); } } else if (node is InAudioBankLink) { InAudioBankLink link = node as InAudioBankLink; if (link.Type == AudioBankTypes.Link) { return(EditorResources.Bank); } else { return(EditorResources.Folder); } } return(null); }
public static int DeleteUnusedBanks(InAudioBankLink bankRoot) { if (bankRoot == null) { return(0); } if (!System.IO.Directory.Exists(FolderSettings.FullBankPath)) { return(0); } FileInfo[] banks = GetPrefabsAtPath(FolderSettings.FullBankPath); int deleteCount = 0; for (int i = 0; i < banks.Length; ++i) { string name = banks[i].Name; //Get the ID which is only numbers name = new String(name.Split(new[] { ".prefab" }, StringSplitOptions.RemoveEmptyEntries)[0].Where(Char.IsDigit).ToArray()); InAudioBankLink bankLink = null; int id = Convert.ToInt32(name, 10); if (bankRoot != null) { bankLink = TreeWalker.FindById(bankRoot, id); } if (bankLink == null) { AssetDatabase.DeleteAsset(FolderSettings.BankDeleteDictory + banks[i].Name); ++deleteCount; } } return(deleteCount); }
/// <summary> /// Unload all audio clips in this banks. Also calls Resources.UnloadUnusedAssets(). Clips will autoreimport if any audio source still referencs this clip /// </summary> /// <param name="bank">The reference to the bank to unload</param> public static void UnloadBank(InAudioBankLink bank) { if (bank != null) BankLoader.Unload(bank); else { InDebug.BankUnloadMissing(); } }
public void FindBank(InAudioBankLink bankLink) { selectedToolbar = 0; bankGUI.Find(bankLink); }
public static void SearchFor(InAudioBankLink bank) { EditorWindow.GetWindow <AuxWindow>().FindBank(bank); }
public static void SearchFor(InAudioBankLink bank) { AuxWindow.Launch().FindBank(bank); }
private static void LoadAuto(InAudioBankLink bankLink) { if (bankLink == null) { return; } if (bankLink._autoLoad) Load(bankLink); for (int i = 0; i < bankLink._children.Count; ++i) { LoadAuto(bankLink._children[i]); } }
public static void DeleteBank(InAudioBankLink toDelete) { InUndoHelper.DoInGroup(() => { InUndoHelper.RecordObject(InAudioInstanceFinder.DataManager.AudioTree.gameObject.GetComponents<MonoBehaviour>().Add(toDelete).Add(InAudioInstanceFinder.DataManager.MusicTree.gameObject.GetComponents<MonoBehaviour>()), "Bank detele"); toDelete._parent._getChildren.Remove(toDelete); InUndoHelper.Destroy(toDelete); }); }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { var actions = prop.FindPropertyRelative("Actions"); var labelPos = pos; var labelStyle = GUI.skin.GetStyle("label"); var alignment = labelStyle.alignment; labelStyle.alignment = TextAnchor.MiddleLeft;; labelPos.height = 14; DrawerHelper.BoldLabel(labelPos, prop.FindPropertyRelative("Title").stringValue, labelStyle); for (int i = 0; i < actions.arraySize; ++i) { var currentElement = actions.GetArrayElementAtIndex(i); labelPos.y += LineHeight; labelPos.height = 20; InAudioBankLink bankLink = currentElement.FindPropertyRelative("Bank").objectReferenceValue as InAudioBankLink; if (bankLink != null) { GUI.Label(labelPos, bankLink.GetName, labelStyle); } else { GUI.Label(labelPos, "Missing event", labelStyle); } Rect buttonPos = labelPos; buttonPos.x = pos.width - 172; //Align to right side buttonPos.width = 70; var actionProp = currentElement.FindPropertyRelative("BankAction"); actionProp.enumValueIndex = Convert.ToInt32(EditorGUI.EnumPopup(buttonPos, (BankHookActionType)actionProp.enumValueIndex)); buttonPos.width = 50; buttonPos.x = pos.width - 100; //Align to right side if (bankLink == null) { GUI.enabled = false; } if (GUI.Button(buttonPos, "Find")) { EditorWindow.GetWindow <AuxWindow>().FindBank(bankLink); } GUI.enabled = true; buttonPos.x = pos.width - 44; buttonPos.width = 35; if (GUI.Button(buttonPos, "X")) { actions.DeleteArrayElementAtIndex(i); } } labelPos.y += DragHeight + 4; labelPos.height = DragHeight; GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUI.Button(labelPos, "Drag bank here for " + prop.FindPropertyRelative("Title").stringValue); if (labelPos.Contains(Event.current.mousePosition)) { DrawerHelper.HandleBankDrag(actions); } labelStyle.alignment = alignment; }