Skip to content

Commit

Permalink
🔩 3.0.7 Released -> Merge pull request #6 from CarterGames/release/3.0.7
Browse files Browse the repository at this point in the history
📦 3.0.7 Release
  • Loading branch information
JonathanMCarter authored Jun 9, 2024
2 parents 4c81cb4 + 447f62c commit 2703b17
Show file tree
Hide file tree
Showing 45 changed files with 1,491 additions and 544 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ private static void WindowInit()
_ => ShownTab
};

if (UtilEditor.Library.LibraryTotal <= 0)
{
AudioScanner.ScanForAudio(false);
}
// if (UtilEditor.Library.LibraryTotal <= 0)
// {
// AudioScanner.ScanForAudio(false);
// }

libraryTab.Initialize();
groupsTab.Initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ private static SerializedProperty SelectedProperty

return selectedPropertyCache;
}
set
{
selectedPropertyCache = value;
SelectedPropertyKey = value.Fpr("key").stringValue;
}
}


public static string SelectedPropertyKey
{
get => SessionState.GetString("library-key", string.Empty);
set => SessionState.SetString("library-key", value);
}


Expand Down Expand Up @@ -183,23 +195,27 @@ protected override void OnLeftGUI()
{
if (UtilEditor.LibraryObject.Fp("library").Fpr("list").GetIndex(i) == null) continue;

if (SelectedProperty != null)
if (UtilEditor.LibraryObject.Fp("library").Fpr("list").GetIndex(i).Fpr("key").stringValue == (SelectedPropertyKey))
{
if (SelectedProperty.Fpr("value").Fpr("key").stringValue.Equals(UtilEditor.LibraryObject.Fp("library").Fpr("list").GetIndex(i).Fpr("value").Fpr("key").stringValue))
{
GUI.backgroundColor = UtilEditor.Grey;
}
else
if (SelectedProperty != null)
{
GUI.backgroundColor = Color.white;
if (SelectedProperty.Fpr("value").Fpr("key").stringValue.Equals(UtilEditor.LibraryObject
.Fp("library").Fpr("list").GetIndex(i).Fpr("value").Fpr("key").stringValue))
{
GUI.backgroundColor = UtilEditor.Grey;
}
else
{
GUI.backgroundColor = Color.white;
}
}
}

if (GUILayout.Button(UtilEditor.LibraryObject.Fp("library").Fpr("list").GetIndex(i).Fpr("value").Fpr("key").stringValue))
{
PerUserSettings.LastLibraryIndexShown = i;

selectedPropertyCache = UtilEditor.LibraryObject.Fp("library").Fpr("list")
SelectedProperty = UtilEditor.LibraryObject.Fp("library").Fpr("list")
.GetIndex(PerUserSettings.LastLibraryIndexShown);
}

Expand Down Expand Up @@ -229,7 +245,7 @@ protected override void OnRightGUI()

if (!CanUpdate) return;

if (SelectedProperty == null) return;
if (SelectedProperty == null || !UtilEditor.Library.LibraryLookup.ContainsKey(SelectedPropertyKey)) return;
DrawLibraryRow(SelectedProperty);
}

Expand Down Expand Up @@ -294,7 +310,7 @@ private static void DrawLibraryRow(SerializedProperty prop)

if (prop.Fpr("value").Fpr("value").objectReferenceValue == null)
{
AudioRemover.RemoveNullLibraryEntries();
// AudioRemover.RemoveNullLibraryEntries();
selectedPropertyCache = null;
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* 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;

namespace CarterGames.Assets.AudioManager.Editor
{
public class AssetFileChangeHandler : AssetPostprocessor
{
/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Fields
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */

private static readonly string AssetFileChangeKey = $"{FileEditorUtil.AssetName}_Session_EditorFileChange";

/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Properties
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */

/// <summary>
/// Gets if the logic has run since the last editor trigger for it.
/// </summary>
public static bool HasProcessed
{
get => SessionState.GetBool(AssetFileChangeKey, false);
private set => SessionState.SetBool(AssetFileChangeKey, value);
}

/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Events
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */

public static readonly Evt ChangesDetected = new Evt();


public override int GetPostprocessOrder() => 100;


private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets,
string[] movedFromAssetPaths)
{
if (importedAssets.Length <= 0 && deletedAssets.Length <= 0 &&
movedAssets.Length <= 0 && movedFromAssetPaths.Length <= 0) return;

HasProcessed = false;

if (EditorApplication.isCompiling || EditorApplication.isUpdating)
{
EditorApplication.delayCall -= CallListeners;
EditorApplication.delayCall += CallListeners;
return;
}

EditorApplication.delayCall -= CallListeners;
EditorApplication.delayCall += CallListeners;
}


/// <summary>
/// Updates all the listeners when called.
/// </summary>
private static async void CallListeners()
{
if (HasProcessed) return;

var fileChangeClasses = InterfaceHelper.GetAllInterfacesInstancesOfType<IAssetEditorFileChanges>();

if (fileChangeClasses.Length > 0)
{
foreach (var init in fileChangeClasses)
{
init.OnEditorFileChanges();
await Task.Yield();
}
}

ChangesDetected.Raise();
HasProcessed = true;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ namespace CarterGames.Assets.AudioManager.Editor
/// </summary>
public static class AssetReloadHandler
{
/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Fields
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */

private static readonly string AssetReloadKey = $"{FileEditorUtil.AssetName}_Session_EditorReload";

/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Properties
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */

/// <summary>
/// Gets if the logic has run since the last editor trigger for it.
/// </summary>
public static bool HasProcessed
{
get => SessionState.GetBool(AssetReloadKey, false);
private set => SessionState.SetBool(AssetReloadKey, value);
}

/* ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
| Events
───────────────────────────────────────────────────────────────────────────────────────────────────────────── */
Expand All @@ -52,6 +71,8 @@ public static class AssetReloadHandler
[DidReloadScripts]
private static void FireReloadCalls()
{
HasProcessed = false;

if (EditorApplication.isCompiling || EditorApplication.isUpdating)
{
EditorApplication.delayCall -= CallListeners;
Expand Down Expand Up @@ -79,8 +100,15 @@ private static async void CallListeners()
await Task.Yield();
}
}


OnReloadProcessed();
}


private static void OnReloadProcessed()
{
Reloaded.Raise();
HasProcessed = true;
}
}
}
Original file line number Diff line number Diff line change
@@ -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 IAssetEditorFileChanges
{
void OnEditorFileChanges();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2703b17

Please sign in to comment.