Doesn't save item icon
Closed this issue · 4 comments
Nelson, hello.
I'm trying to save an item icon from the server side, and it throws the following error:
Releasing render texture that is set to be RenderTexture.active!
Arguments when starting the server: -batchmode -AlwaysLoadItemPrefab
Plugin code:
ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, 363);
var ready = new ItemIconReady((icon) =>
{
File.WriteAllBytes($"Vendors/{itemAsset.itemName}.png", ImageConversion.EncodeToPNG(icon));
});
ItemTool.getIcon(itemAsset.id, 0, itemAsset.quality, itemAsset.getState(), itemAsset, null, string.Empty, string.Empty, itemAsset.size_x * 50, itemAsset.size_y * 50, false, true, ready);
Server is running in headless mode where rendering is not supported
Server is running in headless mode where rendering is not supported
Any ideas on how to create item icons from the server side?
@SDGNelson A very useful feature for developers, I noticed that many people are discussing it in the topics. There are no problems with displaying items that do not have a state. But with weapons, on which various modules can be installed...
Its just not possible to render stuff on the server as it doesn't have a GPU. An alternative would be something like this #3010 or #4228 for UIs.
Also there are some repos that have a lot of item icons in them that could be used by an API but won't work with all mods or custom states like you wanted.
https://github.com/SilksPlugins/UnturnedImages .
If you want this for temporary reasons just make a client-side module instead of server-side and it will work fine (ive done this in the past).
Thanks GazziFX and DanielWillett! These answers are helpful and accurate. :)