
Originally Posted by
convicted tomatophile
TextureAssets.Item[id] returns an Asset<Texture2D> of that item. If you're unsure of whether the item's asset will be loaded (1.4 uses asynchronous asset loading), request the asset manually with ImmediateLoad instead of AsyncLoad.
how can i display the texture? when using imguics it displays a white square instead of a texture i use
https://******.com/0x0ade/ImGuiCS/bl...GuiXNAState.cs
- - - Updated - - -

Originally Posted by
convicted tomatophile
TextureAssets.Item[id] returns an Asset<Texture2D> of that item. If you're unsure of whether the item's asset will be loaded (1.4 uses asynchronous asset loading), request the asset manually with ImmediateLoad instead of AsyncLoad.
~~And the problem is not even in imgui, the problem is that this method returns Assets, that is, it is not automatically compatible with imgui / xna. The question is how does terraria render such textures?~~
oh i just had to add .value
- - - Updated - - -
i finally fixed my problem
but when i try to display exactly the texture from the terraria i get a white square
as far as I understand, the problem is in imgui or my parameters of the button with a picture, since I made a completely working method for obtaining texture by ID here are the codes
public static Texture2D GetTextureByID(string type, int id, GraphicsDevice graphicsdevice)
{
var tx = new Texture2D(graphicsdevice, 20, 20);
if (type == "item") { tx = Main.instance.Content.Load<Texture2D>("Images\\Ite m_" + id); }
if (type == "npc") { tx = Main.instance.Content.Load<Texture2D>("Images\\NPC _" + id); }
if (type == "projectile") { tx = Main.instance.Content.Load<Texture2D>("Images\\Pro jectile_" + id); }
if (type == "buff") { tx = Main.instance.Content.Load<Texture2D>("Images\\Buf f_" + id); }
return tx;
}
ImGui.ImageButton(ImGuiState.Register(texture), new ImVec2(50, 50), new ImVec2(0, 0), new ImVec2(0, 0), 0, new ImVec4(1, 1, 1, 1), new ImVec4(1, 1, 1, 1));
I FIXED IT!!!!!!!!!