Is there a built-in way to make a SpriteRenderer that lazily loads a sprite from an AssetReference?

I would like to have a SpriteRenderer in my scene which loads its sprite from an addressable AssetReference. Is there a good way to do this? I considered writing a custom subclass of SpriteRenderer, but it turns out Unity has marked it as sealed :frowning:

Just make your own wrapper class for an addressables AssetReference.

You will need an additional MonoBehaviour that sets the Sprite of the SpriteRenderer.

You can have this as [ExecuteInEditMode] if you want a set sprite in edit mode. Though be sure to remove any reference before saving the scene. (Untested) but you should be able to use Unity - Scripting API: SceneManagement.EditorSceneManager.SceneSavingCallback to wipe the test sprite from the direct reference before saving.

If all you want is to lazy load and have it still build like a direct reference, you can use Unity - Scripting API: LazyLoadReference<T0> to load it outside of Addressables.