Ejemplo n.º 1
0
        public AudioManagerTreeView(TreeViewState state, AudioManagerData data, AudioManagerCategory root) : base(state)
        {
            showAlternatingRowBackgrounds = true;

            m_Data = data;
            m_Root = root;
            Reload();
        }
Ejemplo n.º 2
0
        public static AssetMoveResult OnWillMoveAsset(string oldPath, string newPath)
        {
            //D.AudioLog("Moving " + oldPath + " to " + newPath);

            string           lowercase      = oldPath.ToLowerInvariant();
            AudioManagerData data           = null;
            bool             shouldSaveData = false;

            // this skips changes by hiding folders (if we want to exclude some files from the build)
            if (!newPath.Contains("/."))
            {
                // moving whole directory, need to check a lot of stuff :(
                if (Directory.Exists(Path.Combine(Application.dataPath, oldPath.Substring("Assets/".Length))))
                {
                    data = AudioManagerData.LoadInstanceData();
                    if (data != null)
                    {
                        //D.AudioLog("It's a direcotry, checking all sounds :(");
                        data.TreeData.RenameAssetPathRecursive(oldPath, newPath, ref shouldSaveData);
                    }
                }

                // moving a file
                else if (lowercase.EndsWith(".wav") || lowercase.EndsWith(".mp3") || lowercase.EndsWith(".aif") || lowercase.EndsWith(".ogg"))
                {
                    data = AudioManagerData.LoadInstanceData();
                    if (data != null)
                    {
                        // Check all the paths
                        data.TreeData.RenameAssetRecursive(oldPath, newPath, ref shouldSaveData);
                    }
                }
            }

            if (shouldSaveData)
            {
                D.AudioLog("Updating audio manager data!");
                data.SaveTree();
#if !UNITY_2018_2_OR_NEWER
                EditorUtility.SetDirty(data);
                AssetDatabase.SaveAssets();
#endif
            }

            return(AssetMoveResult.DidNotMove);
        }
Ejemplo n.º 3
0
        public static AudioManagerData LoadInstanceData()
        {
            AudioPreferences p = AudioPreferences.Instance;

#if UNITY_2018_3_OR_NEWER
            var go = PrefabUtility.LoadPrefabContents(p.AudioManagerDataPrefabPath);
            AudioManagerData data = go.GetComponent <AudioManagerData>();
#else
            AudioManagerData data = AssetDatabase.LoadAssetAtPath <AudioManagerData>(p.AudioManagerDataPath);
#endif

            if (data == null)
            {
                return(null);
            }

            data.ReconstructTreeChildren();
            return(data);
        }
Ejemplo n.º 4
0
        public void SaveTree()
        {
            if (m_TreeData == null)
            {
                InitTree();
            }

#if UNITY_2018_3_OR_NEWER
            var go = PrefabUtility.LoadPrefabContents(AudioPreferences.Instance.AudioManagerDataPrefabPath);
            AudioManagerData data = go.GetComponent <AudioManagerData>();

            data.TreeData  = m_TreeData;
            data.SavedTree = new List <AudioManagerCategory>();
            data.SaveTree(m_TreeData);

            PrefabUtility.SaveAsPrefabAsset(go, AudioPreferences.Instance.AudioManagerDataPrefabPath);
#else
            m_SavedTree = new List <AudioManagerCategory>();
            SaveTree(m_TreeData);
#endif
        }