- Home /
Generate custom inventory icons at runtime
Hi everyone,
I am currently working on a system that allows the player to customize their gun similar to Escape from Tarkov. Modding the weapon works fine, but I have no clue at how to get proper icons for my inventory. In Escape from Tarkov, the inventory will display the correct weapon icon depending on the installed mods, which makes recognizing loot very easy. Maybe someone knows the correct way to generate icons at runtime with some hidden camera that only renders the weapon to some texture? I watched some youtube videos on that topic but the comments said generating Texture2D at runtime is not something you should do..
Any help is appreciated!
Answer by Joe0321 · yesterday
Pleased to see your issue as I think I have the same problem,I am also confused and in need of light on this same issue. Need help. MGS Login
Hey, I got it a first version working, but have yet to implement or test it in my game. Basic setup is just an empty gameobject with an orthograpic camera inside and this script attached https://pastebin.com/iu7VNL2R I dont know what the performance will be when you create many icons at the same time, but for now its better than nothing. It will instantiate a copy of the target gameobject and check its bounds by adding all meshrenderes. The bounds are used to center the object and to change the camera's orthographic size so any object will fit. Works fine for me, I can add any attachment to any gun and the icon will match the size. For debugging, you can disable destroyCopy to check if it is correctly centered etc. Also make sure to have a specific layermask assigned, so that the camera doesnt render background stuff. I hope this helps!
Your answer
Follow this Question
Related Questions
Drag and Drop icons into slots 1 Answer
Inventory SlotID vs. RectPosition 0 Answers
Brackeys Inventory Package, adding icons to empty slots... 0 Answers
MissingReferenceException Help Please! 0 Answers
Populate inventory with item icons 1 Answer