From 995231a1cb5eaad11155e833317509b145e191f1 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 13 May 2024 20:32:04 +0100 Subject: [PATCH] :construction: Update with community report fix - Pushed out a tad early so this bug fix can go out. - Also includes some initialization work that should sort library regen finally if all goes well. --- .../Inspectors/DelayEditModuleInspector.cs | 2 +- .../Inspectors/LoopEditModuleInspector.cs | 2 +- .../Library Window/LibraryEditorWindow.cs | 2 +- .../4. Music/LibraryEditorMusicTab.cs | 22 +-- .../4. Music/MusicTrackListDrawer.cs | 12 +- .../Inspectors/AudioManagerSettingsEditor.cs | 2 +- .../InspectorMusicTrackPlayerEditor.cs | 10 +- .../AudioManagerSettingsWindow.cs | 4 +- .../Systems/Asset Index/AssetIndexHandler.cs | 23 ++- .../Enum Generation/ClipClassGenerator.cs | 8 +- .../Enum Generation/GroupClassGenerator.cs | 8 +- .../Enum Generation/MixerClassGenerator.cs | 6 +- .../Systems/Enum Generation/StructHandler.cs | 2 +- .../Enum Generation/TrackClassGenerator.cs | 10 +- .../Initialization/AssetInitializer.cs | 75 +++++++-- .../Initialization/AssetInitializer.cs.meta | 2 +- .../Initialization/AssetReloadHandler.cs | 86 ++++++++++ .../AssetReloadHandler.cs.meta} | 2 +- .../Initialization/IAssetEditorInitialize.cs} | 16 +- .../IAssetEditorInitialize.cs.meta | 11 ++ .../Initialization/IAssetEditorReload.cs | 30 ++++ .../Initialization/IAssetEditorReload.cs.meta | 11 ++ .../ScriptableObjectInitialize.cs | 63 ++++++++ .../ScriptableObjectInitialize.cs.meta | 11 ++ .../Editor/Systems/Scanning/AudioRemover.cs | 16 +- .../Editor/Systems/Scanning/AudioScanner.cs | 54 +++++-- .../Code/Editor/Systems/Scanning/FirstScan.cs | 28 +--- .../Search Generation/TrackSearchProvider.cs | 2 +- .../Code/Editor/Systems/Settings.meta | 3 + .../Systems/Settings/SettingsInitialize.cs | 80 ++++++++++ .../Settings/SettingsInitialize.cs.meta | 11 ++ .../Editor/Systems/Version Validation.meta | 4 +- .../Version Validation/VersionAutoCheck.cs | 10 +- .../VersionAutoCheck.cs.meta | 2 +- .../Version Validation/VersionChecker.cs | 10 +- .../Version Validation/VersionChecker.cs.meta | 2 +- .../Systems/Version Validation/VersionData.cs | 23 +-- .../Version Validation/VersionData.cs.meta | 2 +- .../Version Validation/VersionEditorGUI.cs | 10 +- .../VersionEditorGUI.cs.meta | 2 +- .../Systems/Version Validation/VersionInfo.cs | 2 +- .../Version Validation/VersionInfo.cs.meta | 2 +- .../Version Validation/VersionNumber.cs | 10 +- .../Version Validation/VersionNumber.cs.meta | 2 +- .../Version Validation/VersionPacket.cs | 10 +- .../Version Validation/VersionPacket.cs.meta | 2 +- .../Code/Editor/Utility/AssetVersionData.cs | 4 +- .../Editor Method Aid/InterfaceHelper.cs | 44 ++++++ .../Editor Method Aid/InterfaceHelper.cs.meta | 11 ++ .../Scriptable Assets/ScriptableRef.cs | 45 +++++- .../Code/Editor/Utility/UtilEditor.cs | 29 ---- .../Code/Runtime/Audio/AudioManager.cs | 6 +- .../Runtime/Audio/Edit Modules/DelayEdit.cs | 4 + .../Edit Modules/DynamicStartTimeEdit.cs | 4 + .../Audio/Edit Modules/GlobalVarianceEdit.cs | 4 + .../Runtime/Audio/Edit Modules/IEditModule.cs | 3 + .../Runtime/Audio/Edit Modules/LoopEdit.cs | 7 + .../Runtime/Audio/Edit Modules/MixerEdit.cs | 4 + .../Runtime/Audio/Edit Modules/MuteEdit.cs | 4 + .../Runtime/Audio/Edit Modules/ParentEdit.cs | 4 + .../Runtime/Audio/Edit Modules/PitchEdit.cs | 4 + .../Runtime/Audio/Edit Modules/PoolingEdit.cs | 79 ++++++++++ .../Audio/Edit Modules/PoolingEdit.cs.meta | 11 ++ .../Audio/Edit Modules/PositionEdit.cs | 4 + .../Audio/Edit Modules/PriorityEdit.cs | 4 + .../Audio/Edit Modules/StartTimeEdit.cs | 4 + .../Runtime/Audio/Edit Modules/VolumeEdit.cs | 4 + .../Runtime/Audio/Player/AudioClipSettings.cs | 2 +- .../Audio/Player/AudioPlayerSequence.cs | 19 +++ .../Code/Runtime/Logging/AmDebugLogger.cs | 112 +++++++++++++ .../Runtime/Logging/AmDebugLogger.cs.meta | 11 ++ ...arterGames.Assets.AudioManager.Logging.dll | Bin 5632 -> 0 bytes ...Games.Assets.AudioManager.Logging.dll.meta | 33 ---- .../{MusicTrackList.cs => MusicPlaylist.cs} | 38 +++-- ...rackList.cs.meta => MusicPlaylist.cs.meta} | 0 .../Code/Runtime/Music/MusicManager.cs | 148 +++++++++--------- .../Runtime/Music/Players/IMusicPlayer.cs | 2 +- .../Music/Players/PlaylistMusicTrackPlayer.cs | 88 +++++------ .../Music/Players/SingleMusicTrackPlayer.cs | 58 +++---- .../Music/Transitions/Data/TransitionData.cs | 6 +- .../Systems/Audio Library/AudioLibrary.cs | 18 +-- .../AudioManagerErrorCode.cs | 2 +- .../AudioManagerErrorMessages.cs | 4 +- .../InspectorMusicTrackPlayer.cs | 8 +- .../Runtime/Systems/Pooling/ObjectPool.cs | 2 +- .../Runtime/Utility/Generated Classes.meta | 8 - Carter Games/Audio Manager/Data.meta | 3 + 87 files changed, 1130 insertions(+), 422 deletions(-) create mode 100644 Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetReloadHandler.cs rename Carter Games/Audio Manager/Code/{Runtime/Music/Players/TrackType.cs.meta => Editor/Systems/Initialization/AssetReloadHandler.cs.meta} (86%) rename Carter Games/Audio Manager/Code/{Runtime/Music/Players/TrackType.cs => Editor/Systems/Initialization/IAssetEditorInitialize.cs} (78%) create mode 100644 Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorInitialize.cs.meta create mode 100644 Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorReload.cs create mode 100644 Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorReload.cs.meta create mode 100644 Carter Games/Audio Manager/Code/Editor/Systems/Initialization/ScriptableObjectInitialize.cs create mode 100644 Carter Games/Audio Manager/Code/Editor/Systems/Initialization/ScriptableObjectInitialize.cs.meta create mode 100644 Carter Games/Audio Manager/Code/Editor/Systems/Settings.meta create mode 100644 Carter Games/Audio Manager/Code/Editor/Systems/Settings/SettingsInitialize.cs create mode 100644 Carter Games/Audio Manager/Code/Editor/Systems/Settings/SettingsInitialize.cs.meta create mode 100644 Carter Games/Audio Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs create mode 100644 Carter Games/Audio Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs.meta create mode 100644 Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PoolingEdit.cs create mode 100644 Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PoolingEdit.cs.meta create mode 100644 Carter Games/Audio Manager/Code/Runtime/Logging/AmDebugLogger.cs create mode 100644 Carter Games/Audio Manager/Code/Runtime/Logging/AmDebugLogger.cs.meta delete mode 100644 Carter Games/Audio Manager/Code/Runtime/Logging/CarterGames.Assets.AudioManager.Logging.dll delete mode 100644 Carter Games/Audio Manager/Code/Runtime/Logging/CarterGames.Assets.AudioManager.Logging.dll.meta rename Carter Games/Audio Manager/Code/Runtime/Music/Data/{MusicTrackList.cs => MusicPlaylist.cs} (92%) rename Carter Games/Audio Manager/Code/Runtime/Music/Data/{MusicTrackList.cs.meta => MusicPlaylist.cs.meta} (100%) delete mode 100644 Carter Games/Audio Manager/Code/Runtime/Utility/Generated Classes.meta create mode 100644 Carter Games/Audio Manager/Data.meta diff --git a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Edit Module Inspectors/Inspectors/DelayEditModuleInspector.cs b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Edit Module Inspectors/Inspectors/DelayEditModuleInspector.cs index 959dccb..d924cf8 100644 --- a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Edit Module Inspectors/Inspectors/DelayEditModuleInspector.cs +++ b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Edit Module Inspectors/Inspectors/DelayEditModuleInspector.cs @@ -86,7 +86,7 @@ public override void DrawInspector(SerializedObject targetObject, int index) if (delay < 0) { delay = 0; - AmLog.Warning($"{AudioManagerErrorCode.InvalidAudioClipInspectorInput}\nDelay edit cannot have a value below 0."); + AmDebugLogger.Warning($"{AudioManagerErrorCode.InvalidAudioClipInspectorInput}\nDelay edit cannot have a value below 0."); } EditModuleInspectorHelper.SetValue(targetObject, index, "delay",delay.ToString()); diff --git a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Edit Module Inspectors/Inspectors/LoopEditModuleInspector.cs b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Edit Module Inspectors/Inspectors/LoopEditModuleInspector.cs index 8a034d4..ef9241d 100644 --- a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Edit Module Inspectors/Inspectors/LoopEditModuleInspector.cs +++ b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Edit Module Inspectors/Inspectors/LoopEditModuleInspector.cs @@ -112,7 +112,7 @@ public override void DrawInspector(SerializedObject targetObject, int index) if (loopCount < 0) { loopCount = 0; - AmLog.Warning($"{AudioManagerErrorCode.InvalidAudioClipInspectorInput}\nLoop count cannot have a value below 0 when using x times mode."); + AmDebugLogger.Warning($"{AudioManagerErrorCode.InvalidAudioClipInspectorInput}\nLoop count cannot have a value below 0 when using x times mode."); } EditModuleInspectorHelper.SetValue(targetObject, index, "loopCount", loopCount.ToString()); diff --git a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/LibraryEditorWindow.cs b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/LibraryEditorWindow.cs index 7dd7acc..6b67619 100644 --- a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/LibraryEditorWindow.cs +++ b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/LibraryEditorWindow.cs @@ -177,7 +177,7 @@ private static void DrawHeader() EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); - if (GUILayout.Button(UtilEditor.OpenBookIcon, GUIStyle.none, GUILayout.MaxHeight(110))) + if (GUILayout.Button(UtilEditor.OpenBookIcon, GUIStyle.none, GUILayout.MaxHeight(75))) { GUI.FocusControl(null); } diff --git a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/Sub-Menus/4. Music/LibraryEditorMusicTab.cs b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/Sub-Menus/4. Music/LibraryEditorMusicTab.cs index e9fbf38..03a9560 100644 --- a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/Sub-Menus/4. Music/LibraryEditorMusicTab.cs +++ b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/Sub-Menus/4. Music/LibraryEditorMusicTab.cs @@ -106,7 +106,7 @@ protected override void LeftSectionControl() EditorGUILayout.BeginVertical("Box", GUILayout.MaxWidth(250)); GUI.backgroundColor = UtilEditor.Yellow; - if (GUILayout.Button("Update Track Struct", GUILayout.MaxHeight(25))) + if (GUILayout.Button("Update Playlist Struct", GUILayout.MaxHeight(25))) { StructHandler.RefreshTracks(); } @@ -115,7 +115,7 @@ protected override void LeftSectionControl() if (PerUserSettings.ShowHelpBoxes) { - EditorGUILayout.HelpBox("Press ^^^ to update the Track.??? struct to have the latest changes", + EditorGUILayout.HelpBox("Press ^^^ to update the Playlist.??? struct to have the latest changes", MessageType.None); } @@ -124,7 +124,7 @@ protected override void LeftSectionControl() GUILayout.Space(7.5f); GUI.backgroundColor = UtilEditor.Green; - if (GUILayout.Button("+ Add New Track")) + if (GUILayout.Button("+ Add New Playlist")) { AddNewBlankTrack(); GUI.FocusControl(null); @@ -203,7 +203,7 @@ protected override void OnRightGUI() { EditorGUILayout.BeginVertical("Box"); EditorGUILayout.BeginVertical("Box"); - EditorGUILayout.LabelField("Select a track list to see its contents here."); + EditorGUILayout.LabelField("Select a playlist to see its contents here."); EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); return; @@ -250,10 +250,10 @@ protected override void OnRightGUI() } - EditorGUILayout.PropertyField(SelectedProperty.Fpr("value").Fpr("trackListType")); + // EditorGUILayout.PropertyField(SelectedProperty.Fpr("value").Fpr("playlistType")); EditorGUILayout.PropertyField(SelectedProperty.Fpr("value").Fpr("loop")); - if (SelectedProperty.Fpr("value").Fpr("trackListType").intValue == 1) + if (SelectedProperty.Fpr("value").Fpr("tracks").arraySize > 1) { EditorGUILayout.PropertyField(SelectedProperty.Fpr("value").Fpr("shuffle")); } @@ -293,10 +293,10 @@ protected override void OnRightGUI() GUILayout.Space(1.5f); GUI.backgroundColor = UtilEditor.Red; - if (GUILayout.Button("Delete Track List")) + if (GUILayout.Button("Delete Playlist")) { - if (!EditorUtility.DisplayDialog("Delete Track List", - "Are you sure you want to delete this track list?", "Delete List", "Cancel")) return; + if (!EditorUtility.DisplayDialog("Delete Playlist", + "Are you sure you want to delete this playlist?", "Delete", "Cancel")) return; var oldKey = UtilEditor.LibraryObject.Fp("tracks").Fpr("list").GetIndex(PerUserSettings.LastLibMusicEntry).Fpr("key").stringValue; UtilEditor.LibraryObject.Fp("tracks").Fpr("list").DeleteIndex(PerUserSettings.LastLibMusicEntry); @@ -346,8 +346,8 @@ private static void AddNewBlankTrack() var newTrackProp = tracksProp.GetIndex(tracksProp.arraySize - 1); newTrackProp.Fpr("key").stringValue = Guid.NewGuid().ToString(); - newTrackProp.Fpr("value").Fpr("listKey").stringValue = "New Track List " + newTrackProp.Fpr("key").stringValue.Substring(0, 7); - newTrackProp.Fpr("value").Fpr("trackListType").intValue = 0; + newTrackProp.Fpr("value").Fpr("listKey").stringValue = "New Playlist " + newTrackProp.Fpr("key").stringValue.Substring(0, 7); + newTrackProp.Fpr("value").Fpr("playlistType").intValue = 0; newTrackProp.Fpr("value").Fpr("loop").boolValue = false; newTrackProp.Fpr("value").Fpr("shuffle").boolValue = false; newTrackProp.Fpr("value").Fpr("tracks").ClearArray(); diff --git a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/Sub-Menus/4. Music/MusicTrackListDrawer.cs b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/Sub-Menus/4. Music/MusicTrackListDrawer.cs index e1b31e1..1ea0f62 100644 --- a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/Sub-Menus/4. Music/MusicTrackListDrawer.cs +++ b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Editor Windows/Library Window/Sub-Menus/4. Music/MusicTrackListDrawer.cs @@ -50,12 +50,12 @@ public static class MusicTrackListDrawer public static void DrawTracks(SerializedProperty prop) { var list = prop.Fpr("value").Fpr("tracks"); - var playType = prop.Fpr("value").Fpr("trackListType"); + // var playType = prop.Fpr("value").Fpr("playlistType"); EditorGUILayout.BeginVertical("HelpBox"); GUI.color = UtilEditor.Yellow; - EditorGUILayout.LabelField("Clips Assigned", EditorStyles.boldLabel); + EditorGUILayout.LabelField("Tracks", EditorStyles.boldLabel); GUI.color = Color.white; UtilEditor.DrawHorizontalGUILine(); @@ -102,7 +102,8 @@ public static void DrawTracks(SerializedProperty prop) EditorGUILayout.BeginHorizontal(); GUILayout.Space(1.5f); - EditorGUI.BeginDisabledGroup(playType.intValue == 0 && i > 0); + EditorGUI.BeginDisabledGroup(list.arraySize == 1 && i > 0); + // EditorGUI.BeginDisabledGroup(playType.intValue == 0 && i > 0); if (string.IsNullOrEmpty(list.GetIndex(i).Fpr("clipId").stringValue)) { @@ -141,7 +142,8 @@ public static void DrawTracks(SerializedProperty prop) GUILayout.Space(1.5f); EditorGUI.EndDisabledGroup(); - EditorGUI.BeginDisabledGroup(playType.intValue == 0); + // EditorGUI.BeginDisabledGroup(list.arraySize == 1); + // EditorGUI.BeginDisabledGroup(playType.intValue == 0); GUI.backgroundColor = UtilEditor.Green; if (GUILayout.Button(" + ", GUILayout.MaxWidth(22.5f))) @@ -155,7 +157,7 @@ public static void DrawTracks(SerializedProperty prop) return; } - EditorGUI.EndDisabledGroup(); + // EditorGUI.EndDisabledGroup(); GUI.backgroundColor = UtilEditor.Red; if (GUILayout.Button(" - ", GUILayout.MaxWidth(22.5f))) diff --git a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Inspectors/AudioManagerSettingsEditor.cs b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Inspectors/AudioManagerSettingsEditor.cs index edc9356..f19f9f6 100644 --- a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Inspectors/AudioManagerSettingsEditor.cs +++ b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Inspectors/AudioManagerSettingsEditor.cs @@ -144,7 +144,7 @@ private static void DrawButtons() if (UtilEditor.FileExistsByFilter(UtilEditor.AudioPrefabName)) audioPrefab = UtilEditor.AudioPrefab; else - AmLog.Error("Unable to find the default audio prefab, setting to null."); + AmDebugLogger.Error("Unable to find the default audio prefab, setting to null."); AudioManagerEditorEvents.OnSettingsReset.Raise(); } diff --git a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Inspectors/InspectorMusicTrackPlayerEditor.cs b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Inspectors/InspectorMusicTrackPlayerEditor.cs index 12cfa92..26348a2 100644 --- a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Inspectors/InspectorMusicTrackPlayerEditor.cs +++ b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Inspectors/InspectorMusicTrackPlayerEditor.cs @@ -33,7 +33,7 @@ public override void OnInspectorGUI() GUILayout.Space(5f); - EditorGUILayout.LabelField("Track Info", EditorStyles.boldLabel); + EditorGUILayout.LabelField("Playlist Info", EditorStyles.boldLabel); UtilEditor.DrawHorizontalGUILine(); EditorGUILayout.BeginVertical("HelpBox"); @@ -43,7 +43,7 @@ public override void OnInspectorGUI() { EditorGUILayout.BeginHorizontal(); - if (GUILayout.Button("Select Track List")) + if (GUILayout.Button("Select Playlist")) { trackSearchProvider ??= CreateInstance(); @@ -63,7 +63,7 @@ public override void OnInspectorGUI() if (!string.IsNullOrEmpty(serializedObject.Fp("trackListId").stringValue)) { - EditorGUILayout.TextField("Track List Id", UtilEditor.Library + EditorGUILayout.TextField("Playlist Id", UtilEditor.Library .MusicTrackLookup[serializedObject.Fp("trackListId").stringValue].ListKey); } else @@ -97,7 +97,7 @@ public override void OnInspectorGUI() if (UtilEditor.Library.MusicTrackLookup.ContainsKey(serializedObject.Fp("trackListId").stringValue)) { if (UtilEditor.Library.MusicTrackLookup[serializedObject.Fp("trackListId").stringValue] - .TrackListType != TrackType.Single) + .GetTracksRaw().Count > 1) { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.PropertyField(serializedObject.Fp("firstTrackId")); @@ -202,7 +202,7 @@ public override void OnInspectorGUI() { if (serializedObject.Fp("inTransitionDuration").floatValue < 0f) { - AmLog.Warning($"{AudioManagerErrorCode.InvalidMusicInspectorInput}\nTransition in cannot be a value below 0."); + AmDebugLogger.Warning($"{AudioManagerErrorCode.InvalidMusicInspectorInput}\nTransition in cannot be a value below 0."); serializedObject.Fp("inTransitionDuration").floatValue = 0f; } diff --git a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Settings Provider/AudioManagerSettingsWindow.cs b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Settings Provider/AudioManagerSettingsWindow.cs index a5e423c..7dd3af5 100644 --- a/Carter Games/Audio Manager/Code/Editor/Custom Editors/Settings Provider/AudioManagerSettingsWindow.cs +++ b/Carter Games/Audio Manager/Code/Editor/Custom Editors/Settings Provider/AudioManagerSettingsWindow.cs @@ -245,7 +245,7 @@ private static void DrawAudioPrefabOptions() } else { - AmLog.Warning($"{AudioManagerErrorCode.PrefabNotValid}\nThe prefab you tried to assign did not have a AudioSequence class attached."); + AmDebugLogger.Warning($"{AudioManagerErrorCode.PrefabNotValid}\nThe prefab you tried to assign did not have a AudioSequence class attached."); } } else @@ -281,7 +281,7 @@ private static void DrawAudioPrefabOptions() } else { - AmLog.Warning($"{AudioManagerErrorCode.PrefabNotValid}\nThe prefab you tried to assign did not have a AudioPlayer class attached."); + AmDebugLogger.Warning($"{AudioManagerErrorCode.PrefabNotValid}\nThe prefab you tried to assign did not have a AudioPlayer class attached."); } } else diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Asset Index/AssetIndexHandler.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Asset Index/AssetIndexHandler.cs index 493aac9..03c1428 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Asset Index/AssetIndexHandler.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Asset Index/AssetIndexHandler.cs @@ -31,7 +31,7 @@ namespace CarterGames.Assets.AudioManager.Editor /// /// Handles the setup of the asset index for runtime references to scriptable objects used for the asset. /// - public sealed class AssetIndexHandler : IPreprocessBuildWithReport + public sealed class AssetIndexHandler : IPreprocessBuildWithReport, IAssetEditorInitialize { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Fields @@ -39,6 +39,27 @@ public sealed class AssetIndexHandler : IPreprocessBuildWithReport private const string AssetFilter = "t:audiomanagerasset"; + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | IAssetEditorInitialize Implementation + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Defines the order that this initializer run at. + /// + public int InitializeOrder => 1; + + + /// + /// Runs when the asset initialize flow is used. + /// + public void OnEditorInitialized() + { + EditorApplication.update -= OnEditorUpdate; + EditorApplication.update += OnEditorUpdate; + + UpdateIndex(); + } + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | IPreprocessBuildWithReport Implementation ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/ClipClassGenerator.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/ClipClassGenerator.cs index 3936ab4..9c46513 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/ClipClassGenerator.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/ClipClassGenerator.cs @@ -67,13 +67,13 @@ public override void Generate() if (data == null) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); } else { if (data.Count <= 0) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); } else { @@ -87,7 +87,7 @@ public override void Generate() DupeLookup[parsedName]++; dupeChangedName = $"{parsedName}{DupeLookup[parsedName]}"; - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructElementNameAlreadyExists)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructElementNameAlreadyExists)); } @@ -102,7 +102,7 @@ public override void Generate() #pragma warning disable catch (Exception e) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed)); } #pragma warning restore } diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/GroupClassGenerator.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/GroupClassGenerator.cs index f5a56bb..9bc1bcf 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/GroupClassGenerator.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/GroupClassGenerator.cs @@ -66,7 +66,7 @@ public override void Generate() if (UtilEditor.Library.GroupsLookup.Count <= 0) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); StructHandler.WriteFooter(file); return; } @@ -83,7 +83,7 @@ public override void Generate() groupDupNameLookup[parsedName]++; dupeChangedName = $"{parsedName}{groupDupNameLookup[parsedName]}"; - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructElementNameAlreadyExists)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructElementNameAlreadyExists)); } try @@ -100,7 +100,7 @@ public override void Generate() #pragma warning disable catch (Exception e) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed)); } #pragma warning restore } @@ -121,7 +121,7 @@ public override void Generate() #pragma warning disable catch (Exception e) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed)); } #pragma warning restore } diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/MixerClassGenerator.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/MixerClassGenerator.cs index 8d271df..34baa51 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/MixerClassGenerator.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/MixerClassGenerator.cs @@ -57,13 +57,13 @@ public override void Generate() if (data == null) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); } else { if (data.Count <= 0) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); } else { @@ -76,7 +76,7 @@ public override void Generate() #pragma warning disable catch (Exception e) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed)); } #pragma warning restore } diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/StructHandler.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/StructHandler.cs index c1194fb..37fec73 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/StructHandler.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/StructHandler.cs @@ -133,7 +133,7 @@ private static void ResetMixerClass() } - [MenuItem("Tools/Carter Games/Audio Manager/Reset Music Track Helper Class", priority = 35)] + [MenuItem("Tools/Carter Games/Audio Manager/Reset Music Playlist Helper Class", priority = 35)] private static void ResetTrackClass() { GenerateEmptyClass(TrackGenerator); diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/TrackClassGenerator.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/TrackClassGenerator.cs index 2004404..e1623df 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/TrackClassGenerator.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Enum Generation/TrackClassGenerator.cs @@ -14,8 +14,8 @@ public sealed class TrackClassGenerator : StructGeneratorBase ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ public override string LinePrefix => " public const string"; - public override string ClassPath => UtilEditor.GetPathOfFile("track", "Utility/Generated Classes/Track.cs"); - public override string ClassName => "Track"; + public override string ClassPath => UtilEditor.GetPathOfFile("playlist", "Utility/Generated Classes/Playlist.cs"); + public override string ClassName => "Playlist"; /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Methods @@ -31,13 +31,13 @@ public override void Generate() if (data == null) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); } else { if (data.Count <= 0) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorNoData)); } else { @@ -50,7 +50,7 @@ public override void Generate() #pragma warning disable catch (Exception e) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.StructGeneratorElementFailed)); } #pragma warning restore } diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs index e680f90..9886b0e 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs @@ -21,38 +21,93 @@ * THE SOFTWARE. */ +using System.Linq; +using System.Threading.Tasks; +using CarterGames.Common; using UnityEditor; namespace CarterGames.Assets.AudioManager.Editor { /// - /// Handles the auto setup of the save manager when the assets are changed in the project. + /// Handles any initial listeners in the project for the asset. /// - public sealed class AssetInitializer : AssetPostprocessor + public static class AssetInitializer { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── - | Methods + | Fields ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + // The key for if the asset has been initialized. + private static readonly string AssetInitializeKey = $"{FileEditorUtil.AssetName}_Session_EditorInitialize"; + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Properties + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// - /// Runs after assets have imported / script reload etc at a safe time to edit assets. + /// Gets if the asset is initialized or not. /// - private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, - string[] movedFromAssetPaths) + public static bool IsInitialized { - TryInitialize(); + get => SessionState.GetBool(AssetInitializeKey, false); + private set => SessionState.SetBool(AssetInitializeKey, value); } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Events + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Is raised when the asset is initialized. + /// + public static readonly Evt Initialized = new Evt(); + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ /// - /// Creates the scriptable objects for the asset if they don't exist yet. + /// Initializes the editor logic for the asset when called. /// + [InitializeOnLoadMethod] private static void TryInitialize() { - if (UtilEditor.HasInitialized) return; - UtilEditor.Initialize(); + if (IsInitialized) return; + InitializeEditorClasses(); + } + + + /// + /// Runs through all interfaces for initializing the editor asset logic and runs each in the defined order. + /// + private static async void InitializeEditorClasses() + { + var initClasses = InterfaceHelper.GetAllInterfacesInstancesOfType(); + + if (initClasses.Length > 0) + { + foreach (var init in initClasses.OrderBy(t => t.InitializeOrder)) + { + init.OnEditorInitialized(); + await Task.Yield(); + } + } + + OnAllClassesInitialized(); + } + + + + /// + /// Runs any post initialize logic to complete the process. + /// + private static void OnAllClassesInitialized() + { AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); + + IsInitialized = true; + Initialized.Raise(); } } } \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs.meta index ce96e26..e0d55a4 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs.meta +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetInitializer.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9c8384f057224c9c934a622428b9d1df +guid: 682d0b3a31e5de249811d8e43c2ca11b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetReloadHandler.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetReloadHandler.cs new file mode 100644 index 0000000..baa153b --- /dev/null +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetReloadHandler.cs @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System.Threading.Tasks; +using CarterGames.Common; +using UnityEditor; +using UnityEditor.Callbacks; + +namespace CarterGames.Assets.AudioManager.Editor +{ + /// + /// Handles any reload listeners in the project for the asset. + /// + public static class AssetReloadHandler + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Events + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Raises when the reload has occured. + /// + public static readonly Evt Reloaded = new Evt(); + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Add subscription to the delay call when scripts reload. + /// + [DidReloadScripts] + private static void FireReloadCalls() + { + if (EditorApplication.isCompiling || EditorApplication.isUpdating) + { + EditorApplication.delayCall -= CallListeners; + EditorApplication.delayCall += CallListeners; + return; + } + + EditorApplication.delayCall -= CallListeners; + EditorApplication.delayCall += CallListeners; + } + + + /// + /// Updates all the listeners when called. + /// + private static async void CallListeners() + { + var reloadClasses = InterfaceHelper.GetAllInterfacesInstancesOfType(); + + if (reloadClasses.Length > 0) + { + foreach (var init in reloadClasses) + { + init.OnEditorReloaded(); + await Task.Yield(); + } + } + + Reloaded.Raise(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Runtime/Music/Players/TrackType.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetReloadHandler.cs.meta similarity index 86% rename from Carter Games/Audio Manager/Code/Runtime/Music/Players/TrackType.cs.meta rename to Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetReloadHandler.cs.meta index e58b0bf..0386806 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Music/Players/TrackType.cs.meta +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetReloadHandler.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 17d399d0a9a14857b3a503ca4c1f42b6 +guid: 03eeb37bf80ccee49bc48980a444a3c4 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/Audio Manager/Code/Runtime/Music/Players/TrackType.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorInitialize.cs similarity index 78% rename from Carter Games/Audio Manager/Code/Runtime/Music/Players/TrackType.cs rename to Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorInitialize.cs index 3169477..618c8d5 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Music/Players/TrackType.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorInitialize.cs @@ -21,19 +21,11 @@ * THE SOFTWARE. */ -namespace CarterGames.Assets.AudioManager +namespace CarterGames.Assets.AudioManager.Editor { - public enum TrackType + public interface IAssetEditorInitialize { - /// - /// A single track that can loop. - /// - Single = 0, - - - /// - /// A list of tracks that can played through. - /// - Playlist = 1, + int InitializeOrder { get; } + void OnEditorInitialized(); } } \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorInitialize.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorInitialize.cs.meta new file mode 100644 index 0000000..fb4f4af --- /dev/null +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorInitialize.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6344249f496936549845a923263b5ae9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 0bf9d87d2c3ba2c49b4926fc7c8d5009, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorReload.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorReload.cs new file mode 100644 index 0000000..9a5b33f --- /dev/null +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorReload.cs @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Assets.AudioManager.Editor +{ + public interface IAssetEditorReload + { + void OnEditorReloaded(); + } +} \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorReload.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorReload.cs.meta new file mode 100644 index 0000000..7579bd1 --- /dev/null +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorReload.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 582ad7c0b394ada4c811145bedfe6a93 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 0bf9d87d2c3ba2c49b4926fc7c8d5009, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/ScriptableObjectInitialize.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/ScriptableObjectInitialize.cs new file mode 100644 index 0000000..1dbee9e --- /dev/null +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/ScriptableObjectInitialize.cs @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Assets.AudioManager.Editor +{ + /// + /// Handles any logic for generating/updating the scriptable objects for the asset where needed. + /// + public class ScriptableObjectInitialize : IAssetEditorInitialize, IAssetEditorReload + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | IAssetEditorInitialize + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Defines the order that this initializer run at. + /// + public int InitializeOrder => -1; + + + /// + /// Runs when the asset initialize flow is used. + /// + public void OnEditorInitialized() + { + if (ScriptableRef.HasAllAssets) return; + ScriptableRef.TryCreateAssets(); + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | IAssetEditorReload + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Runs when the asset reload flow is used. + /// + public void OnEditorReloaded() + { + if (ScriptableRef.HasAllAssets) return; + ScriptableRef.TryCreateAssets(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/ScriptableObjectInitialize.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/ScriptableObjectInitialize.cs.meta new file mode 100644 index 0000000..99553b9 --- /dev/null +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Initialization/ScriptableObjectInitialize.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c45ceeedcac51b14487d09fd59e1032f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 0bf9d87d2c3ba2c49b4926fc7c8d5009, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/AudioRemover.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/AudioRemover.cs index de4da42..2b97bfd 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/AudioRemover.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/AudioRemover.cs @@ -30,9 +30,16 @@ namespace CarterGames.Assets.AudioManager.Editor /// public sealed class AudioRemover : UnityEditor.AssetModificationProcessor { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + private static int loggedDataRemovals = 0; private static int loggedMixerRemovals = 0; + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | AssetModificationProcessor Implementation + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options) { @@ -40,6 +47,9 @@ private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAsset return AssetDeleteResult.DidNotDelete; } + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ private static void RemoveNullEntriesInLibrary(string removed) { @@ -200,13 +210,11 @@ private static void RemoveEntryFromAnyTrackList(SerializedProperty entry) for (var i = 0; i < UtilEditor.LibraryObject.Fp("tracks").Fpr("list").arraySize; i++) { var keyPair = UtilEditor.LibraryObject.Fp("tracks").Fpr("list").GetIndex(i); - var adjusted = 0; for (var j = 0; j < keyPair.Fpr("value").Fpr("tracks").arraySize; j++) { - if (clipName != keyPair.Fpr("value").Fpr("tracks").GetIndex(j - adjusted).Fpr("clipKey").stringValue) continue; - keyPair.Fpr("value").Fpr("tracks").DeleteIndex(j - adjusted); - adjusted += 1; + if (clipName != keyPair.Fpr("value").Fpr("tracks").GetIndex(j).Fpr("clipId").stringValue) continue; + keyPair.Fpr("value").Fpr("tracks").DeleteIndex(j); } } } diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/AudioScanner.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/AudioScanner.cs index 62ed281..f9663d6 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/AudioScanner.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/AudioScanner.cs @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Linq; +using CarterGames.Assets.AudioManager.Logging; using CarterGames.Common.Serializiation; using UnityEditor; using UnityEngine; @@ -34,12 +35,15 @@ namespace CarterGames.Assets.AudioManager.Editor /// Scans for audio clips when a new audio clip is added to the project... /// [DefaultExecutionOrder(1000)] - public sealed class AudioScanner : AssetPostprocessor + public sealed class AudioScanner : AssetPostprocessor, IAssetEditorReload { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Properties ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + private static bool ShouldUpdate { get; set; } + private static string[] LastImportedAssets { get; set; } + private static bool LibraryExists => ScriptableRef.HasLibraryFile; @@ -56,6 +60,16 @@ public static bool AnyAudioInProject } } + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | IAssetEditorReload Implementation + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + public void OnEditorReloaded() + { + if (!ShouldUpdate) return; + UpdateLibraryAsset(); + } + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Menu Items ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ @@ -85,39 +99,45 @@ public static void ManualScan() /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | AssetPostprocessors ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - + private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { if (importedAssets.Length > 0 && movedAssets.Length <= 0 && movedFromAssetPaths.Length <= 0) { - if (!UtilEditor.HasInitialized) - { - UtilEditor.Initialize(); - } + ShouldUpdate = true; + LastImportedAssets = importedAssets; + } + } + - CheckForAudioIfEmpty(); - AudioRemover.RemoveNullLibraryEntries(); + private static void UpdateLibraryAsset() + { + // AmDebugLogger.Normal($"Update Library: {ShouldUpdate}"); + + CheckForAudioIfEmpty(); + AudioRemover.RemoveNullLibraryEntries(); - if (importedAssets.Any(t => t.Contains(".mixer"))) - { - UtilEditor.SetLibraryMixerGroups(GetAllMixersInProject()); - StructHandler.RefreshMixers(); - } + if (LastImportedAssets.Any(t => t.Contains(".mixer"))) + { + UtilEditor.SetLibraryMixerGroups(GetAllMixersInProject()); + StructHandler.RefreshMixers(); + } - if (!PerUserSettings.ScannerHasNewAudioClip) return; + if (!PerUserSettings.ScannerHasNewAudioClip) return; - ScanForAudio(false); + ScanForAudio(false); - PerUserSettings.ScannerHasNewAudioClip = false; - } + PerUserSettings.ScannerHasNewAudioClip = false; + ShouldUpdate = false; } private void OnPostprocessAudio(AudioClip a) { PerUserSettings.ScannerHasNewAudioClip = true; + ShouldUpdate = true; } /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/FirstScan.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/FirstScan.cs index 14ef336..c70f7d4 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/FirstScan.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Scanning/FirstScan.cs @@ -28,36 +28,14 @@ namespace CarterGames.Assets.AudioManager.Editor /// /// Handles the initial scan when the asset is imported. /// - public static class FirstScan + public class FirstScan : IAssetEditorReload { - /// - /// Runs when the editor is opened... - /// - [InitializeOnLoadMethod] - private static void Init() + public void OnEditorReloaded() { if (PerUserSettings.ScannerInitialized || UtilEditor.Library.LibraryLookup.Count > 0) { - EditorApplication.update -= ShowFirstScan; - return; + ShowFirstScan(); } - - EditorApplication.update -= ShowFirstScan; - EditorApplication.update += ShowFirstScan; - } - - - [InitializeOnLoadMethod] - private static void InitSettings() - { - if (UtilEditor.RuntimeSettings.SequencePrefab != null) - { - EditorApplication.delayCall -= UtilEditor.RuntimeSettings.Initialize; - return; - } - - EditorApplication.delayCall -= UtilEditor.RuntimeSettings.Initialize; - EditorApplication.delayCall += UtilEditor.RuntimeSettings.Initialize; } diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Search Generation/TrackSearchProvider.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Search Generation/TrackSearchProvider.cs index 6fa1d56..30aa317 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Search Generation/TrackSearchProvider.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Search Generation/TrackSearchProvider.cs @@ -72,7 +72,7 @@ public List CreateSearchTree(SearchWindowContext context) var searchList = new List(); // The group that names the search window popup when searching... - searchList.Add(new SearchTreeGroupEntry(new GUIContent("Search track lists"), 0)); + searchList.Add(new SearchTreeGroupEntry(new GUIContent("Search playlists"), 0)); foreach (var tracks in UtilEditor.Library.MusicTrackLookup) { diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Settings.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Settings.meta new file mode 100644 index 0000000..3a6ca6b --- /dev/null +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Settings.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8e2d1d4565d945e9bea75d92d2abcb64 +timeCreated: 1714218018 \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Settings/SettingsInitialize.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Settings/SettingsInitialize.cs new file mode 100644 index 0000000..a8d591c --- /dev/null +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Settings/SettingsInitialize.cs @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using UnityEngine; + +namespace CarterGames.Assets.AudioManager.Editor +{ + /// + /// Handles initializing the settings asset of the asset. + /// + public sealed class SettingsInitialize : IAssetEditorInitialize, IAssetEditorReload + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | IAssetEditorInitialize Implementation + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + public int InitializeOrder => 200; + + + public void OnEditorInitialized() + { + TryInitializeSettings(); + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | IAssetEditorReload Implementation + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + public void OnEditorReloaded() + { + TryInitializeSettings(); + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + private static void TryInitializeSettings() + { + var changed = false; + + if (UtilEditor.SettingsObject.Fp("sequencePrefab").objectReferenceValue == null) + { + UtilEditor.SettingsObject.Fp("sequencePrefab").objectReferenceValue = Resources.Load(UtilRuntime.DefaultAudioSequencePrefabResourcesPath); + changed = true; + } + + if (UtilEditor.SettingsObject.Fp("audioPrefab").objectReferenceValue == null) + { + UtilEditor.SettingsObject.Fp("audioPrefab").objectReferenceValue = Resources.Load(UtilRuntime.DefaultAudioPrefabResourcesPath); + changed = true; + } + + if (!changed) return; + + UtilEditor.SettingsObject.ApplyModifiedProperties(); + UtilEditor.SettingsObject.Update(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Settings/SettingsInitialize.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Settings/SettingsInitialize.cs.meta new file mode 100644 index 0000000..dd4821c --- /dev/null +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Settings/SettingsInitialize.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 718b2be4079042b6882ed7d0ef81d97e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 0bf9d87d2c3ba2c49b4926fc7c8d5009, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation.meta index 605591d..34ee14f 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation.meta +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: fb0cc8d1044c4c49a00a559d8298b5fd +fileFormatVersion: 2 +guid: 48f93a89981d8d842adf4ed565453554 timeCreated: 1687686663 \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionAutoCheck.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionAutoCheck.cs index fcfd977..34f1ae5 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionAutoCheck.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionAutoCheck.cs @@ -1,20 +1,20 @@ /* * Copyright (c) 2024 Carter Games - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * - * + * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionAutoCheck.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionAutoCheck.cs.meta index f7cf330..5214b6c 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionAutoCheck.cs.meta +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionAutoCheck.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f3c2bdfc07d506049b9fe68eccbd2e6e +guid: 3893b16d4bcc2b444ad01aff270f279f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionChecker.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionChecker.cs index e335f63..fa0058e 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionChecker.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionChecker.cs @@ -1,20 +1,20 @@ /* * Copyright (c) 2024 Carter Games - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * - * + * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionChecker.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionChecker.cs.meta index fa25df6..b5c402b 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionChecker.cs.meta +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionChecker.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: fe710ecaa591b474d9f53b753c838648 +guid: d996d441545715345a14ed33f4e4a62b MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionData.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionData.cs index b76d08a..baf3c5f 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionData.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionData.cs @@ -1,20 +1,20 @@ /* * Copyright (c) 2024 Carter Games - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * - * + * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN @@ -104,14 +104,15 @@ public bool Match(string toCompare) /// If the entry is greater on any (major/minor/patch) value. public bool IsHigherVersion(string toCompare) { - var current = VersionNumber; - var remote = new VersionNumber(toCompare); + var aVN = VersionNumber; + var bVN = new VersionNumber(toCompare); - if (Match(toCompare)) return false; + if (Match(toCompare)) + { + return false; + } - if (current.Major < remote.Major) return true; - if (current.Major.Equals(remote.Major) && current.Minor < remote.Minor) return true; - return current.Major.Equals(remote.Major) && current.Minor.Equals(remote.Minor) && current.Patch < remote.Patch; + return (aVN.Major < bVN.Major) || (aVN.Minor < bVN.Minor) || (aVN.Patch < bVN.Patch); } } } \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionData.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionData.cs.meta index 2ccf75b..763eb35 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionData.cs.meta +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionData.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5f28136b8376630408b5405318c8d116 +guid: 25ab23050a9541942ac79a2f2ffd5f1f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionEditorGUI.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionEditorGUI.cs index aacf8e2..13f7597 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionEditorGUI.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionEditorGUI.cs @@ -1,20 +1,20 @@ /* * Copyright (c) 2024 Carter Games - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * - * + * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionEditorGUI.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionEditorGUI.cs.meta index 561f8a1..bf13a32 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionEditorGUI.cs.meta +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionEditorGUI.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 776e0e26a50f67c489fbeeef51400067 +guid: a5b0191ea7baa5a439fc0b2d923d2766 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionInfo.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionInfo.cs index dbaf8b1..827b35c 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionInfo.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionInfo.cs @@ -14,7 +14,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionInfo.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionInfo.cs.meta index 08376e2..9c6ab17 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionInfo.cs.meta +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionInfo.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ae6cf16ec60e1aa46810bb87560742ca +guid: 9cba0e49c5bab414397518df9cec2567 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionNumber.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionNumber.cs index cde9e74..301840d 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionNumber.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionNumber.cs @@ -1,20 +1,20 @@ /* * Copyright (c) 2024 Carter Games - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * - * + * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionNumber.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionNumber.cs.meta index 2a6f744..c8aea52 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionNumber.cs.meta +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionNumber.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3aa4f85ad1289bc4da4daab0a89a68f1 +guid: 499eeea2eee7a2141b9c5bb385fe1339 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionPacket.cs b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionPacket.cs index 14ba75d..2c03ce4 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionPacket.cs +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionPacket.cs @@ -1,20 +1,20 @@ /* * Copyright (c) 2024 Carter Games - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * - * + * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN diff --git a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionPacket.cs.meta b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionPacket.cs.meta index 0dbaf6c..af407ad 100644 --- a/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionPacket.cs.meta +++ b/Carter Games/Audio Manager/Code/Editor/Systems/Version Validation/VersionPacket.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c1629bdcee75f234ea700949475828e1 +guid: 3778f0eb3f3aaa040a3b5e627558bd8d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Carter Games/Audio Manager/Code/Editor/Utility/AssetVersionData.cs b/Carter Games/Audio Manager/Code/Editor/Utility/AssetVersionData.cs index ef1b57c..6439088 100644 --- a/Carter Games/Audio Manager/Code/Editor/Utility/AssetVersionData.cs +++ b/Carter Games/Audio Manager/Code/Editor/Utility/AssetVersionData.cs @@ -31,7 +31,7 @@ public static class AssetVersionData /// /// The version number of the asset. /// - public static string VersionNumber => "3.0.5"; + public static string VersionNumber => "3.0.6"; /// @@ -40,6 +40,6 @@ public static class AssetVersionData /// /// Asset owner is in the UK, so its D/M/Y format. /// - public static string ReleaseDate => "21/03/2024"; + public static string ReleaseDate => "13/05/2024"; } } \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs b/Carter Games/Audio Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs new file mode 100644 index 0000000..04c6dce --- /dev/null +++ b/Carter Games/Audio Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using System; +using System.Linq; + +namespace CarterGames.Assets.AudioManager.Editor +{ + public static class InterfaceHelper + { + /// + /// Gets all the interface implementations and returns the result (Editor Only) + /// + /// An Array of the interface type + public static T[] GetAllInterfacesInstancesOfType() + { + var types = AppDomain.CurrentDomain.GetAssemblies() + .SelectMany(x => x.GetTypes()) + .Where(x => x.IsClass && typeof(T).IsAssignableFrom(x)); + + return types.Select(type => (T)Activator.CreateInstance(type)).ToArray(); + } + } +} \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs.meta b/Carter Games/Audio Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs.meta new file mode 100644 index 0000000..bf70828 --- /dev/null +++ b/Carter Games/Audio Manager/Code/Editor/Utility/Editor Method Aid/InterfaceHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eb672985cfa54bc48561d214e8118453 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 0bf9d87d2c3ba2c49b4926fc7c8d5009, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Audio Manager/Code/Editor/Utility/Scriptable Assets/ScriptableRef.cs b/Carter Games/Audio Manager/Code/Editor/Utility/Scriptable Assets/ScriptableRef.cs index 28959dd..aaa9701 100644 --- a/Carter Games/Audio Manager/Code/Editor/Utility/Scriptable Assets/ScriptableRef.cs +++ b/Carter Games/Audio Manager/Code/Editor/Utility/Scriptable Assets/ScriptableRef.cs @@ -68,9 +68,8 @@ public static bool HasLibraryFile { get { - var files = Directory.GetFiles(DataFolderPath); - files = files.Where(t => !t.Contains(".meta")).ToArray(); - return files.Contains(LibraryAssetPath); + var assets = AssetDatabase.FindAssets(AudioManagerLibraryFilter); + return assets != null && assets.Length > 0; } } @@ -122,5 +121,45 @@ public static bool HasLibraryFile public static bool HasAllAssets => File.Exists(AssetIndexPath) && File.Exists(SettingsAssetPath) && File.Exists(LibraryAssetPath); + + + /// + /// Tries to create any missing assets when called. + /// + public static void TryCreateAssets() + { + AssetDatabase.StartAssetEditing(); + + if (assetIndexCache == null) + { + FileEditorUtil.CreateSoGetOrAssignAssetCache( + ref assetIndexCache, + AssetIndexFilter, + AssetIndexPath, + AssetName, $"{AssetName}/Resources/Asset Index.asset"); + } + + + if (settingsAssetRuntimeCache == null) + { + FileEditorUtil.CreateSoGetOrAssignAssetCache( + ref settingsAssetRuntimeCache, + RuntimeSettingsFilter, + SettingsAssetPath, + AssetName, $"{AssetName}/Data/Runtime Settings.asset"); + } + + + if (audioLibraryCache == null) + { + FileEditorUtil.CreateSoGetOrAssignAssetCache( + ref audioLibraryCache, + AudioManagerLibraryFilter, + LibraryAssetPath, + AssetName, $"{AssetName}/Data/Library.asset"); + } + + AssetDatabase.StopAssetEditing(); + } } } \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Editor/Utility/UtilEditor.cs b/Carter Games/Audio Manager/Code/Editor/Utility/UtilEditor.cs index b989a60..f09ab2a 100644 --- a/Carter Games/Audio Manager/Code/Editor/Utility/UtilEditor.cs +++ b/Carter Games/Audio Manager/Code/Editor/Utility/UtilEditor.cs @@ -236,35 +236,6 @@ public static bool HasInitialized /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Methods ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ - - public static void Initialize() - { - if (HasInitialized) return; - - AssetDatabase.Refresh(); - - if (ScriptableRef.assetIndexCache == null) - { - var index = AssetIndex; - } - - if (ScriptableRef.settingsAssetRuntimeCache == null) - { - var rSettings = RuntimeSettings; - } - - if (ScriptableRef.audioLibraryCache == null) - { - var library = Library; - } - - AssetIndexHandler.UpdateIndex(); - EditorUtility.SetDirty(AssetIndex); - - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - } - /// /// Checks to see if a file exists in the editor. diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/AudioManager.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/AudioManager.cs index 4a2aa68..90a71cf 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/AudioManager.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/AudioManager.cs @@ -90,7 +90,7 @@ private static AudioPlayerSequence PlayBase(string request, IEditModule[] edits, // if not, do nothing as it won't be heard... if (!AssetAccessor.GetAsset().CanPlayAudio) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); return null; } @@ -147,7 +147,7 @@ private static AudioPlayerSequence PlayGroupBase(string request, IEditModule[] e // if not, do nothing as it won't be heard... if (!AssetAccessor.GetAsset().CanPlayAudio) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); return null; } @@ -183,7 +183,7 @@ private static AudioPlayerSequence PlayGroupBase(string[] request, GroupPlayMode // if not, do nothing as it won't be heard... if (!AssetAccessor.GetAsset().CanPlayAudio) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); return null; } diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/DelayEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/DelayEdit.cs index b0d536c..90d9d2c 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/DelayEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/DelayEdit.cs @@ -38,7 +38,11 @@ public sealed class DelayEdit : IEditModule | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => false; + /// /// Processes the edit when called. diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/DynamicStartTimeEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/DynamicStartTimeEdit.cs index 95155c3..b013cba 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/DynamicStartTimeEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/DynamicStartTimeEdit.cs @@ -38,8 +38,12 @@ public sealed class DynamicStartTimeEdit : IEditModule | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => false; + /// /// Processes the edit when called. /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/GlobalVarianceEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/GlobalVarianceEdit.cs index ab2fc8f..fdebb3c 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/GlobalVarianceEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/GlobalVarianceEdit.cs @@ -38,8 +38,12 @@ public sealed class GlobalVarianceEdit : IEditModule | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => true; + /// /// Processes the edit when called. /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/IEditModule.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/IEditModule.cs index 298cf48..8fa70fa 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/IEditModule.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/IEditModule.cs @@ -28,6 +28,9 @@ namespace CarterGames.Assets.AudioManager /// public interface IEditModule { + /// + /// Gets if the edits should process when looping + /// bool ProcessOnLoop { get; } diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/LoopEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/LoopEdit.cs index ceca0fb..e97c416 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/LoopEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/LoopEdit.cs @@ -59,14 +59,21 @@ public sealed class LoopEdit : IEditModule public bool ShouldLoopWithDelays => !IgnoreDelayAfterFirstCall; + /// + /// Gets the current loop total. + /// public int CurrentLoopCount { get; set; } /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => false; + /// /// Processes the edit when called. /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/MixerEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/MixerEdit.cs index 5fc0a26..a29e0c8 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/MixerEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/MixerEdit.cs @@ -40,8 +40,12 @@ public sealed class MixerEdit : IEditModule | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => false; + /// /// Processes the edit when called. /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/MuteEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/MuteEdit.cs index a8b0e32..7ec1dee 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/MuteEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/MuteEdit.cs @@ -38,8 +38,12 @@ public sealed class MuteEdit : IEditModule | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => false; + /// /// Processes the edit when called. /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/ParentEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/ParentEdit.cs index f38c2f1..21c8110 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/ParentEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/ParentEdit.cs @@ -40,8 +40,12 @@ public sealed class ParentEdit : IEditModule | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => false; + /// /// Processes the edit when called. /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PitchEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PitchEdit.cs index 6c5d1b4..987fdf0 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PitchEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PitchEdit.cs @@ -48,8 +48,12 @@ public sealed class PitchEdit : IEditModule | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => true; + /// /// Processes the edit when called. /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PoolingEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PoolingEdit.cs new file mode 100644 index 0000000..96bb453 --- /dev/null +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PoolingEdit.cs @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +namespace CarterGames.Assets.AudioManager +{ + /// + /// An audio sequence edit that modifies the pooling logic for the sequence the player is on. + /// + public sealed class PoolingEdit : IEditModule + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Properties + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + private bool RecycleOnComplete { get; set; } = true; + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | IAudioEditModule + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Gets if the edits should process when looping + /// + public bool ProcessOnLoop => false; + + + /// + /// Processes the edit when called. + /// + /// The AudioSource to edit. + public void Process(AudioPlayer source) + { + source.PlayerSequence.RecycleOnComplete = RecycleOnComplete; + } + + + /// + /// Revers the edit to default when called. + /// + /// The AudioSource to edit. + public void Revert(AudioPlayer source) + { + source.PlayerSequence.RecycleOnComplete = true; + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Makes a new pooling edit with the setting entered. + /// + /// The value to set to. + public PoolingEdit(bool value) + { + RecycleOnComplete = value; + } + } +} \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PoolingEdit.cs.meta b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PoolingEdit.cs.meta new file mode 100644 index 0000000..97aa0d4 --- /dev/null +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PoolingEdit.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 560d76cacce24ec0838956b0b109ff78 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 0bf9d87d2c3ba2c49b4926fc7c8d5009, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PositionEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PositionEdit.cs index 6617064..282b4ef 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PositionEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PositionEdit.cs @@ -41,8 +41,12 @@ public sealed class PositionEdit : IEditModule | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => false; + /// /// Processes the edit when called. /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PriorityEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PriorityEdit.cs index 929084c..f077656 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PriorityEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/PriorityEdit.cs @@ -40,8 +40,12 @@ public sealed class PriorityEdit : IEditModule | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => false; + /// /// Processes the edit when called. /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/StartTimeEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/StartTimeEdit.cs index 259c1e5..6a5ac05 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/StartTimeEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/StartTimeEdit.cs @@ -38,8 +38,12 @@ public sealed class StartTimeEdit : IEditModule | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => false; + /// /// Processes the edit when called. /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/VolumeEdit.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/VolumeEdit.cs index a21605a..2b79107 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/VolumeEdit.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Edit Modules/VolumeEdit.cs @@ -45,8 +45,12 @@ public sealed class VolumeEdit : IEditModule | IAudioEditModule ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + /// + /// Gets if the edits should process when looping + /// public bool ProcessOnLoop => true; + /// /// Processes the edit when called. /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Player/AudioClipSettings.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Player/AudioClipSettings.cs index 6404982..19de5f0 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Player/AudioClipSettings.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Player/AudioClipSettings.cs @@ -48,7 +48,7 @@ public sealed class AudioClipSettings /// /// Creates a new clip settings class with the options desired. /// - /// + /// The options to apply. public AudioClipSettings(IEnumerable options) { Edits = new Dictionary(); diff --git a/Carter Games/Audio Manager/Code/Runtime/Audio/Player/AudioPlayerSequence.cs b/Carter Games/Audio Manager/Code/Runtime/Audio/Player/AudioPlayerSequence.cs index e6e9db7..6fc209f 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Audio/Player/AudioPlayerSequence.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Audio/Player/AudioPlayerSequence.cs @@ -87,6 +87,9 @@ public sealed class AudioPlayerSequence : MonoBehaviour /// Returns if any audio is currently being played from this sequence. /// public bool IsPlaying => Players.Any(t => t.IsPlaying); + + + public bool RecycleOnComplete { get; set; } /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Events @@ -286,6 +289,8 @@ public void PlayerComplete() Completed.Raise(); + if (!RecycleOnComplete) return; + foreach (var player in Players) { AudioPool.Return(player); @@ -319,5 +324,19 @@ private void Loop() Looped.Raise(); Play(); } + + + /// + /// Call to manually recycle this element into the pooling setup. + /// + public void RecycleManually() + { + foreach (var player in Players) + { + AudioPool.Return(player); + } + + AudioPool.Return(this); + } } } \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Runtime/Logging/AmDebugLogger.cs b/Carter Games/Audio Manager/Code/Runtime/Logging/AmDebugLogger.cs new file mode 100644 index 0000000..45e24f6 --- /dev/null +++ b/Carter Games/Audio Manager/Code/Runtime/Logging/AmDebugLogger.cs @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2018-Present Carter Games + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +using UnityEngine; + +namespace CarterGames.Assets.AudioManager.Logging +{ + /// + /// Used for sending logs formatted with the asset... + /// + public static class AmDebugLogger + { + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Fields + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + private const string LogPrefix = "Audio Manager | "; + private const string WarningPrefix = "Warning | "; + private const string ErrorPrefix = "Error | "; + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Properties + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Defines if the logs should appear unless overriden by the method that is calling for a log. + /// + private static bool CanShowMessage + { + get + { + if (PlayerPrefs.HasKey("AudioManager_Settings_ShowDebugLogs")) + { + return PlayerPrefs.GetInt("AudioManager_Settings_ShowDebugLogs") == 1; + } + + return false; + } + } + + /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── + | Methods + ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + + /// + /// Sends a standard message when called. + /// + /// The message to show. + /// Should the message override the user's preference? + public static void Normal(string message, bool overrideUserShowMessage = false) + { + if (!overrideUserShowMessage) + { + if (!CanShowMessage) return; + } + + Debug.Log($"{LogPrefix}{message}"); + } + + + /// + /// Sends an warning message when called. + /// + /// The message to show. + /// Should the message override the user's preference? + public static void Warning(string message, bool overrideUserShowMessage = false) + { + if (!overrideUserShowMessage) + { + if (!CanShowMessage) return; + } + + Debug.LogWarning($"{LogPrefix}{WarningPrefix}{message}"); + } + + + /// + /// Sends an error message when called. + /// + /// The message to show. + /// Should the message override the user's preference? + public static void Error(string message, bool overrideUserShowMessage = false) + { + if (!overrideUserShowMessage) + { + if (!CanShowMessage) return; + } + + Debug.LogError($"{LogPrefix}{ErrorPrefix}{message}"); + } + } +} \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Runtime/Logging/AmDebugLogger.cs.meta b/Carter Games/Audio Manager/Code/Runtime/Logging/AmDebugLogger.cs.meta new file mode 100644 index 0000000..9c7b662 --- /dev/null +++ b/Carter Games/Audio Manager/Code/Runtime/Logging/AmDebugLogger.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9009c20b9ddaa9b4daa8ba038e25e78d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 0bf9d87d2c3ba2c49b4926fc7c8d5009, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Carter Games/Audio Manager/Code/Runtime/Logging/CarterGames.Assets.AudioManager.Logging.dll b/Carter Games/Audio Manager/Code/Runtime/Logging/CarterGames.Assets.AudioManager.Logging.dll deleted file mode 100644 index 94275b5d4fddc554b47ee67d9a91daad3b706889..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5632 zcmeHLO>87b6@Jw-Ymdk5U}u9_$OhW+X5*}#W>z+Y1;=>one}?(zj*BZ0VBI-rabPX zr+ZZ0{v%;AhoFEE3Q~xK!U4D-gpfeukOUByL~vj^A~?WCB5;ThKNo~J?DD1(}<>rP60<^e1T|MBQaB z1JPPmiQWO-&rTDaXzhDF*(6Fe^`{`8Z<4K0ZikRBGdTM6T4TQ<>0%PCS}IUwNZPkC zFuYNEJ!s=H2JbB;T_1)FN2{oebth_586z5R5;Z%F^>bn03_3#RdlAA8BB8baIl0H^ zZzoFA>Cu=m5}yWE65*p`S%XfYh1^XFwBC;prPFPL4G|Nk-+e=L4kUXz2dEu`c+5a! zOrqz8fOQx3W2f36bhZx~19y;`0+!LA#_0Y|J^LZYeQSRl0tc@TIqss^o9}2eZoGJ5 zT*Oi1J=h$!ver;`=*(FNh^q@4Vo&<661{@DvlUZ!PeuIk>?;-}y*7)-xPOiSR?bf2*b%g>@W zOC25qDFfTm%49Uh<2nkmqC(OJ!3p=S(}u8?EgOE!JNI86?HL1aNUHT@-M z24}-4*4aU4MF#KebI^3rAED`n#=s0`#eH-K{XtmNNpqmb=rZVCv<2EnyJ7-w#fzY6 z(6Z*sF+W5<5qIGk;HbZs9tK(hzvM2&17#Qn(auNe59;URfC&V=Sy368@hcmy93@YN zL1=pwTUDqk!<7l!E3W%nGcpM5sw96?D&+Hkb|mlERnHGXryMj?4c{6YQIu-aDa#-ZGknE9 zLY#N)9jWG(TnlK%DJwtl*Fx-bMdm!)-3gq4_Tm%mMu5%r%63R|rAK8sq)8c0c_GEi zW+Z2u{fs&7Zp@#zgNNk~9?!`fZBPYom`^i!=RDLZNm8^zMYJJ)4zyJYv}PT4Ta-sn z3F8oD$lOPt9HBCJ7gfB#j<2#i7?qF~(4-EX%-zLC*540Zv|D!muCaTSk1x%|SwkCw*s zpa0Hd-+1}2FI=FcDMTt^k~jjUyPL&~W_y$EhGF1*G%_Hm%n>p&8D_MoOqDG=!7*}Sll~o2jes6A>51}w9Wt|bLU=X-U;eB zIc9NGQj*7?;u`_yr$ysv&UKMqHr&vuyAq0yDQ{gW2U&nH9qxOL()fnpktcxiD(;W3 z;xe{S%oo4%+Nsh&^6JzNr(gTx@A^K&cT&oKWH~xJO?^f$ujoVCEaE7X%USaQ^KsKO z^Kuh6>v~Okp*gR7KBJcPDQ?Ec_(91WvbIeeSA4Ly^u*dd6u=t#+f(ww8R>2Q|2G0c zZ`^U@s)Ii2+d5@$p=Ue(cDy`B^b)^#ae2uY26qwpcLlUS3*e^kr9BII3iMp`)lEN6 z{`p4qHPRRvwI7Q`{*Gya)mr{05yCcI$nJ;%{$*fbY{Q=K5drc&Oao^_r%EP}MU|z{5K2=v7r|9k`^AhF$I7T&(BFv44$Nu=M8o zIjrM3kNJK0zJa)hcoGgqbw8dQSE3K=F^ve-u!}BMX5MxjhQ9TS8U4>_apbMP)VEjo HuMzksz$^)N diff --git a/Carter Games/Audio Manager/Code/Runtime/Logging/CarterGames.Assets.AudioManager.Logging.dll.meta b/Carter Games/Audio Manager/Code/Runtime/Logging/CarterGames.Assets.AudioManager.Logging.dll.meta deleted file mode 100644 index 22239a4..0000000 --- a/Carter Games/Audio Manager/Code/Runtime/Logging/CarterGames.Assets.AudioManager.Logging.dll.meta +++ /dev/null @@ -1,33 +0,0 @@ -fileFormatVersion: 2 -guid: 4de79c9400b72924ab8bcedb75ccb5c2 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 0 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 1 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/Carter Games/Audio Manager/Code/Runtime/Music/Data/MusicTrackList.cs b/Carter Games/Audio Manager/Code/Runtime/Music/Data/MusicPlaylist.cs similarity index 92% rename from Carter Games/Audio Manager/Code/Runtime/Music/Data/MusicTrackList.cs rename to Carter Games/Audio Manager/Code/Runtime/Music/Data/MusicPlaylist.cs index 47fa937..873a88e 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Music/Data/MusicTrackList.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Music/Data/MusicPlaylist.cs @@ -25,7 +25,6 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; -using UnityEngine.Serialization; namespace CarterGames.Assets.AudioManager { @@ -33,7 +32,7 @@ namespace CarterGames.Assets.AudioManager /// Contains all the data for a track list of music. /// [Serializable] - public sealed class MusicTrackList + public sealed class MusicPlaylist { /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Fields @@ -41,7 +40,7 @@ public sealed class MusicTrackList [SerializeField] private string listKey; [SerializeField] private List tracks; - [SerializeField] private TrackType trackListType; + // [SerializeField] private TrackType playlistType; [SerializeField] private bool loop = true; [SerializeField] private bool shuffle = false; @@ -61,10 +60,11 @@ public sealed class MusicTrackList | Properties ───────────────────────────────────────────────────────────────────────────────────────────────────────────── */ + // For a future update... /// /// Gets the type of track list this list is. /// - public TrackType TrackListType => trackListType; + // public TrackType PlaylistType => playlistType; /// @@ -260,18 +260,28 @@ public List GetTracks() public IMusicPlayer GetMusicPlayer() { if (playerRef != null) return playerRef; - - switch (trackListType) + + if (tracks.Count > 0) { - case TrackType.Single: - playerRef = new SingleMusicTrackPlayer(); - break; - case TrackType.Playlist: - playerRef = new PlaylistMusicTrackPlayer(); - break; - default: - break; + playerRef = new SingleMusicTrackPlayer(); } + else + { + playerRef = new PlaylistMusicTrackPlayer(); + } + + // For future updates when layered music is added in.... + // switch (playlistType) + // { + // case TrackType.Single: + // playerRef = new SingleMusicTrackPlayer(); + // break; + // case TrackType.Playlist: + // playerRef = new PlaylistMusicTrackPlayer(); + // break; + // default: + // break; + // } return playerRef; } diff --git a/Carter Games/Audio Manager/Code/Runtime/Music/Data/MusicTrackList.cs.meta b/Carter Games/Audio Manager/Code/Runtime/Music/Data/MusicPlaylist.cs.meta similarity index 100% rename from Carter Games/Audio Manager/Code/Runtime/Music/Data/MusicTrackList.cs.meta rename to Carter Games/Audio Manager/Code/Runtime/Music/Data/MusicPlaylist.cs.meta diff --git a/Carter Games/Audio Manager/Code/Runtime/Music/MusicManager.cs b/Carter Games/Audio Manager/Code/Runtime/Music/MusicManager.cs index 06afc6a..2a73472 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Music/MusicManager.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Music/MusicManager.cs @@ -39,7 +39,7 @@ public static class MusicManager /// /// The track list that is currently playing. /// - private static MusicTrackList ActiveTrackList { get; set; } = null; + private static MusicPlaylist ActivePlaylist { get; set; } = null; /// @@ -60,7 +60,7 @@ public static class MusicManager public static AudioClip ActiveClip => MusicSource.Standard.MainSource.clip; - private static bool CanUse => ActiveTrackList != null; + private static bool CanUse => ActivePlaylist != null; /// @@ -180,26 +180,28 @@ public static float PlayerVolume /// /// Prepares a player for use, but doesn't play it. /// - /// The track list id to get. + /// The track list id to get. /// The player prepared for use. - public static IMusicPlayer Prepare(string id) + public static IMusicPlayer Prepare(string playlistId) { - var list = AssetAccessor.GetAsset().GetTrackList(id); + var list = AssetAccessor.GetAsset().GetTrackList(playlistId); if (list != null) { - ActiveTrackList = list; + ActivePlaylist = list; } else { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); return null; } - var player = ActiveTrackList.GetMusicPlayer(); + var player = ActivePlaylist.GetMusicPlayer(); - player.TrackList = ActiveTrackList; + player.Playlist = ActivePlaylist; + AssetAccessor.GetAsset().MusicTrackLookup["MyTrackListId"].GetTracks(); + return player; } @@ -207,27 +209,27 @@ public static IMusicPlayer Prepare(string id) /// /// Prepares a player for use, but doesn't play it. /// - /// The track list id to get. + /// The track list id to get. /// The track clip name to first play. /// The player prepared for use. - public static IMusicPlayer Prepare(string id, string firstTrack) + public static IMusicPlayer Prepare(string playlistId, string firstTrack) { - var trackList = AssetAccessor.GetAsset().GetTrackList(id); + var trackList = AssetAccessor.GetAsset().GetTrackList(playlistId); if (trackList != null) { - ActiveTrackList = trackList; + ActivePlaylist = trackList; } else { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); return null; } - var player = ActiveTrackList.GetMusicPlayer(); + var player = ActivePlaylist.GetMusicPlayer(); - player.TrackList = ActiveTrackList; - player.SetFirstTrack(ActiveTrackList.GetTrack(firstTrack)); + player.Playlist = ActivePlaylist; + player.SetFirstTrack(ActivePlaylist.GetTrack(firstTrack)); ActiveId = firstTrack; return player; @@ -237,28 +239,28 @@ public static IMusicPlayer Prepare(string id, string firstTrack) /// /// Prepares a player for use, but doesn't play it. /// - /// The track list id to get. + /// The track list id to get. /// The index of the first track to play in the list. /// The player prepared for use. - public static IMusicPlayer Prepare(string id, int firstTrackIndex) + public static IMusicPlayer Prepare(string playlistId, int firstTrackIndex) { - var trackList = AssetAccessor.GetAsset().GetTrackList(id); + var trackList = AssetAccessor.GetAsset().GetTrackList(playlistId); if (trackList != null) { - ActiveTrackList = trackList; + ActivePlaylist = trackList; } else { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); return null; } - var player = ActiveTrackList.GetMusicPlayer(); + var player = ActivePlaylist.GetMusicPlayer(); - player.TrackList = ActiveTrackList; - player.SetFirstTrack(ActiveTrackList.GetTracks()[firstTrackIndex]); - ActiveId = ActiveTrackList.GetTracksRaw()[firstTrackIndex].ClipId; + player.Playlist = ActivePlaylist; + player.SetFirstTrack(ActivePlaylist.GetTracks()[firstTrackIndex]); + ActiveId = ActivePlaylist.GetTracksRaw()[firstTrackIndex].ClipId; return player; } @@ -267,28 +269,28 @@ public static IMusicPlayer Prepare(string id, int firstTrackIndex) /// /// Plays the music track list of the entered id. /// - /// The id to play. + /// The id to play. /// The volume for the audio source to play at. - public static void Play(string id, float volume = 1f) + public static void Play(string playlistId, float volume = 1f) { if (!AssetAccessor.GetAsset().CanPlayMusic) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicDisabled)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicDisabled)); return; } - var trackList = AssetAccessor.GetAsset().GetTrackList(id); + var trackList = AssetAccessor.GetAsset().GetTrackList(playlistId); if (trackList != null) { - var player = Prepare(id); + var player = Prepare(playlistId); player.Volume = volume; Play(trackList); } else { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); } } @@ -296,28 +298,28 @@ public static void Play(string id, float volume = 1f) /// /// Plays the music track list of the entered id. /// - /// The list to play. + /// The list to play. /// The volume for the audio source to play at. - private static void Play(MusicTrackList trackList, float volume = 1f) + private static void Play(MusicPlaylist playlist, float volume = 1f) { if (!AssetAccessor.GetAsset().CanPlayMusic) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicDisabled)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicDisabled)); return; } - if (trackList == null) + if (playlist == null) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); return; } - ActiveTrackList = trackList; + ActivePlaylist = playlist; - Player = ActiveTrackList.GetMusicPlayer(); + Player = ActivePlaylist.GetMusicPlayer(); Player.Volume = volume; - Player.TrackList = ActiveTrackList; + Player.Playlist = ActivePlaylist; Player.TransitionIn(); Player.Play(); } @@ -377,7 +379,7 @@ public static void Stop() /// /// Transitions in the active player when called. /// - public static void TransitionIn() + public static void TransitionPlayerIn() { Player.TransitionIn(); } @@ -386,7 +388,7 @@ public static void TransitionIn() /// /// Transitions out the active player when called. /// - public static void TransitionOut() + public static void TransitionPlayerOut() { Player.TransitionOut(); } @@ -395,28 +397,28 @@ public static void TransitionOut() /// /// Transitions the active player when called to the new clip. /// - /// The clip to transition to. - public static void TransitionTo(string clip) + /// The clip to transition to. + public static void TransitionToTrack(string trackId) { if (!CanUse) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicTrackListNotSet)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicPlaylistNotSet)); return; } - if (!ActiveTrackList.LibraryHasTrackClip(clip) && !ActiveTrackList.TrackIsInList(clip)) + if (!ActivePlaylist.LibraryHasTrackClip(trackId) && !ActivePlaylist.TrackIsInList(trackId)) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); return; } - ActiveId = clip; + ActiveId = trackId; - Player.Transition.Data.AddParam("musicClip", ActiveTrackList.GetTrack(clip)); - Player.Transition.Data.AddParam("musicClipStartTime", ActiveTrackList.GetStartTime(clip)); + Player.Transition.Data.AddParam("musicClip", ActivePlaylist.GetTrack(trackId)); + Player.Transition.Data.AddParam("musicClipStartTime", ActivePlaylist.GetStartTime(trackId)); - Player.DefaultVolumeTransition.Data.AddParam("musicClip", ActiveTrackList.GetTrack(clip)); - Player.DefaultVolumeTransition.Data.AddParam("musicClipStartTime", ActiveTrackList.GetStartTime(clip)); + Player.DefaultVolumeTransition.Data.AddParam("musicClip", ActivePlaylist.GetTrack(trackId)); + Player.DefaultVolumeTransition.Data.AddParam("musicClipStartTime", ActivePlaylist.GetStartTime(trackId)); Player.Transition.Transition(TransitionDirection.InAndOut); } @@ -425,38 +427,38 @@ public static void TransitionTo(string clip) /// /// Transitions the active player when called to the new clip. /// - /// The clip to transition to. + /// The clip to transition to. /// The transition to use. /// The duration for the transition. Def: 1f - public static void TransitionTo(string clip, MusicTransition musicTransition, float duration = 1f) + public static void TransitionToTrack(string trackId, MusicTransition musicTransition, float duration = 1f) { - TransitionTo(clip, GetTransitionFromEnum(musicTransition, duration)); + TransitionToTrack(trackId, GetTransitionFromEnum(musicTransition, duration), duration); } /// /// Transitions the active player when called to the new clip. /// - /// The clip to transition to. + /// The clip to transition to. /// The transition to use. /// The duration for the transition. Def: 1f - public static void TransitionTo(string clip, IMusicTransition musicTransition, float duration = 1f) + public static void TransitionToTrack(string trackId, IMusicTransition musicTransition, float duration = 1f) { if (!CanUse) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicTrackListNotSet)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicPlaylistNotSet)); return; } - if (!ActiveTrackList.LibraryHasTrackClip(clip) && !ActiveTrackList.TrackIsInList(clip)) + if (!ActivePlaylist.LibraryHasTrackClip(trackId) && !ActivePlaylist.TrackIsInList(trackId)) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); return; } - ActiveId = clip; - musicTransition.Data.AddParam("musicClip", ActiveTrackList.GetTrack(clip)); - musicTransition.Data.AddParam("musicClipStartTime", ActiveTrackList.GetStartTime(clip)); + ActiveId = trackId; + musicTransition.Data.AddParam("musicClip", ActivePlaylist.GetTrack(trackId)); + musicTransition.Data.AddParam("musicClipStartTime", ActivePlaylist.GetStartTime(trackId)); musicTransition.Data.AddParam("duration", duration); musicTransition.Transition(TransitionDirection.InAndOut); } @@ -486,32 +488,32 @@ public static IMusicTransition GetTransitionFromEnum(MusicTransition musicTransi /// /// Sets the active track list and player, but nothing else. /// - /// The track list to use. - public static void SetTrackList(string trackListId) + /// The track list to use. + public static void SetPlaylist(string playlistId) { - SetTrackList(AssetAccessor.GetAsset().GetTrackList(trackListId)); + SetPlaylist(AssetAccessor.GetAsset().GetTrackList(playlistId)); } /// /// Sets the active track list and player, but nothing else. /// - /// The track list to use. - public static void SetTrackList(MusicTrackList trackList) + /// The track list to use. + public static void SetPlaylist(MusicPlaylist playlist) { - if (trackList == null) + if (playlist == null) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); return; } - if (ActiveTrackList != trackList) + if (ActivePlaylist != playlist) { - ActiveTrackList = trackList; + ActivePlaylist = playlist; } if (Player != null) return; - Player = ActiveTrackList.GetMusicPlayer(); + Player = ActivePlaylist.GetMusicPlayer(); } } } \ No newline at end of file diff --git a/Carter Games/Audio Manager/Code/Runtime/Music/Players/IMusicPlayer.cs b/Carter Games/Audio Manager/Code/Runtime/Music/Players/IMusicPlayer.cs index db47bfb..1e1ac5c 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Music/Players/IMusicPlayer.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Music/Players/IMusicPlayer.cs @@ -55,7 +55,7 @@ public interface IMusicPlayer /// /// Gets the track list. /// - MusicTrackList TrackList { get; set; } + MusicPlaylist Playlist { get; set; } /// diff --git a/Carter Games/Audio Manager/Code/Runtime/Music/Players/PlaylistMusicTrackPlayer.cs b/Carter Games/Audio Manager/Code/Runtime/Music/Players/PlaylistMusicTrackPlayer.cs index 0793aeb..3f71521 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Music/Players/PlaylistMusicTrackPlayer.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Music/Players/PlaylistMusicTrackPlayer.cs @@ -49,7 +49,7 @@ public sealed class PlaylistMusicTrackPlayer : IMusicPlayer /// /// The track list to play. /// - public MusicTrackList TrackList { get; set; } + public MusicPlaylist Playlist { get; set; } /// @@ -85,7 +85,7 @@ public sealed class PlaylistMusicTrackPlayer : IMusicPlayer /// /// Gets if the playlist player is at the end of the playlist or not. /// - private bool IsAtEnd => TrackList.GetTracks().Count.Equals(TracksPlayed); + private bool IsAtEnd => Playlist.GetTracks().Count.Equals(TracksPlayed); /// @@ -134,13 +134,13 @@ public IMusicTransition Transition if (TracksPlayed.Equals(0)) { if (customTransition != null) return customTransition; - if (TrackList.StartingTransition != null) return TrackList.StartingTransition; + if (Playlist.StartingTransition != null) return Playlist.StartingTransition; return DefaultVolumeTransition; } else { if (customTransition != null) return customTransition; - if (TrackList.SwitchingTransition != null) return TrackList.SwitchingTransition; + if (Playlist.SwitchingTransition != null) return Playlist.SwitchingTransition; return DefaultVolumeTransition; } } @@ -162,9 +162,9 @@ public IMusicTransition Transition private void SetToFirstTrack() { MusicManager.MusicSource.Standard.MainSource.playOnAwake = false; - MusicManager.MusicSource.Standard.MainSource.loop = TrackList.TrackListLoops; - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(StartingTrackIndex); - MusicManager.MusicSource.Standard.MainSource.clip = TrackList.GetTrack(StartingTrackIndex); + MusicManager.MusicSource.Standard.MainSource.loop = Playlist.TrackListLoops; + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(StartingTrackIndex); + MusicManager.MusicSource.Standard.MainSource.clip = Playlist.GetTrack(StartingTrackIndex); CurrentIndex = StartingTrackIndex; } @@ -174,9 +174,9 @@ private void SetToFirstTrack() /// public void Play() { - if (TrackList.PlayListShuffled) + if (Playlist.PlayListShuffled) { - StartingTrackIndex = Random.Range(0, TrackList.GetTracks().Count); + StartingTrackIndex = Random.Range(0, Playlist.GetTracks().Count); } else { @@ -188,7 +188,7 @@ public void Play() if (!AssetAccessor.GetAsset().CanPlayAudio) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); return; } @@ -197,7 +197,7 @@ public void Play() MusicRoutineHandler.RunRoutine(RoutineId, Co_LifetimeRoutine()); IsPlaying = true; - PlayedIndexes.Add(TrackList.GetTracks().IndexOf(MusicManager.MusicSource.Standard.MainSource.clip)); + PlayedIndexes.Add(Playlist.GetTracks().IndexOf(MusicManager.MusicSource.Standard.MainSource.clip)); MusicManager.Started.Raise(); } @@ -220,7 +220,7 @@ public void Resume() { if (!AssetAccessor.GetAsset().CanPlayAudio) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); return; } @@ -278,7 +278,7 @@ public void SkipForwards(bool smoothTransition = true) PlayedIndexes.Add(CurrentIndex); - if (TrackList.PlayListShuffled) + if (Playlist.PlayListShuffled) { CurrentIndex = GetRandomUnPlayedTrack(); } @@ -290,15 +290,15 @@ public void SkipForwards(bool smoothTransition = true) if (smoothTransition) { - Transition.Data.AddParam("musicClip", TrackList.GetTrack(CurrentIndex)); - Transition.Data.AddParam("musicClipStartTime", TrackList.GetStartTime(CurrentIndex)); + Transition.Data.AddParam("musicClip", Playlist.GetTrack(CurrentIndex)); + Transition.Data.AddParam("musicClipStartTime", Playlist.GetStartTime(CurrentIndex)); Transition.Transition(TransitionDirection.InAndOut); } else { - MusicManager.MusicSource.Standard.MainSource.clip = TrackList.GetTrack(CurrentIndex); - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(CurrentIndex); + MusicManager.MusicSource.Standard.MainSource.clip = Playlist.GetTrack(CurrentIndex); + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(CurrentIndex); TransitionIn(); } @@ -320,7 +320,7 @@ public void SkipBackwards(bool replayCurrentFirst = true, bool smoothTransition if (MusicManager.MusicSource.Standard.MainSource.time > 3f) { // Restart clip... - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(CurrentIndex); + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(CurrentIndex); if (smoothTransition) { @@ -343,15 +343,15 @@ public void SkipBackwards(bool replayCurrentFirst = true, bool smoothTransition if (smoothTransition) { - Transition.Data.AddParam("musicClip", TrackList.GetTrack(CurrentIndex)); - Transition.Data.AddParam("musicClipStartTime", TrackList.GetStartTime(CurrentIndex)); + Transition.Data.AddParam("musicClip", Playlist.GetTrack(CurrentIndex)); + Transition.Data.AddParam("musicClipStartTime", Playlist.GetStartTime(CurrentIndex)); Transition.Transition(TransitionDirection.InAndOut); } else { - MusicManager.MusicSource.Standard.MainSource.clip = TrackList.GetTrack(CurrentIndex); - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(CurrentIndex); + MusicManager.MusicSource.Standard.MainSource.clip = Playlist.GetTrack(CurrentIndex); + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(CurrentIndex); TransitionIn(); } @@ -373,7 +373,7 @@ private int GetRandomUnPlayedTrack() { var options = new List(); - for (var i = 0; i < TrackList.GetTracks().Count; i++) + for (var i = 0; i < Playlist.GetTracks().Count; i++) { if (PlayedIndexes.Contains(i)) continue; options.Add(i); @@ -394,17 +394,17 @@ private int GetRandomUnPlayedTrack() /// The clip to try and play. public void SetFirstTrack(AudioClip audioClip) { - if (!TrackList.GetTracks().Contains(audioClip)) + if (!Playlist.GetTracks().Contains(audioClip)) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); return; } - MusicManager.SetTrackList(TrackList); + MusicManager.SetPlaylist(Playlist); MusicManager.MusicSource.Standard.MainSource.playOnAwake = false; - MusicManager.MusicSource.Standard.MainSource.loop = TrackList.TrackListLoops; - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(0); + MusicManager.MusicSource.Standard.MainSource.loop = Playlist.TrackListLoops; + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(0); MusicManager.MusicSource.Standard.MainSource.clip = audioClip; MusicManager.MusicSource.Standard.MainSource.mute = @@ -414,19 +414,19 @@ public void SetFirstTrack(AudioClip audioClip) public void SetTrack(AudioClip audioClip) { - if (!TrackList.GetTracks().Contains(audioClip)) + if (!Playlist.GetTracks().Contains(audioClip)) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); return; } - MusicManager.SetTrackList(TrackList); + MusicManager.SetPlaylist(Playlist); - var indexOfTrack = TrackList.GetTracks().IndexOf(audioClip); + var indexOfTrack = Playlist.GetTracks().IndexOf(audioClip); MusicManager.MusicSource.Standard.MainSource.playOnAwake = false; - MusicManager.MusicSource.Standard.MainSource.loop = TrackList.TrackListLoops; - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(indexOfTrack); + MusicManager.MusicSource.Standard.MainSource.loop = Playlist.TrackListLoops; + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(indexOfTrack); MusicManager.MusicSource.Standard.MainSource.clip = audioClip; MusicManager.MusicSource.Standard.MainSource.mute = @@ -460,7 +460,7 @@ private IEnumerator Co_LifetimeRoutine() yield return null; - if (MusicManager.MusicSource.Standard.MainSource.time >= TrackList.GetEndTime(CurrentIndex)) + if (MusicManager.MusicSource.Standard.MainSource.time >= Playlist.GetEndTime(CurrentIndex)) { if (Mathf.Approximately(EndCheckTimeout, 0f)) { @@ -470,27 +470,27 @@ private IEnumerator Co_LifetimeRoutine() if (IsAtEnd) { - if (TrackList.TrackListLoops && !Transition.InProgress) + if (Playlist.TrackListLoops && !Transition.InProgress) { CurrentIndex = StartingTrackIndex; PlayedIndexes.Clear(); PlayedIndexes.Add(CurrentIndex); - Transition.Data.AddParam("musicClip", TrackList.GetTrack(CurrentIndex)); - Transition.Data.AddParam("musicClipStartTime", TrackList.GetStartTime(CurrentIndex)); + Transition.Data.AddParam("musicClip", Playlist.GetTrack(CurrentIndex)); + Transition.Data.AddParam("musicClipStartTime", Playlist.GetStartTime(CurrentIndex)); Transition.Completed.Add(OnTransitionCompleted); Transition.Transition(TransitionDirection.InAndOut); MusicManager.TrackChanged.Raise(); - EndCheckTimeout = TrackList.GetTrack(CurrentIndex).length / 20f; + EndCheckTimeout = Playlist.GetTrack(CurrentIndex).length / 20f; CanTransition = true; TracksPlayed = 0; } else { - if (MusicManager.MusicSource.Standard.MainSource.time >= TrackList.GetEndTime(CurrentIndex) - Transition.Data.GetParam("Duration")) + if (MusicManager.MusicSource.Standard.MainSource.time >= Playlist.GetEndTime(CurrentIndex) - Transition.Data.GetParam("Duration")) { TransitionOut(); CanTransition = false; @@ -505,7 +505,7 @@ private IEnumerator Co_LifetimeRoutine() { PlayedIndexes.Add(CurrentIndex); - if (TrackList.PlayListShuffled) + if (Playlist.PlayListShuffled) { CurrentIndex = GetRandomUnPlayedTrack(); } @@ -514,10 +514,10 @@ private IEnumerator Co_LifetimeRoutine() CurrentIndex++; } - EndCheckTimeout = TrackList.GetTrack(CurrentIndex).length / 20f; + EndCheckTimeout = Playlist.GetTrack(CurrentIndex).length / 20f; - Transition.Data.AddParam("musicClip", TrackList.GetTrack(CurrentIndex)); - Transition.Data.AddParam("musicClipStartTime", TrackList.GetStartTime(CurrentIndex)); + Transition.Data.AddParam("musicClip", Playlist.GetTrack(CurrentIndex)); + Transition.Data.AddParam("musicClipStartTime", Playlist.GetStartTime(CurrentIndex)); Transition.Completed.Add(OnTransitionCompleted); Transition.Transition(TransitionDirection.InAndOut); diff --git a/Carter Games/Audio Manager/Code/Runtime/Music/Players/SingleMusicTrackPlayer.cs b/Carter Games/Audio Manager/Code/Runtime/Music/Players/SingleMusicTrackPlayer.cs index 5ca0dca..5968ced 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Music/Players/SingleMusicTrackPlayer.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Music/Players/SingleMusicTrackPlayer.cs @@ -48,7 +48,7 @@ public sealed class SingleMusicTrackPlayer : IMusicPlayer /// /// The track list to play. /// - public MusicTrackList TrackList { get; set; } + public MusicPlaylist Playlist { get; set; } /// @@ -65,7 +65,7 @@ public IMusicTransition Transition get { if (customTransition != null) return customTransition; - if (TrackList.StartingTransition != null) return TrackList.StartingTransition; + if (Playlist.StartingTransition != null) return Playlist.StartingTransition; return DefaultVolumeTransition; } } @@ -109,12 +109,12 @@ public float Volume /// private void SetToFirstTrack() { - MusicManager.SetTrackList(TrackList); + MusicManager.SetPlaylist(Playlist); MusicManager.MusicSource.Standard.MainSource.playOnAwake = false; - MusicManager.MusicSource.Standard.MainSource.loop = TrackList.TrackListLoops; - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(0); - MusicManager.MusicSource.Standard.MainSource.clip = TrackList.GetTrack(0); + MusicManager.MusicSource.Standard.MainSource.loop = Playlist.TrackListLoops; + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(0); + MusicManager.MusicSource.Standard.MainSource.clip = Playlist.GetTrack(0); MusicManager.MusicSource.Standard.MainSource.volume = Volume; MusicManager.MusicSource.Standard.MainSource.mute = @@ -127,15 +127,15 @@ private void SetToFirstTrack() /// public void Play() { - Transition.Data.AddParam("musicClip", TrackList.GetTrack(0)); - Transition.Data.AddParam("musicClipStartTime", TrackList.GetStartTime(0)); + Transition.Data.AddParam("musicClip", Playlist.GetTrack(0)); + Transition.Data.AddParam("musicClipStartTime", Playlist.GetStartTime(0)); SetToFirstTrack(); TransitionIn(); if (!AssetAccessor.GetAsset().CanPlayAudio) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); return; } @@ -164,7 +164,7 @@ public void Resume() { if (!AssetAccessor.GetAsset().CanPlayAudio) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); return; } @@ -211,12 +211,12 @@ public void TransitionOut() /// public void SkipForwards(bool smoothTransition = true) { - if (TrackList.TrackListLoops) + if (Playlist.TrackListLoops) { - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(); + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(); - Transition.Data.AddParam("musicClip", TrackList.GetTrack(0)); - Transition.Data.AddParam("musicClipStartTime", TrackList.GetStartTime(0)); + Transition.Data.AddParam("musicClip", Playlist.GetTrack(0)); + Transition.Data.AddParam("musicClipStartTime", Playlist.GetStartTime(0)); Transition.Transition(TransitionDirection.InAndOut); } @@ -237,7 +237,7 @@ public void SkipBackwards(bool replayCurrentFirst = true, bool smoothTransition if (MusicManager.MusicSource.Standard.MainSource.time > 3f) { // Restart clip... - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(); + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(); } else { @@ -245,7 +245,7 @@ public void SkipBackwards(bool replayCurrentFirst = true, bool smoothTransition if (!AssetAccessor.GetAsset().CanPlayAudio) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.AudioDisabled)); return; } @@ -257,8 +257,8 @@ public void SkipBackwards(bool replayCurrentFirst = true, bool smoothTransition if (!smoothTransition) return; - Transition.Data.AddParam("musicClip", TrackList.GetTrack(0)); - Transition.Data.AddParam("musicClipStartTime", TrackList.GetStartTime(0)); + Transition.Data.AddParam("musicClip", Playlist.GetTrack(0)); + Transition.Data.AddParam("musicClipStartTime", Playlist.GetStartTime(0)); TransitionIn(); } @@ -270,15 +270,15 @@ public void SkipBackwards(bool replayCurrentFirst = true, bool smoothTransition /// The clip to try and play. public void SetFirstTrack(AudioClip audioClip) { - if (!TrackList.GetTracks().Contains(audioClip)) + if (!Playlist.GetTracks().Contains(audioClip)) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); return; } MusicManager.MusicSource.Standard.MainSource.playOnAwake = false; - MusicManager.MusicSource.Standard.MainSource.loop = TrackList.TrackListLoops; - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(0); + MusicManager.MusicSource.Standard.MainSource.loop = Playlist.TrackListLoops; + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(0); MusicManager.MusicSource.Standard.MainSource.clip = audioClip; MusicManager.MusicSource.Standard.MainSource.mute = @@ -288,15 +288,15 @@ public void SetFirstTrack(AudioClip audioClip) public void SetTrack(AudioClip audioClip) { - if (!TrackList.GetTracks().Contains(audioClip)) + if (!Playlist.GetTracks().Contains(audioClip)) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackClipNotInListOrLibrary)); return; } MusicManager.MusicSource.Standard.MainSource.playOnAwake = false; - MusicManager.MusicSource.Standard.MainSource.loop = TrackList.TrackListLoops; - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(0); + MusicManager.MusicSource.Standard.MainSource.loop = Playlist.TrackListLoops; + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(0); MusicManager.MusicSource.Standard.MainSource.clip = audioClip; MusicManager.MusicSource.Standard.MainSource.mute = @@ -343,11 +343,11 @@ private IEnumerator Co_LifetimeRoutine() yield return null; - if (MusicManager.MusicSource.Standard.MainSource.time >= TrackList.GetEndTime(0)) + if (MusicManager.MusicSource.Standard.MainSource.time >= Playlist.GetEndTime(0)) { - if (TrackList.TrackListLoops) + if (Playlist.TrackListLoops) { - MusicManager.MusicSource.Standard.MainSource.time = TrackList.GetStartTime(0); + MusicManager.MusicSource.Standard.MainSource.time = Playlist.GetStartTime(0); MusicManager.Looped.Raise(); } else diff --git a/Carter Games/Audio Manager/Code/Runtime/Music/Transitions/Data/TransitionData.cs b/Carter Games/Audio Manager/Code/Runtime/Music/Transitions/Data/TransitionData.cs index 4b9401d..2055e22 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Music/Transitions/Data/TransitionData.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Music/Transitions/Data/TransitionData.cs @@ -136,7 +136,7 @@ public T GetParam(string key) return (T)value; } - AmLog.Warning($"{AudioManagerErrorCode.TransitionDataParameterNotFound}\nUnable to get parameter {key}."); + AmDebugLogger.Warning($"{AudioManagerErrorCode.TransitionDataParameterNotFound}\nUnable to get parameter {key}."); return default; } @@ -155,7 +155,7 @@ public T GetParam(string key, T defValue) return (T)value; } - AmLog.Warning($"{AudioManagerErrorCode.TransitionDataParameterNotFound}\nUnable to get parameter {key}. Using provided default {defValue} instead."); + AmDebugLogger.Warning($"{AudioManagerErrorCode.TransitionDataParameterNotFound}\nUnable to get parameter {key}. Using provided default {defValue} instead."); return defValue; } @@ -175,7 +175,7 @@ public bool TryGetParam(string key, out T value) return true; } - AmLog.Warning($"{AudioManagerErrorCode.TransitionDataParameterNotFound}\nUnable to get parameter {key}."); + AmDebugLogger.Warning($"{AudioManagerErrorCode.TransitionDataParameterNotFound}\nUnable to get parameter {key}."); value = default; return false; } diff --git a/Carter Games/Audio Manager/Code/Runtime/Systems/Audio Library/AudioLibrary.cs b/Carter Games/Audio Manager/Code/Runtime/Systems/Audio Library/AudioLibrary.cs index ebdfeea..0fb1547 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Systems/Audio Library/AudioLibrary.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Systems/Audio Library/AudioLibrary.cs @@ -49,7 +49,7 @@ public class AudioLibrary : AudioManagerAsset [SerializeField] private SerializableDictionary mixers; [SerializeField] private SerializableDictionary mixersReverseLookup; - [SerializeField] private SerializableDictionary tracks; + [SerializeField] private SerializableDictionary tracks; [SerializeField] private SerializableDictionary tracksReverseLookup; /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── @@ -126,7 +126,7 @@ public int ClipCount /// /// Gets a lookup of all the music tracks in the library. /// - public Dictionary MusicTrackLookup => tracks; + public Dictionary MusicTrackLookup => tracks; /// @@ -155,7 +155,7 @@ public AudioData GetData(string request) return LibraryLookup[request]; } - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.ClipCannotBeFound)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.ClipCannotBeFound)); return null; } @@ -177,7 +177,7 @@ public GroupData GetGroup(string request) return GroupsLookup[request]; } - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.GroupCannotBeFound)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.GroupCannotBeFound)); return null; } @@ -199,7 +199,7 @@ public AudioMixerGroup GetMixer(string request) return MixerLookup[request].MixerGroup; } - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MixerCannotBeFound)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MixerCannotBeFound)); return null; } @@ -209,7 +209,7 @@ public AudioMixerGroup GetMixer(string request) /// /// The requested string. /// The track list found. - public MusicTrackList GetTrackList(string request) + public MusicPlaylist GetTrackList(string request) { if (ReverseTrackListLookup.ContainsKey(request)) { @@ -221,7 +221,7 @@ public MusicTrackList GetTrackList(string request) return MusicTrackLookup[request]; } - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.TrackListCannotBeFound)); return null; } @@ -249,7 +249,7 @@ public void OrderLibrary() { if (Application.isPlaying) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.EditorOnlyMethod)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.EditorOnlyMethod)); return; } @@ -274,7 +274,7 @@ public void SetMixerGroups(AudioMixerGroup[] inputMixerArray) if (Application.isPlaying) { - AmLog.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.EditorOnlyMethod)); + AmDebugLogger.Warning(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.EditorOnlyMethod)); return; } diff --git a/Carter Games/Audio Manager/Code/Runtime/Systems/Error Handling & Logs/AudioManagerErrorCode.cs b/Carter Games/Audio Manager/Code/Runtime/Systems/Error Handling & Logs/AudioManagerErrorCode.cs index ff17a3d..42496dc 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Systems/Error Handling & Logs/AudioManagerErrorCode.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Systems/Error Handling & Logs/AudioManagerErrorCode.cs @@ -49,7 +49,7 @@ public enum AudioManagerErrorCode TrackClipNotInListOrLibrary = 7, // (Runtime) Track/AudioClip not in the track list that is being played. TransitionDataParameterNotFound = 8, // (Runtime) Transition missing a parameter value. MusicPlayerNotInitialized = 9, // (Runtime) When a music player is null when a call was made. - MusicTrackListNotSet = 10, // (Runtime) When the user tries to play a track from a list before it is assigned. + MusicPlaylistNotSet = 10, // (Runtime) When the user tries to play a track from a list before it is assigned. /* ───────────────────────────────────────────────────────────────────────────────────────────────────────────── | Editor Specific Errors diff --git a/Carter Games/Audio Manager/Code/Runtime/Systems/Error Handling & Logs/AudioManagerErrorMessages.cs b/Carter Games/Audio Manager/Code/Runtime/Systems/Error Handling & Logs/AudioManagerErrorMessages.cs index 80034b9..702c4c0 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Systems/Error Handling & Logs/AudioManagerErrorMessages.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Systems/Error Handling & Logs/AudioManagerErrorMessages.cs @@ -74,8 +74,8 @@ private static readonly Dictionary MessagesLookup $"{AudioManagerErrorCode.StructElementNameAlreadyExists}\nThere was another entry in the struct with the same name." }, { - AudioManagerErrorCode.MusicTrackListNotSet, - $"{AudioManagerErrorCode.MusicTrackListNotSet}\nYou need to set the track list before trying to transition it. Use MusicManager.SetTrackList() to assign it if you are not using MusicManager.Play()" + AudioManagerErrorCode.MusicPlaylistNotSet, + $"{AudioManagerErrorCode.MusicPlaylistNotSet}\nYou need to set the playlist before trying to transition it. Use MusicManager.SetPlaylist() to assign it if you are not using MusicManager.Play()." }, }; diff --git a/Carter Games/Audio Manager/Code/Runtime/Systems/Inspector Players/Music Track Player/InspectorMusicTrackPlayer.cs b/Carter Games/Audio Manager/Code/Runtime/Systems/Inspector Players/Music Track Player/InspectorMusicTrackPlayer.cs index 9e4d790..2ff764f 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Systems/Inspector Players/Music Track Player/InspectorMusicTrackPlayer.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Systems/Inspector Players/Music Track Player/InspectorMusicTrackPlayer.cs @@ -126,7 +126,7 @@ public void Stop() { if (musicPlayer == null) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicPlayerNotInitialized)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicPlayerNotInitialized)); return; } @@ -141,7 +141,7 @@ public void Pause() { if (musicPlayer == null) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicPlayerNotInitialized)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicPlayerNotInitialized)); return; } @@ -156,7 +156,7 @@ public void Resume() { if (musicPlayer == null) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicPlayerNotInitialized)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicPlayerNotInitialized)); return; } @@ -172,7 +172,7 @@ public void ChangeTrack(string key) { if (musicPlayer == null) { - AmLog.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicPlayerNotInitialized)); + AmDebugLogger.Error(AudioManagerErrorMessages.GetMessage(AudioManagerErrorCode.MusicPlayerNotInitialized)); return; } diff --git a/Carter Games/Audio Manager/Code/Runtime/Systems/Pooling/ObjectPool.cs b/Carter Games/Audio Manager/Code/Runtime/Systems/Pooling/ObjectPool.cs index a86d474..65fc836 100644 --- a/Carter Games/Audio Manager/Code/Runtime/Systems/Pooling/ObjectPool.cs +++ b/Carter Games/Audio Manager/Code/Runtime/Systems/Pooling/ObjectPool.cs @@ -145,7 +145,7 @@ public T Assign() if (!ShouldExpand) { - AmLog.Normal("No free member objects to return."); + AmDebugLogger.Normal("No free member objects to return."); return default; } diff --git a/Carter Games/Audio Manager/Code/Runtime/Utility/Generated Classes.meta b/Carter Games/Audio Manager/Code/Runtime/Utility/Generated Classes.meta deleted file mode 100644 index 105d429..0000000 --- a/Carter Games/Audio Manager/Code/Runtime/Utility/Generated Classes.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 79dfa3803e7a43039f5c6fab90d7555e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Carter Games/Audio Manager/Data.meta b/Carter Games/Audio Manager/Data.meta new file mode 100644 index 0000000..2f84133 --- /dev/null +++ b/Carter Games/Audio Manager/Data.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 06f75160636a4b5e8765a68071f0b761 +timeCreated: 1682930223 \ No newline at end of file