Hello, I need to add an image to my game UI built with UI toolkit.
I came to know its not directly available by default. From other post I added an image component in my code and added that from project elements to the main panel. But I am unable to set a sprite or source image or background to that image.
How can I assign image? How to add an image?
using UnityEngine.UIElements;
public class MyImage : Image
{
public new class UxmlFactory : UxmlFactory<MyImage, Image.UxmlTraits>{}
public MyImage()
{
}
}
Update: Hey guys, got the fix, its working. I had to set min size. Thanks.