Skip to content

Make adressables great again #1494 - #1500

Open
rohitkulkarni97 wants to merge 252 commits into
RE-SS3D:developfrom
rohitkulkarni97:Issues/Make-Adressables-great-again-#1494
Open

rohitkulkarni97 wants to merge 252 commits into
RE-SS3D:developfrom
rohitkulkarni97:Issues/Make-Adressables-great-again-#1494

Conversation

@rohitkulkarni97

@rohitkulkarni97 rohitkulkarni97 commented Mar 15, 2026 •

Copy link
Copy Markdown
Contributor

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

Closes #1494

…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
…tepCraftable, and Item to simplify usage of Assets.Get method
@rohitkulkarni97 rohitkulkarni97 changed the title (WIP) Make adressables great again #1494 Make adressables great again #1494 Apr 28, 2026
henkhooft pushed a commit to henkhooft/SS3D that referenced this pull request Jul 22, 2026
Investigated upstream RE-SS3D#1500 ("Make adressables great
again", closes RE-SS3D#1494 excessive memory usage) and this fork's actual
Addressables usage. Confirmed this fork has the same eager-loading
root cause independently of upstream: 21 Addressables groups are
configured but only ever used as editor-time metadata via
AssetDatabase.LoadAssetsFromAssetGroup(), which copies real Object
references into a serialized dictionary. No Addressables.LoadAssetAsync
call exists anywhere in the codebase, so every configured asset is
still hard-referenced into RAM at load time.

Adds 2026-07_addressables-expansion-migration.md scoping a phased
migration to async AssetHandle-style loading (planned, no code yet),
including a concrete plan to retire the MI/Main HUD/Storage Panel
Resources.Load catalogs once migrated. Cross-links it from INDEX.md,
TECH_DEBT.md (new §1.15 - §1.14 was taken by a concurrently-landed
asset-taxonomy effort), and the data-codegen system map.

Split out of the combined addressables+subsystem-bootstrap branch
since the two problems have unrelated root causes; the subsystem
bootstrap work now lives on its own branch/PR.
CopyValuesToBodyPart ran on a bare instantiated prefab, before
NetworkSpawner.Spawn. _bodyLayers is not serialized and is only filled by
AddInitialLayers in OnStartServer, which that spawn triggers, so the copy had
no body layers and the loop body never executed. Every sustained damage was
silently discarded on detach - exactly what the method promises to preserve.

Regression introduced on this branch. develop spawns first and then copies, so
it was never affected there. A part is severed because its bone layer is
destroyed, so a severed limb again reaches the floor carrying roughly half of
its maximum damage.
Async organ spawning made the existing wait unsound. WaitUntil(() => Heart &&
LeftLung && RightLung) is satisfied the instant Instantiate assigns the field,
but the network spawn that follows is deferred behind an await, and it is that
spawn which runs the organ's own OnStartServer and creates its body layers. The
organs were therefore attached into the body before they had any layers.

Add BodyPart.IsInitialized, set once a part's layers exist, and gate both the
torso and the head on it rather than on the field being non-null. IsSpawned is
deliberately not used: it only reports that an ObjectId was assigned, which says
nothing about the part having been built.

No visible symptom on this branch today - nothing reads an organ's layers early
enough to fault. This restores the invariant that a body part is never attached
into a body before it has been built.
# Conflicts:
#	Assets/Content/WorldObjects/Entities/Silicon/EngineeringBorg/EngineeringBorg.prefab
#	Assets/Content/WorldObjects/Structures/Walls/SteelWall.prefab
#	Assets/Content/WorldObjects/Structures/Walls/SteelWallReinforced.prefab

This branch was successfully deployed

1 active deployment
unity_tests — 6074fd66 Deployed Aug 12, 2026 by rohitkulkarni97 via Run tests #1214
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.

Excessive memory usage

1 participant