-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔩 3.0.7 Released -> Merge pull request #6 from CarterGames/release/3.0.7
📦 3.0.7 Release
- Loading branch information
Showing
45 changed files
with
1,491 additions
and
544 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
Carter Games/Audio Manager/Code/Editor/Systems/Initialization/AssetFileChangeHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...tor/Systems/Scanning/AudioRemover.cs.meta → ...ialization/AssetFileChangeHandler.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Carter Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorFileChanges.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...er Games/Audio Manager/Code/Editor/Systems/Initialization/IAssetEditorFileChanges.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.