Lock hot bar item definition types?

I only have a few items in my game, and I'd like to always show them in the hot bar, without the player needing to set them or able to change them. Is this possible?

Thank you,
Andrew
 
It is possible with a script that could add those items at the start of the game.

Code:
//This is about to be deprecated
itemHotbar.AssignItemToSlot( itemInfo, slotIndex );
//Instead use this.  
hotbarItemViewSlotContainer.AddItem( itemInfo, slotIndex );

Would the player always have these items in their inventory? The default hotbar scans the inventory to make sure the player has those items. If not it grays out the item to show there aren't any left to use.

There are a few tricks you could use to always have the items, such as creating an Item Collection which you hide in all the UIs and could store your hotbar items.

Just a heads up that I will be refactoring the Hotbar component such that it inherits the Item View Slots Container instead of sitting next to one. This will allow me more control over how the hotbar behaves, which I need to fix a bug I found on Friday.
 
I'm getting back to this, and just wanted to check on the latest way to accomplish it. It sounds like you were making some updates back in November.

My player won't always have the items, but the "greying out" you describe is ideal. I only have a few items in my game (e.g. butterfly, lantern) and would like to just always have them set in the hotbar as #1, #2, #3, etc. This game is for non-gamers, and it should be a lot simpler than expecting them to navigate to the inventory.

As an aside, is it possible to set the number of hotbar slots? Right now I only need 2, but may expand it in the future.
 
Yes of course. Simply spawn the number of slots you want.
Using the UI Designer Editor there should be a button to add/remove slots in edit mode.
For now I do not think we have the functionality to add/remove slots at runtime
 
In case it helps anyone else:

Code:
var player = GameObject.FindGameObjectWithTag("Player");
var inventory = player.GetComponent<Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory>();
var itemDef = InventorySystemManager.GetItemDefinition("Butterfly");
var itemInfo = inventory.GetItemInfo(itemDef);
this.ItemHotbar.AddItem(itemInfo.Value, 0);
 
In case it helps anyone else:

Code:
var player = GameObject.FindGameObjectWithTag("Player");
var inventory = player.GetComponent<Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory>();
var itemDef = InventorySystemManager.GetItemDefinition("Butterfly");
var itemInfo = inventory.GetItemInfo(itemDef);
this.ItemHotbar.AddItem(itemInfo.Value, 0);
This helped a lot actually! I was banging my head against the wall because I missed the .Value in itemInfo.Value.
 
Top