Exemplo n.º 1
0
        public static InAudioBankLink CreateBank(GameObject go, InAudioBankLink parent, int guid)
        {
            InAudioBankLink link = CreateBankLink(go, parent, guid);

            SaveAndLoad.CreateAudioBank(guid);
            return(link);
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        public static void RebuildBanks(InAudioBankLink rootBank, InAudioNode root)
        {
            SystemFolderHelper.CreateIfMissing(FolderSettings.BankCreateFolder);
            TreeWalker.ForEach(rootBank, CreateIfMissing);
            TreeWalker.ForEach(rootBank, DeleteAllNodesFromBanks);
            TreeWalker.ForEach(root, node =>
            {
                var folderData = node.NodeData as InFolderData;
                if (folderData != null && folderData.BankLink == null)
                {
                    folderData.BankLink = rootBank;
                }
            });
            TreeWalker.ForEach(root, AddNodesToBank);

            //Set the bank of the root node if it is missing
            InFolderData inFolderData = root.NodeData as InFolderData;

            if (inFolderData != null && inFolderData.BankLink == null)
            {
                inFolderData.BankLink = TreeWalker.FindFirst(rootBank, link => link.Type == AudioBankTypes.Link);
            }
            if (inFolderData.BankLink != null)
            {
                TreeWalker.ForEach(root, SetBanks);
            }
        }
Exemplo n.º 4
0
        public static InAudioBankLink CreateFolder(GameObject go, InAudioBankLink parent, int guid)
        {
            var node = CreateNode(go, parent, guid);

            node.Name = parent.Name + " Child Folder";
            node.Type = AudioBankTypes.Folder;
            return(node);
        }
Exemplo n.º 5
0
        private static InAudioBankLink CreateBankLink(GameObject go, InAudioBankLink parent, int guid)
        {
            var node = CreateNode(go, parent, guid);

            node.Name = parent.Name + " Child";
            node.Type = AudioBankTypes.Link;
            return(node);
        }
Exemplo n.º 6
0
 public static InAudioBank LoadBank(InAudioBankLink bankLink)
 {
     if (bankLink == null)
     {
         return(null);
     }
     return(SaveAndLoad.LoadAudioBank(bankLink.ID));
 }
Exemplo n.º 7
0
        public static bool Load(InAudioBankLink bankLink)
        {
            if (bankLink == null)
            {
                return(false);
            }

            return(LoadBank(bankLink));
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        public static bool IsLoaded(InAudioBankLink bankLink)
        {
            if (bankLink == null)
            {
                return(false);
            }

            return(bankLink.IsLoaded);
        }
Exemplo n.º 10
0
 public static void DeleteFolder(InAudioBankLink toDelete)
 {
     UndoHelper.DoInGroup(() =>
     {
         UndoHelper.RecordObjectFull(toDelete.Parent, "Delete Bank Folder");
         toDelete.Parent.GetChildren.Remove(toDelete);
         UndoHelper.Destroy(toDelete);
     });
 }
Exemplo n.º 11
0
 private static void DeleteAllNodesFromBanks(InAudioBankLink audioBankLink)
 {
     if (audioBankLink.Type == AudioBankTypes.Link)
     {
         if (audioBankLink.LazyBankFetch != null)
         {
             audioBankLink.LazyBankFetch.Clips.Clear();
         }
     }
 }
Exemplo n.º 12
0
        public static void ChangeBankOverride(InAudioNode node, InAudioBankLink rootBank, InAudioNode root)
        {
            var all = TreeWalker.FindAll(rootBank, link => link.Type == AudioBankTypes.Link ? link.LazyBankFetch : null);

            UndoHelper.RecordObject(all.ToArray().AddObj(node.NodeData), "Changed Bank");
            InFolderData data = (node.NodeData as InFolderData);

            data.OverrideParentBank = !data.OverrideParentBank;
            RebuildBanks(rootBank, root);
        }
Exemplo n.º 13
0
        public static InAudioBank Load(InAudioBankLink bankLink)
        {
            if (bankLink == null)
            {
                return(null);
            }

            bankLink.LoadedBank = LoadBank(bankLink);

            if (bankLink.LoadedBank == null)
            {
                Debug.LogError("InAudio: Bank with name \"" + bankLink.Name + "\", id " + bankLink.GUID + " could not be found. Please open the Integrity Window and rebuild Bank Integrity");
                return(null);
            }


            if (Application.isPlaying && InAudioInstanceFinder.DataManager != null)
            {
                InAudioInstanceFinder.DataManager.BankIsLoaded(bankLink.LoadedBank);

                bool warning = false;
                for (int i = 0; i < bankLink.LoadedBank.Clips.Count; i++)
                {
                    var node = bankLink.LoadedBank.Clips[i].Node;
                    if (node == null)
                    {
                        warning = true;
                        continue;
                    }
                    var data = node.NodeData as InAudioData;
                    if (data == null)
                    {
                        warning = true;
                        continue;
                    }
                    (bankLink.LoadedBank.Clips[i].Node.NodeData as InAudioData).RuntimeClip =
                        bankLink.LoadedBank.Clips[i].Clip;
                }

                if (warning)
                {
                    Debug.LogError("One or more audio nodes are missing from the bank \"" + bankLink.Name + "\", id " +
                                   bankLink.ID + ".\nPlease open the InAudio Integrity Window and rebuild the banks");
                }
                bankLink.IsLoaded = true;
            }

            return(bankLink.LoadedBank);
        }
Exemplo n.º 14
0
        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]);
            }
        }
Exemplo n.º 15
0
 private static void CreateIfMissing(InAudioBankLink bankLink)
 {
     if (bankLink != null && bankLink.Type == AudioBankTypes.Link)
     {
         bankLink.LoadedBank = BankLoader.LoadBank(bankLink);
         if (bankLink.LoadedBank == null)
         {
             GameObject go = BankLoader.GetBankGO(bankLink.ID);
             if (go == null)
             {
                 SaveAndLoad.CreateAudioBank(bankLink.ID);
                 Debug.Log("Created missing Bank " + bankLink.Name + " with id " + bankLink.ID);
             }
             else
             {
                 var bank = go.AddComponent <InAudioBank>();
                 bank.GUID = bankLink.ID;
                 Debug.Log("Created missing Bank \n" + bankLink.Name + "\n with id " + bankLink.ID);
             }
         }
     }
 }
Exemplo n.º 16
0
        public static void Unload(InAudioBankLink bankLink)
        {
            InAudioBank bank = bankLink.LoadedBank;

            if (bank != null)
            {
                for (int i = 0; i < bank.Clips.Count; i++)
                {
                    var node = bank.Clips[i].Node;
                    if (node != null)
                    {
                        var audioData = node.NodeData as InAudioData;
                        if (audioData != null)
                        {
                            audioData.Clip = null;
                        }
                    }
                }
                Resources.UnloadUnusedAssets();
                bankLink.IsLoaded = false;
            }
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
 public static void DeleteBank(InAudioBankLink toDelete)
 {
     AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(toDelete.LazyBankFetch.gameObject));
     toDelete.Parent.GetChildren.Remove(toDelete);
     Object.DestroyImmediate(toDelete, true);
 }