How to load sprites?

Hello everyone,

I have multiple large .png files I want to make as Addressables, but to make the issue more simple, lets assume I only have one large .png file in my project.

I marked that .png file as an Addressable, uploaded it to my remote location, but when I’m trying to load it, I can’t load it as a Sprite but only as a Texture2D.

Is there a way to directly build the Addressable as a Sprite, or is the only option to load the Texture2D and then create a Sprite out of it?

What version of Addressables are you using? I’ve run into a handful of issues with sprites on older versions, including one that was similar to yours, but they’re all resolved on the latest version of the Addressables package.

@dlegare-synapse I have version 1.16.7 installed, but I’m getting this error:

Unable to load asset of type UnityEngine.Sprite from location Assets/MyLocalPathToThePNG/imageName.png

when calling this code

Addressables.LoadAssetAsync<Sprite>(location)

where “location” is the path to the Addressable.

All of the sprite-related issues I know of are fixed in Addressables 1.16, so what you’re running into is probably different than the issue I was thinking of. The only other thing I can suggest double-checking is that you have the texture type set to “Sprite” for your sprite asset:

If you already have that setup, then I’m not sure what would be causing the issue. This kind of sounds like a bug to me, though, since you seem to be doing the right thing. Maybe file a bug report in that case?

I had the same issue, and I found the solution:

8834914--1203397--upload_2023-2-25_18-7-36.png

It’s not enough to set the Texture Type to Sprite, you also have to set the Sprite Mode. Without it, it doesn’t work.

Once you’ve done that, the sprites in the addressable group should look like this:

8834914--1203400--upload_2023-2-25_18-9-9.png

1 Like

:slight_smile: