Some questions about declaring asset/prefab references for SubScenes

I have been trying to wrap my head around the asset referencing system for a long time but I keep getting confused about the consequences of using the different functions so I thought I’d finally ask to get some clarity. I basically have these questions about each function (below).

  • Which functions cause the referenced asset to become added to the resulting AssetBundle for the SubScene?
  • Which functions cause the referenced asset to trigger reserialization of SubScenes when the asset is modified in the editor?
  • Are there any other major differences that I should be aware of?

The functions that I’m aware of are:

  • conversionSystem.DeclareReferencedPrefab
  • conversionSystem.DeclareReferencedAsset
  • conversionSystem.DeclareDependency
  • conversionSystem.DeclareAssetDependency

(I’m aware that the DeclareReferenced-functions trigger the asset to actually be converted as an Entity in contrast to the DeclareDependency-functions)

What I’m trying to achieve
I have a whole bunch of assets that I don’t want bundled with my subscenes but that are used as source data for the conversion step. I’m trying to make sure that modifications to these assets will trigger a reconversion of the SubScene while in the editor, but they should also not be stored in the serialized subscene.

An example would be:

  • A ScriptableObject that holds some kind of settings.
  • A Prefab that holds a reference to the ScriptableObject.
  • During conversion, the Prefab is converted and pulls data from the ScriptableObject.

What I want:

  • When the ScriptableObject is modified, I want the SubScene to be reserialized.
  • When building, I don’t want the ScriptableObject to exist at all post conversion. It should not be added to the Asset Bundles.




TL;DR: if they do what they say, then what you want is DeclareAssetDependency.

1 Like