Class SettingsAssetResolution
Resolve-or-create for a settings asset identified BY ID WITHIN A FOLDER — the shape every creator that authors many assets of one type needs, and the counterpart to ResolveSettingsContext<TSettings>(string), which answers the opposite question: where is the ONE project-wide settings asset?
Replaces the byte-identical private helper WaveCreator, SequencePlayerCreator and
PlayerInputCreator each declared, plus the concrete twins in
InitializationPipelineProfileCreator and LoggingProfileCreator. Those five differed only
in whether the fallback file name arrived as a parameter or as a class constant.
Lives beside SettingsAssetAuthoring rather than beside
Serenity.Global.Infrastructure.Editor.SerenityAssetIdLookup because it needs
EnsureProjectFolderExists(string, ICollection<string>) and
VerifyAssetWasWrittenToDisk(string), and this assembly already depends on
the one those two lookups live in — the reverse would be a cycle. Reaching past
EnsureProjectFolderExists to the EnsureFolder it wraps would drop its
Assets-path-shape guard, which for some callers is the only validation the path gets.
Inherited Members
Namespace: Serenity.StructuredPersistence.Infrastructure.Editor.Authoring
Assembly: Serenity.UnityStructuredPersistence.Infrastructure.Editor.dll
Syntax
public static class SettingsAssetResolution
Methods
ResolveOrCreateByIdInFolder<TSettings>(string, string, string, SerenityAssetCreationTransaction, out bool)
Returns the existing TSettings asset in folderPath (and
its subfolders) whose Id equals id ordinally, so the caller updates it in place;
otherwise creates one named after id — falling back to
fileNameFallback when the Id yields no usable file name — assigns it a fresh
Guid, and hands the path to transaction, which
registers it with Addressables on commit and deletes it on rollback.
The folder is ensured on the create path even when the caller already ensured it. That is not a
redundant write: UnityEditorUtils.ResourceUtils.EnsureFolder returns before touching the
AssetDatabase — and before recording anything for rollback — as soon as
UnityEditor.AssetDatabase.IsValidFolder(System.String) reports the folder exists. Paying that check unconditionally
is what lets one method serve callers that ensure beforehand and callers that do not, instead of two
near-identical overloads encoding nothing but the caller's own statement order.
Declaration
public static TSettings ResolveOrCreateByIdInFolder<TSettings>(string folderPath, string id, string fileNameFallback, SerenityAssetCreationTransaction transaction, out bool createdNew) where TSettings : ScriptableObject, IFoundationSettings
Parameters
| Type | Name | Description |
|---|---|---|
| string | folderPath | |
| string | id | |
| string | fileNameFallback | |
| SerenityAssetCreationTransaction | transaction | |
| bool | createdNew |
Returns
| Type | Description |
|---|---|
| TSettings |
Type Parameters
| Name | Description |
|---|---|
| TSettings |