(WIP) Make adressables great again #1494#1500
Open
rohitkulkarni97 wants to merge 238 commits intoRE-SS3D:developfrom
Open
(WIP) Make adressables great again #1494#1500rohitkulkarni97 wants to merge 238 commits intoRE-SS3D:developfrom
rohitkulkarni97 wants to merge 238 commits intoRE-SS3D:developfrom
Conversation
…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
…agement consistency
…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
…proved readability
…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
…agement consistency
NetworkObjectTracker is a MonoBehaviour that carries the asset GUID so dependency prefabs loaded implicitly by Addressables can be discovered at runtime. The Generate() pass now stamps the tracker onto every prefab, fixing GUID mismatches from prefab moves or copies.
When GetObject encounters a null prefab slot, it scans all loaded NetworkObjectTracker instances to find dependency prefabs that were loaded by Addressables but never received an OnLoaded event, and registers them into their deterministic FishNet runtime slots.
Verify that the generator adds NetworkObjectTracker with the correct GUID and that re-running the generator does not duplicate the component.
Remove StartAssetEditing/StopAssetEditing batching so base prefab imports complete before variants are processed, making inherited trackers visible to TryGetComponent. Add DisallowMultipleComponent as a safety net against duplicate trackers.
Move OnLoaded invocation out of the awaited path so it fires exactly once per handle regardless of how many callers await the same GUID. The callback captures itself to unsubscribe on first invocation.
Variant prefabs that were reverted from the initial generation now carry the tracker GUID override produced by the fixed generator.
InstanceLifetimeTracker has DisallowMultipleComponent, so a second AddComponent call would fail and the subsequent Initialize would throw. Use TryGetComponent first, and re-initialize if the tracker's key is stale (e.g. from prefab variants inheriting the base's tracker).
Scanning in GetObject was too late — the server reads PrefabId from a spawned instance before the client ever calls GetObject, so dependency prefabs that weren't registered sent garbage IDs over the network. Scanning on HandleAssetLoaded ensures every loaded prefab (root or implicit addressable dependency) has its FishNet PrefabId set before any spawn reads it. A per-tracker Initialized flag skips already processed instances, and the scan no longer short-circuits on slot occupancy so multiple in-memory copies of the same prefab (e.g. a direct scene reference plus the addressable-loaded copy) each get their PrefabId set.
Scenes can carry directly referenced NetworkObject prefabs (including addressable ones resolved via serialized references) that never fire HandleAssetLoaded. Scan once in OnEnable to cover the currently loaded scene and subscribe to SceneManager.sceneLoaded for future scenes. Add TryRecoverSlot so GetObject can re-point an empty slot at any surviving in-memory copy of the prefab — covers the case where a transitive addressable dependency was released without firing HandleAssetUnloaded, but another copy (e.g. scene reference) is still alive. Moves the tracker Initialized flag into InitializePrefab so every registration path keeps FishNet and tracker state in sync.
…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".
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR checklist
Pictures/Videos
Testing
Networking checklist
Changes
Related issues/PRs