Skip to content

Optional Addressables locator support (3.1.0)#25

Open
PaulNonatomic wants to merge 2 commits into
mainfrom
feat/addressable-support
Open

Optional Addressables locator support (3.1.0)#25
PaulNonatomic wants to merge 2 commits into
mainfrom
feat/addressable-support

Conversation

@PaulNonatomic

Copy link
Copy Markdown
Owner

3.1.0 — optional Addressables locator support

Re-implements the addressable-locator idea from the old feat/addressable-servicekit branch, freshly built against current main (3.0) and without the generic base-class split that made the old branch unmergeable.

Added

  • AddressableServiceKitBehaviour — derive from this instead of ServiceKitBehaviour to load the locator through Addressables (via a typed ServiceKitLocatorAssetReference) rather than a direct serialized reference. The locator loads asynchronously before the service registers (so it isn't pulled into every bundle/scene that references it), and the Addressables handle is released on destroy.
  • ServiceKitBehaviour.PrepareLocatorAsync() — a protected virtual hook (default no-op, completes synchronously) run in Awake before registration. The addressable variant overrides it to load the locator; you can override it to source a locator from any async origin. This is the minimal, non-invasive seam that replaces the old branch's ServiceKitBehaviourBase<T> refactor.

Both are additive and non-breaking: the hook's default is a synchronous no-op, so existing behaviours register exactly as before. AddressableServiceKitBehaviour is gated behind SERVICEKIT_ADDRESSABLES (set automatically when the Addressables package is present) and compiles to nothing otherwise.

Validation

Full #if matrix, Unity 6000.3.16f1:

Config EditMode Validates
Default (no UniTask / no Addressables) 115 / 115 + PlayMode 19/19 base hook (Task), addressable file excluded, 3 unresolved Addressables GUID refs harmless
Addressables, no UniTask 116 / 116 addressable Task branch compiles against the real Addressables API
Addressables + UniTask 114 / 114 hook UniTask.CompletedTask path + addressable UniTask branch

Not covered

No automated functional test of the addressable load path — that needs built Addressables content, which isn't practical in batchmode. The validation above is a full compile matrix; the load/register/release logic mirrors the proven prior implementation and uses only stable Addressables APIs (AssetReferenceT, LoadAssetAsync, AsyncOperationHandle, Addressables.Release).

AddressableServiceKitBehaviour loads its ServiceKitLocator via Addressables (a typed
ServiceKitLocatorAssetReference) instead of a direct serialized reference - the locator
isn't pulled into every bundle that references it, and its handle is released on destroy.
Gated behind SERVICEKIT_ADDRESSABLES (set when the Addressables package is present);
compiles to nothing otherwise.

Backed by a new protected virtual ServiceKitBehaviour.PrepareLocatorAsync() hook (default
no-op, completes synchronously) run in Awake before registration, so a subclass can source
its locator asynchronously. Normal behaviours are unaffected.

Validated: default EditMode 115 / PlayMode 19; compiles cleanly with Addressables (Task
path) and with Addressables + UniTask (UniTask path).
- PrepareLocatorAsync hook PlayMode test: proves registration is deferred until an
  async locator source completes, then the service registers and initializes. This
  is the mechanism AddressableServiceKitBehaviour relies on, tested deterministically
  without the Addressables package via a TaskCompletionSource stand-in.
- Sample 12 (Addressable Locator): a runnable example of AddressableServiceKitBehaviour
  plus a setup README, gated behind SERVICEKIT_ADDRESSABLES.

A self-contained automated test of the real Addressables load is impractical in a
package harness (Addressables config is project-level and batchmode init is flaky),
so the sample is the human-verifiable runtime proof.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant