Skip to main content
Notice removed Draw attention by Saturn
Bounty Ended with Philipp's answer chosen by Saturn
Notice added Draw attention by Saturn
Bounty Started worth 50 reputation by Saturn
added 86 characters in body
Source Link
Saturn
  • 1.8k
  • 12
  • 39
  • 68

I've been dabbling with Addressables for a while, and overall everything works fine with AssetReferenceT - I can load Textures and just about anything else, but for some reason I cannot seem to get to load Sprite or Texture2D.

Given an AssetReferenceT<Sprite>, or AssetReferenceSprite, assigned to a Single Sprite that is addressable...

var icon = await reference.LoadAssetAsync<Sprite>();

And similar variations will just give me some form of:

Exception: Unable to load asset of type UnityEngine.Sprite from location Assets/triangle 1.png[09adbfd8aff3bbd43890e8aabd7f13ec].

I'm rather confused as this is such a simple thing to do - I already do it with all other asset types but I just can't make it work for Sprite and Texture2D. The closest I was able to achieve was using AssetReferenceT<Texture> and then creating the Sprite at runtime, but that doesn't seem ideal.

Addressables 2.1.0, Unity 6000.0.9f1 (but I've been running into this for a long time).

The reference is set without warnings:

enter image description here

enter image description here

I've been dabbling with Addressables for a while, and overall everything works fine with AssetReferenceT - I can load Textures and just about anything else, but for some reason I cannot seem to get to load Sprite or Texture2D.

Given an AssetReferenceT<Sprite>, or AssetReferenceSprite, assigned to a Single Sprite that is addressable...

var icon = await reference.LoadAssetAsync<Sprite>();

And similar variations will just give me some form of:

Exception: Unable to load asset of type UnityEngine.Sprite from location Assets/triangle 1.png[09adbfd8aff3bbd43890e8aabd7f13ec].

I'm rather confused as this is such a simple thing to do - I already do it with all other asset types but I just can't make it work for Sprite and Texture2D. The closest I was able to achieve was using AssetReferenceT<Texture> and then creating the Sprite at runtime, but that doesn't seem ideal.

Addressables 2.1.0, Unity 6000.0.9f1 (but I've been running into this for a long time).

The reference is set without warnings:

enter image description here

I've been dabbling with Addressables for a while, and overall everything works fine with AssetReferenceT - I can load Textures and just about anything else, but for some reason I cannot seem to get to load Sprite or Texture2D.

Given an AssetReferenceT<Sprite>, or AssetReferenceSprite, assigned to a Single Sprite that is addressable...

var icon = await reference.LoadAssetAsync<Sprite>();

And similar variations will just give me some form of:

Exception: Unable to load asset of type UnityEngine.Sprite from location Assets/triangle 1.png[09adbfd8aff3bbd43890e8aabd7f13ec].

I'm rather confused as this is such a simple thing to do - I already do it with all other asset types but I just can't make it work for Sprite and Texture2D. The closest I was able to achieve was using AssetReferenceT<Texture> and then creating the Sprite at runtime, but that doesn't seem ideal.

Addressables 2.1.0, Unity 6000.0.9f1 (but I've been running into this for a long time).

The reference is set without warnings:

enter image description here

enter image description here

Source Link
Saturn
  • 1.8k
  • 12
  • 39
  • 68

Load a Single Sprite using Addressables

I've been dabbling with Addressables for a while, and overall everything works fine with AssetReferenceT - I can load Textures and just about anything else, but for some reason I cannot seem to get to load Sprite or Texture2D.

Given an AssetReferenceT<Sprite>, or AssetReferenceSprite, assigned to a Single Sprite that is addressable...

var icon = await reference.LoadAssetAsync<Sprite>();

And similar variations will just give me some form of:

Exception: Unable to load asset of type UnityEngine.Sprite from location Assets/triangle 1.png[09adbfd8aff3bbd43890e8aabd7f13ec].

I'm rather confused as this is such a simple thing to do - I already do it with all other asset types but I just can't make it work for Sprite and Texture2D. The closest I was able to achieve was using AssetReferenceT<Texture> and then creating the Sprite at runtime, but that doesn't seem ideal.

Addressables 2.1.0, Unity 6000.0.9f1 (but I've been running into this for a long time).

The reference is set without warnings:

enter image description here