Hello I want to put a highlight selected inventory item from UI. This is the relevant code:
private void Update()
{
var item = KickStarter.runtimeInventory.SelectedItem;
if (item != null)
{
lastSelectedItem = item;
KickStarter.runtimeInventory.SelectItem(null); //I deselect this to discard dragging mechanic of the AC
HighlightItem(lastSelectedItem);
}
}
private void HighlightItem(InvItem selectedItem)
{
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Welcome to the community, @jigsaw.
In what way do you want to highlight it? With a texture swap?
If you read SelectedInstance instead, you'll get a reference to the selected item's Instance, which has a Tex property you can use to override its texture:
If you can share more context about the situation, I may be able to suggest a more specific approach.
Hi sorry for insufficient information. I want to add a custom sprite (a game object) on selected item. Imagine a frame sprite on inventory item. The problem is I cannot find the position of the selected inventory item (from UI).
When dealing with UI, it's better to attach your script to each Button in the UI prefab, and then compare the "instance" variable with that associated with the Button it's attached to:
Replacing "Inventory" and "Items" with the names of your Inventoy menu, and the InventoryBox element inside it, respectively.
I couldn't make this work with invInstance. I went changing texture way: