Accessing Materials(items) from your inventory to build prefabs during runtime

WillyG99

Member
Hi!

So if i have a building system, where i open a menu, select my building prefab, and as i try to place it, i want it to check if i have the required materials in my inventory. How can i check something like that? Seems basic and might be obvious but a little pointer would help out alot
 
I remember someone doing exactly this in the very early days of UIS using Easy Build System.
Unfortunatly I can't find it anymore.

What you'll want is a custom ItemAction to start the building preview with the selected item.
Check this page:
You might find this useful too

Then you'll want to check how much of an item you having in your inventory/itemCollection. This can be done with
Code:
hasItem = m_Inventory.HasItem( (1, itemDefinition) );
You can find more example on this page
and this one

You can also check the source code for those two classes, they are fully documented so you should be able to follow along. There are functions to get the ItemInfo, get the amount, and much more.
 
Thank you, i will give it a shot when i get back home?

Also fyi i will probably use the Easy Build Sytem, so i just need to check the requirements before placing?
 
Last edited:
Top