So I have a scriptable object that holds a public Image variable. And I want to drag an image to the inspector, but I'm not able to get it to work. I have changed the Texture Type to Sprite (2D and UI). I have tried to find people with similar problems but the only answer I can find is to change the Texture Type to sprite. And I need the Texture Type to be used for UI for ex Player HUD that shows cooldown on abilities.
Picture of Image Inspector
Picture of Scriptable object inspector
Image
is a class inherited from UnityEngine.UI namespace. And to be shown requires a Canvas component.
You can create a prefab with an Image that contains your sprite in order to add to your scriptable object, then use abiltyIcon.sprite
in order to recieve the original sprite when needed.
If you don't want to create a prefab then the solution would be using Sprite
class as mentioned.
Just by doing the reverse path I've mentioned early. Instead of having an Image
with a Sprite
you would have a Sprite
and add it to an empty Image
on the code.
Considering you are using a scriptable object, check if this solution isn't better than the first one.