-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logic connecting AssetEditors to ExportSettings
Also refactor BaseAssetEditor.GetAssetPaths usage to be more generic
- Loading branch information
Showing
8 changed files
with
96 additions
and
49 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
42 changes: 42 additions & 0 deletions
42
Disunity/Disunity.Editor/Editors/BaseSettingsAssetEditor.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,42 @@ | ||
using Disunity.Editor.Pickers; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Disunity.Editor.Editors { | ||
internal abstract class BaseSettingsAssetEditor<T> : BaseAssetEditor where T : Object { | ||
|
||
protected readonly ExportSettings _settings; | ||
|
||
protected abstract IEnumerable<T> Setting { get; set; } | ||
|
||
public BaseSettingsAssetEditor(EditorWindow window, ExportSettings settings) : base(window) { | ||
_settings = settings; | ||
} | ||
|
||
protected override void HandleAddition(AssetEntry addition) { | ||
base.HandleAddition(addition); | ||
if (Setting.All(asmDef => AssetDatabase.GetAssetPath(asmDef) != addition.Value)) { | ||
Setting = | ||
Enumerable.Concat( | ||
Setting, | ||
Enumerable.Repeat(AssetDatabase.LoadAssetAtPath<T>(addition.Value), 1)) | ||
.ToArray(); | ||
} | ||
} | ||
|
||
protected override void HandleSubtraction(AssetEntry subtraction) { | ||
base.HandleSubtraction(subtraction); | ||
Setting = Setting | ||
.Where(asmDef => AssetDatabase.GetAssetPath(asmDef) != subtraction.Value) | ||
.ToArray(); | ||
} | ||
public override string[] GetAssetPaths() { | ||
return AssetDatabase | ||
.FindAssets($"t:{typeof(T).Name}") | ||
.Select(AssetDatabase.GUIDToAssetPath) | ||
.ToArray(); | ||
} | ||
} | ||
} |
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
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
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