#if UNITY_EDITOR using System.Diagnostics; using System.IO; using System.Linq; using System.Xml.Linq; using UnityEditor; using UnityEditor.SceneManagement; using UnityEditor.VersionControl; using UnityEngine; using UnityEngine.SceneManagement; using Wwise.Wooduan.Components; using Wwise.Wooduan.Core; namespace Wwise.Wooduan.Tools { public partial class AkWooduanMenuTools { #region Configs [MenuItem("Wwise/Configs/Audio Init &F1")] private static void OpenAudioInitSettings() { //Selection.activeObject = AudioInitSettings.Instance; } [MenuItem("Wwise/Configs/Wwise Paths &F2")] private static void OpenWwisePathSettings() { //Selection.activeObject = WwisePathSettings.Instance; } [MenuItem("Wwise/Configs/DLC SoundBank List &F3")] public static void OpenDLCBankList() { //Selection.activeObject = DLCBankList.Instance; } [MenuItem("Wwise/Configs/AkSoundEngine &F4")] private static void OpenWwiseInitializationSettings() { Selection.activeObject = AkWwiseInitializationSettings.Instance; } #endregion #region Game [MenuItem("Wwise/Game/Load Default Banks")] public static void LoadDefaultBanks() { AkUtilities.LoadAudioInitData(); } [MenuItem("Wwise/Game/Reload All Banks")] public static void ReloadAllBanks() { AkBankManager.ReloadAllBanks(); } #endregion #region Open [MenuItem("Wwise/Open/Wwise Picker &F5")] public static void WwisePicker() { EditorWindow.GetWindow("Wwise Picker", true, typeof(EditorWindow).Assembly.GetType("UnityEditor.ConsoleWindow")); } [MenuItem("Wwise/Open/Audio Console &F6")] public static void AudioConsole() { EditorWindow.GetWindow("Audio Console", true, typeof(EditorWindow).Assembly.GetType("UnityEditor.ConsoleWindow")); } [MenuItem("Wwise/Open/Wwise Project &F7")] public static void OpenWwiseProject() { if (File.Exists(AkWwiseEditorSettings.WwiseProjectAbsolutePath)) Process.Start(AkWwiseEditorSettings.WwiseProjectAbsolutePath); else EditorUtility.DisplayDialog("Error", "Can't find Wwise Project at " + AkWwiseEditorSettings.WwiseProjectAbsolutePath, "OK"); } [MenuItem("Wwise/Open/Sound Caster &F8")] public static void SoundCaster() { var window = EditorWindow.GetWindow("Sound Caster", true, typeof(EditorWindow).Assembly.GetType("UnityEditor.InspectorWindow")); window.minSize = new Vector2(300, 600); } [MenuItem("Wwise/Open/SFX Folder &F9")] private static void OpenSfxFolder() { var folderPath = AkWooduanScriptingTools.CombinePath(AkWwiseEditorSettings.WwiseProjectFolderAbsolutePath, "Originals/SFX"); if (Directory.Exists(folderPath)) Process.Start(folderPath); else EditorUtility.DisplayDialog("Error", "Can't find Wwise Project at " + AkWwiseEditorSettings.WwiseProjectAbsolutePath, "OK"); } #endregion #region Tools [MenuItem("Wwise/Tools/Implementation Backup &F9")] public static void WwiseBackUp() { var window = EditorWindow.GetWindow(); window.position = new Rect(500, 300, 500, 500); window.titleContent = new GUIContent("BackUp"); } [MenuItem("Wwise/Tools/Script Migration &F11")] public static void ScriptMigration() { var window = EditorWindow.GetWindow(); window.position = new Rect(500, 300, 690, 360); window.titleContent = new GUIContent("Script Migration"); } [MenuItem("Wwise/Tools/Replace by Regex in Text File")] public static void RegexReplacer() { var window = EditorWindow.GetWindow(); window.position = new Rect(500, 300, 300, 150); window.titleContent = new GUIContent("Regex Replacer"); } [MenuItem("Wwise/Tools/Field Upgrade")] public static void FieldUpgrade() { var window = EditorWindow.GetWindow(); window.position = new Rect(500, 300, 300, 150); window.titleContent = new GUIContent("Filed Upgrade"); } [MenuItem("Wwise/Tools/Script Reference Update")] public static void ScriptReferenceUpdate() { var window = EditorWindow.GetWindow(); window.position = new Rect(500, 300, 400, 100); window.titleContent = new GUIContent("Script Reference Update"); } [MenuItem("Wwise/Tools/Remove Missing and Duplicate Components")] public static void RemoveMissingDuplicate() { var window = EditorWindow.GetWindow(); window.position = new Rect(500, 300, 500, 120); window.titleContent = new GUIContent("Remove"); } [MenuItem("Wwise/Tools/Search Linked Components")] private static void SearchLinkedComponents() { var window = EditorWindow.GetWindow(); window.position = new Rect(500, 300, 500, 500); } [MenuItem("Assets/AkWooduan/Batch Rename")] private static void BatchRename() { var window = EditorWindow.GetWindow(); window.position = new Rect(800, 400, 200, 180); window.titleContent = new GUIContent("Batch Rename"); } [MenuItem("Assets/AkWooduan/特效资源检测音频配置")] private static void CheckAudioComponents() { var xmlPath = Path.Combine(Application.dataPath, "Maps/StandardModels/effects/EffectAudioData.xml"); if (!File.Exists(xmlPath)) { EditorUtility.DisplayDialog("Error", "配置文件不存在,请使用导出工具创建!", "OK"); return; } var xRoot = XDocument.Load(xmlPath).Root; if (xRoot == null) return; var path = AssetDatabase.GetAssetPath(Selection.activeGameObject); if (!path.EndsWith(".prefab")) return; var xAsset = xRoot.Elements().FirstOrDefault(x => path == AkWooduanScriptingTools.GetXmlAttribute(x, "AssetPath")); var components = Selection.activeGameObject.GetComponentsInChildren(true); if (xAsset == null) { xAsset = new XElement("Prefab"); foreach (var component in components) { var xComponent = new XElement("Component"); xComponent.SetAttributeValue("Type", component.GetType().Name); xComponent.SetAttributeValue("GameObject", AkWooduanAssetSearcher.GetGameObjectPath(component.transform)); AkWooduanComponentBackup.ExportComponent(component, xComponent); xAsset.Add(xComponent); } xRoot.Add(xAsset); AkWooduanScriptingTools.WriteXml(xmlPath, xRoot); } else { foreach (var component in components) { var gameObjectPath = AkWooduanAssetSearcher.GetGameObjectPath(component.transform); var xComponent = xAsset.Elements().FirstOrDefault(x => gameObjectPath == AkWooduanScriptingTools.GetXmlAttribute(x, "GameObject")); if (xComponent == null || AkWooduanComponentBackup.ComponentModified(component, xComponent)) { EditorUtility.DisplayDialog("Warning", "Prefab上的音频配置发生改动,请联系音频组核对!", "OK"); return; } } foreach (var xComponennt in xAsset.Elements()) { } } } [MenuItem("Wwise/Tools/Character Component Sync")] public static void CharacterComponentSync() { var window = EditorWindow.GetWindow(); window.position = new Rect(500, 300, 300, 100); window.titleContent = new GUIContent("Character Component Sync"); } [MenuItem("Assets/Wwise/Implementation Backup/Save Selection")] public static void SaveSelectedAssets() { AkWooduanComponentBackup.Instance.SeparateXmlFiles = false; var selectedPaths = Selection.objects.Select(AssetDatabase.GetAssetPath).ToArray(); var prefabs = selectedPaths.Where(path => path.EndsWith(".prefab")).ToArray(); if (prefabs.Length > 0) AkWooduanComponentBackup.Instance.SaveSelectedAssets(prefabs, AkWooduanComponentBackup.Instance.ParsePrefab); var scenes = selectedPaths.Where(path => path.EndsWith(".unity")).ToArray(); if (scenes.Length > 0) AkWooduanComponentBackup.Instance.SaveSelectedAssets(scenes, AkWooduanComponentBackup.Instance.ParseScene); var clips = selectedPaths.Where(path => path.EndsWith(".anim")).ToArray(); if (clips.Length > 0) AkWooduanAnimationBackup.Instance.SaveSelectedAssets(clips, AkWooduanAnimationBackup.Instance.ParseAnimation); var models = selectedPaths.Where(path => path.EndsWith(".FBX")).ToArray(); if (models.Length > 0) AkWooduanAnimationBackup.Instance.SaveSelectedAssets(models, AkWooduanAnimationBackup.Instance.ParseModel); } [MenuItem("Assets/Wwise/Implementation Backup/Export Selection")] public static void ExportSelectedAssets() { AkWooduanComponentBackup.Instance.SeparateXmlFiles = false; var selectedPaths = Selection.objects.Select(AssetDatabase.GetAssetPath).ToArray(); var prefabs = selectedPaths.Where(path => path.EndsWith(".prefab")).ToArray(); if (prefabs.Length > 0) AkWooduanComponentBackup.Instance.ExportSelectedAssets(prefabs, AkWooduanComponentBackup.Instance.ParsePrefab); var scenes = selectedPaths.Where(path => path.EndsWith(".unity")).ToArray(); if (scenes.Length > 0) AkWooduanComponentBackup.Instance.ExportSelectedAssets(scenes, AkWooduanComponentBackup.Instance.ParseScene); var clips = selectedPaths.Where(path => path.EndsWith(".anim")).ToArray(); if (clips.Length > 0) AkWooduanAnimationBackup.Instance.ExportSelectedAssets(clips, AkWooduanAnimationBackup.Instance.ParseAnimation); var models = selectedPaths.Where(path => path.EndsWith(".FBX")).ToArray(); if (models.Length > 0) AkWooduanAnimationBackup.Instance.ExportSelectedAssets(models, AkWooduanAnimationBackup.Instance.ParseModel); } [MenuItem("Assets/Wwise/Implementation Backup/Revert Selection")] public static void RevertSelectedAssets() { var selectedPaths = Selection.objects.Select(AssetDatabase.GetAssetPath).ToArray(); var prefabs = selectedPaths.Where(path => path.EndsWith(".prefab")).ToArray(); if (prefabs.Length > 0) AkWooduanComponentBackup.Instance.RevertSelectedAssets(prefabs, AkWooduanComponentBackup.Instance.ImportPrefab); var scenes = selectedPaths.Where(path => path.EndsWith(".unity")).ToArray(); if (scenes.Length > 0) AkWooduanComponentBackup.Instance.RevertSelectedAssets(scenes, AkWooduanComponentBackup.Instance.ImportScene); var clips = selectedPaths.Where(path => path.EndsWith(".anim")).ToArray(); if (clips.Length > 0) AkWooduanAnimationBackup.Instance.RevertSelectedAssets(clips, AkWooduanAnimationBackup.Instance.ImportClip); var models = selectedPaths.Where(path => path.EndsWith(".FBX")).ToArray(); if (models.Length > 0) AkWooduanAnimationBackup.Instance.RevertSelectedAssets(models, AkWooduanAnimationBackup.Instance.ImportModel); } [MenuItem("Assets/Wwise/Implementation Backup/Remove Selected")] public static void RemoveSelectedAssets() { var selectedPaths = Selection.objects.Select(AssetDatabase.GetAssetPath).ToArray(); var prefabs = selectedPaths.Where(path => path.EndsWith(".prefab")).ToArray(); if (prefabs.Length > 0) AkWooduanComponentBackup.Instance.RemoveSelectedAssets(prefabs, AkWooduanComponentBackup.Instance.RemoveAllInPrefab); var scenes = selectedPaths.Where(path => path.EndsWith(".unity")).ToArray(); if (scenes.Length > 0) AkWooduanComponentBackup.Instance.RemoveSelectedAssets(scenes, AkWooduanComponentBackup.Instance.RemoveAllInScene); var clips = selectedPaths.Where(path => path.EndsWith(".anim")).ToArray(); if (clips.Length > 0) AkWooduanAnimationBackup.Instance.RemoveSelectedAssets(clips, AkWooduanAnimationBackup.Instance.RemoveClip); var models = selectedPaths.Where(path => path.EndsWith(".FBX")).ToArray(); if (models.Length > 0) AkWooduanAnimationBackup.Instance.RemoveSelectedAssets(models, AkWooduanAnimationBackup.Instance.RemoveModel); } [MenuItem("Assets/Wwise/Implementation Backup/Remove Unsaved")] public static void RemoveUnsavedComponents() { var selectedPaths = Selection.objects.Select(AssetDatabase.GetAssetPath).ToArray(); var prefabs = selectedPaths.Where(path => path.EndsWith(".prefab")).ToArray(); if (prefabs.Length > 0) AkWooduanComponentBackup.Instance.RemoveSelectedAssets(prefabs, AkWooduanComponentBackup.Instance.RemoveUnsavedInPrefab); var scenes = selectedPaths.Where(path => path.EndsWith(".unity")).ToArray(); if (scenes.Length > 0) AkWooduanComponentBackup.Instance.RemoveSelectedAssets(scenes, AkWooduanComponentBackup.Instance.RemoveUnsavedInScene); } #endregion } } #endif