Hotbar Active Highlight?

joran

New member
Is there a way to mark an item in the hotbar as active (or N items) (ie special highlight or something) once you click it or press a hotkey (instead of say using the item?)

If there is such a mechanism, is there also a way to retrieve the currently selected item(s)?
 
Unfortunatly right now only one item can be selected at a time.
The ItemHotbar is an "ItemViewSlotContainer" so you can use those functions to select and get the selected slot:

Code:
itemHotbar.SelectSlot(index);

var itemViewslot = itemHotbar.GetSelectedSlot();

The Highlight of the item is shown by the ItemView within the ItemViewSlot which can have a component that swaps the background icon when selected example the "Equipped Select Item View" module.

If you are unable to get the desired result using our ItemHotbar component I would recommend you try creating your own custom ItemViewSlotContainer. This way you'll have a lot more control over your item view slots. You can inspire yourself from the ItemHotbar, InventoryGrid and ItemSlotCollectionView. These are all ItemViewSlotContainers.
 
I suspect "equipped select item view" is exactly what i needed ... are you guys planning on releasing more thorough api docs? Also it would be great if you guys added some more tutorials on setting up an inventory from scratch(theres so much "magic" in the Demo inventory, that its a bit hard to grok), and then walk through setting up hotbars from scratch (you might actually have that) and "equipping" items from scratch, and creating item actions and item behaviours from scratch (and when you should use an item behaviour vs an item action, etc)

Im getting my head around things but i didnt feel like most of the tutorials helped me understand the system and its parts and how they go together ... it was cool and easy to follow... but all I was really doing was parroting the code and actions without really understanding what or why i was doing it ... I think the demo project provides great reference material that i regularly go try and untangle how some bit of it works (and i think im mostly coming to terms with the GUI and using it ... and to an extent item actions, but i feel like the c# code api is not well documented. and there are a distinct lack of tutorials

Ie (how do i get the Item Slot View prefab instance that was triggered Im currently doing


C#:
m_ItemViewSlotsContainer.ItemViewSlots[m_ItemViewSlotIndex].gameObject.transform.GetChild(0).gameObject.GetComponent<T>()

which seems more complicated, than it should be.

One last question is is there a built in way to configure hotbars to be able to drag an item from the hotbar and drop the item in screen space outside any inventories and have the item be removed from the hotbar?
 
We have video tutorials which explain most of the things you mentioned, combined with the online documentation you should have everything you need to know

As for API docs, the code is fully documented so going through the classes and public functions using your IDE, using the autocomplete and reading the comments and description of the relevant classes/function should give you everything you need to know. We don't plan to copy paste all that information in the online documentation. All the API that is "Essential" are given as "code examples" in the documentation (for example the sections Item, Attribute, Item View Slot Container, etc...)

We continuously update the documentation with more information when users say something in particular is not clear. So if you have a section in mind that needs to be improved let us know.

If you read the documentation carefully you would have seen that the API question you asked is actually part of the code examples in the documentation page:
Code:
// Get the item in a slot.
var itemViewSlot = m_ItemViewSlotContainer.GetItemViewSlot(slotIndex);
var itemView = m_ItemViewSlotContainer.GetItemView(slotIndex);
var itemInfo = m_ItemViewSlotContainer.GetItemAt(slotIndex);
But even if it was not your IDE should have been able to autocomplete this if you had tried different keywords ("Item", "Get", "Slot", "View", etc...).

If you aren't using an IDE, like Visual Studio (Not Code) or Rider, I highly recommend you do it'll save you hours of work each week.


As for your last question Currently there is no easy way to drag and drop items in screen space. Some people have added a giant Item View Slot to cover the screen and used custom code to listen to the drop event.
That feature is in my TODO list in mid-priority so I'll try to add it either in the next update or the one after.

I hope that helps :)
 
Good new Joran, I had some time today to work on the feature you requested. It's just a proof of concept right now but it will make it for the next update. (the quality of the gif is horrible but it gets the point across)

ItemDropInScene_lowres_13_01_2021.gif

The cool thing about this solution is that the DropHandler is calling an ItemAction, which means a lot of things are going to be possible.

I hope it gets you excited for the release coming up :)
 
this is great thanks :) and yeah I am using VScode as my IDE (which i constantly have to manually edit the Assembly-CSharp.proj to include all of the files from the Opsive.*.csproj .... I will install rider tonight and see if that solves some of my issues (i tend to really like jetbrains products)
 
+100000 using Rider makes a world of difference (I generally dislike VS IDE products ... I didnt know about Rider before now(or maybe i knew somewhere in the back of my brain))
 
Top