Skip to content

Make adressables great again #1494#1500

Open
rohitkulkarni97 wants to merge 248 commits intoRE-SS3D:developfrom
rohitkulkarni97:Issues/Make-Adressables-great-again-#1494
Open

Make adressables great again #1494#1500
rohitkulkarni97 wants to merge 248 commits intoRE-SS3D:developfrom
rohitkulkarni97:Issues/Make-Adressables-great-again-#1494

Conversation

@rohitkulkarni97
Copy link
Copy Markdown
Contributor

@rohitkulkarni97 rohitkulkarni97 commented Mar 15, 2026

Summary

This PR replaces the legacy static Assets lookup/database bootstrap with a scene-owned, async asset system built around GUIDs, catalogs, backend loaders, and disposable asset handles. The configured content path now routes the main SS3D asset databases through Addressables, while the provider/lifecycle layer keeps loaded assets resident only while handles or spawned instances still reference them.

It also adds the FishNet-side support required for addressable network prefabs: deterministic GUID-based prefab IDs, runtime registration of loaded addressable prefabs, synchronized client preloading before spawn, and late-join gating so clients do not observe addressable objects before the required prefabs are loaded.

PR checklist

  • The game builds properly without errors.
  • No unrelated changes are present.
  • No "trash" files are committed.
  • Relevant code is documented.
  • Update the related GitBook document, or create a new one if needed.

Testing

Automated coverage added/updated:

  • Edit Mode tests for AssetHandle, AssetProvider, AssetLifecycleTracker, InstanceLifetimeTracker, and NetworkObjectsGenerator.
  • Play Mode tests for asset lifecycle/instance lifetime integration.
  • Asset audit tests for catalog/database inclusion, non-null database GUIDs, and prefab stamping validation.
  • FakeAssetBackend and test assembly access for exercising the internal asset loading flow.

Manual validation still needed:

  • Full Unity build.
  • Host, server, and client smoke tests for item spawn, crafting, tile placement/loading, role loadout spawn, audio playback, and interaction icons.
  • Network spawn paths for addressable prefabs, including late-joining clients.

Networking checklist

  • Works from host in host mode.
  • Works from server in server mode.
  • Works on server in client mode.
  • Works and is synchronized across different clients.
  • Is persistent.

Changes

Asset System

  • Added AssetSubSystem as the startup-owned composition root for asset catalogs, backend initialization, database lookup, load/unload event relays, and the network preload barrier.
  • Added AssetRequest<T> and AssetHandle<T> as the new async loading API. Handles are ref-counted and disposable; helper guards can tie handle lifetime to Unity objects.
  • Added AssetProvider, AssetLifecycleTracker, and InstanceLifetimeTracker to dedupe concurrent loads, track handles and instantiated prefab copies, and unload assets when the last reference is released.
  • Added backend abstraction with IAssetBackend, AddressablesBackend, ResourcesBackend, and AssetBackendType.
  • Removed the old static Assets lookup flow and the separate AssetsInitializationTrigger.

Catalogs And Databases

  • Reworked asset databases into backend-aware AssetCatalog/AssetDatabase assets.
  • Added an AddressablesCatalog containing the seven configured databases: CraftingRecipes, InteractionIcons, Items, Materials, ParticlesEffects, Sounds, and WorldSpaceUI.
  • Moved database assets under Assets/Content/Data/AssetSystem/Databases.
  • Simplified ObjectAssetReference so references store the asset GUID only, rather than GUID plus database ID.
  • Updated editor inspectors, database code generation, and object reference generation to work from catalog/database GUIDs and to stamp prefabs during generation.

Networked Addressables

  • Added NetworkBarrier and PreloadCondition to coordinate loading addressable prefabs across server and clients.
  • Added NetworkSpawner overloads for spawning by ObjectAssetReference, GUID, GameObject, NetworkObject, or NetworkBehaviour while ensuring clients are ready before FishNet spawns.
  • Replaced FishNet's direct prefab collection flow with a generated NetworkObjects asset keyed by deterministic GUID order.
  • Added NetworkObjectsGenerator, generator settings, and NetworkObjectTracker so network prefabs can be discovered, assigned stable FishNet prefab IDs, and registered when loaded through Addressables.
  • Added the NetworkBarrier prefab, wired it into the boot scene through AssetSubSystem, and configured the generated NetworkObjects asset path.

Content Migration

  • Generated 138 icon textures and metadata under Assets/Art/Generated/Icons.
  • Migrated 138 tile/resource data assets to GUID-based prefab/icon references.
  • Updated 198 world object prefabs plus relevant FishNet demo/system prefabs with asset identifiers, instance lifetime trackers, and network object trackers.
  • Added/updated AssetDatabaseSettings, AddressablesCatalog, NetworkObjects.asset, PreloadCondition.asset, and NetworkObjectsGeneratorSettings.asset.
  • Updated GenericObjectSo editor/preprocessor support and stopped generating runtime preview icons in TileResourceLoader; resources now use stored icons with a missing-icon fallback.

Gameplay Migration

  • Migrated item spawning, inventory/container interactions, role loadouts, crafting, tile map placement/loading, construction holograms, audio playback, combat hit effects, body-part effects, furniture/locker/vendor/nuke interactions, boombox/noisy collision audio, and console item spawning to use AssetRequest/AssetHandle and the async network spawning path.
  • Converted direct InstanceFinder.ServerManager.Spawn(...) call sites that depend on database assets to NetworkSpawner.SpawnAsync(...).
  • Updated interaction icons and world-space UI loading to hold/release asset handles instead of repeatedly calling the old static database lookup.

Related Issues/PRs

Related: #1494

…eters in asset creation methods, and removing DatabaseAsset.cs usage.
….Get method instead of DatabaseAsset's Prefab property, Create, Get<T>() & CreateAs<T>(...) functions, and different implicit operators.
…Creator and DatabaseScriptWriter for consistency in asset management workflow.
…, and Item to use Assets.Get method for improved consistency and clarity
…to use Assets.Get method for improved consistency
…and other places to streamline asset retrieval
…tepCraftable, and Item to simplify usage of Assets.Get method
…nce to streamline addressable asset handling and improve code clarity
…nstructionHologramManager to utilize WorldObjectAssetReference for improved asset retrieval
…bjectsSO prefabs to enhance asset management
…eferences throughout the codebase for consistency
…AssetReference, and implement IEqualityComparer for improved comparison
…lementation and simplifying equality and hash code methods
…eters in asset creation methods, and removing DatabaseAsset.cs usage.
….Get method instead of DatabaseAsset's Prefab property, Create, Get<T>() & CreateAs<T>(...) functions, and different implicit operators.
…Creator and DatabaseScriptWriter for consistency in asset management workflow.
…, and Item to use Assets.Get method for improved consistency and clarity
…to use Assets.Get method for improved consistency
…and other places to streamline asset retrieval
…leObject

Converts the IAssetDatabase interface into an abstract ScriptableObject base
class so database instances can be assigned to serialized fields in the
inspector. DatabaseID moves to the base, and AssetGuids is exposed as an
abstract IReadOnlyCollection<string> property so backends can back it with
their own storage (List, HashSet, Dictionary.Keys, etc.) without
double-serializing the GUID set.

- Rename IAssetDatabase.cs to AssetDatabase.cs (preserves the meta GUID).
- AddressablesDatabase inherits from AssetDatabase and overrides AssetGuids
  and ResolveKey.
- Move the code-gen helper (GenerateDatabaseCode, path constants) to an
  AssetDatabase.Editor.cs partial so every database type inherits it.
- Alias UnityEditor.AssetDatabase as UnityAssetDatabase in files that now
  see the new class in scope, to resolve the name collision.
- Widen AssetSubSystem._databasesById and GetDatabase to AssetDatabase, and
  materialize AssetGuids in CraftingSubSystem since IReadOnlyCollection has
  no indexer.
… backend factory

Catalogs now own their databases (serialized List<AssetDatabase>) and produce
their own backend via an abstract factory method, so AssetSubSystem no longer
hardcodes which backend or catalog to instantiate. Adding a new backend means
adding a catalog + backend pair, with no AssetSubSystem changes.

- Rename IAssetCatalog.cs to AssetCatalog.cs (preserves the meta GUID).
- AddressablesCatalog becomes a ScriptableObject with a [CreateAssetMenu],
  overriding BackendType and CreateBackend. Runtime Initialize/Reset are
  gone — the serialized _databases list and the base's Has/ResolveKey
  implementations take their place.
- AssetDatabaseSettings gains List<AssetCatalog> IncludedCatalogs alongside
  the existing IncludedAssetDatabases (which still drives code-gen).
- AssetSubSystem.InitializeInternalAsync discovers catalogs from settings,
  calls CreateBackend once per distinct BackendType, and registers each
  catalog's databases in a single pass.
Unity re-saved all eight databases after the AssetDatabase refactor: the
removed DatabaseName field is dropped, and the AssetGuids public field is
renamed to the private backing field _assetGuids. GUID lists are preserved.
…ings

Wires the new catalog system at runtime: a single AddressablesCatalog asset
groups the eight existing AddressablesDatabase assets and is registered in
AssetDatabaseSettings.IncludedCatalogs, which AssetSubSystem now reads on
init. Confirmed in Play mode with "7 asset databases initialized".
@rohitkulkarni97 rohitkulkarni97 changed the title (WIP) Make adressables great again #1494 Make adressables great again #1494 Apr 28, 2026
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