Hello,
I have an Inventory menu whose source is Adventure Creator.
Following the tutorial, I set up a New Item window that opens when an item is picked up or examined (I checked "Can drop an item onto itself to examine it").
I also checked "Drag and drop inventory interface".
I can combine two items to create a new one by dragging them into my inventory. The newly created item appears in the New Item window.
What I would like is for this combination to happen when an item is dragged into the New Item window. How can I do this?
Im using AC 1.85.5, Win. Unity 6000.3.9f1
Thank you.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
As in, you'd like the item icon inside the New Item window to act like a regular Inventory item when dropping other items onto it?
The tutorial involves creating a Graphic element that displays the newly-added Item's texture - it's not an InventoryBox element that allows for regular Inventory interactions.
To have it react to dropping items onto it, a bit of custom scripting might be needed - but the Graphic element will first need to be replaced with a Button so that input over it can be detected.
We'll also need to store the ID of Item that's just been added. If you create a global Integer variable, update the OnInventoryAdd ActionList with a Variable: Set Action that sets this new variable's value to the Inventory item parameter.
Share screenshots of your Settings, Variables and Menu Managers once done and I'll see if I can provide the script then needed.
Thank you very much.
Here's what I did: I made the graphic element of the New Item menu invisible, replaced it with an identical button (ButtonGraphic), and integrated the update of the "Article d'inventaire" variable into the OnInventoryAdd ActionList.
The menu is functional, and clicking the ButtonGraphic of the added or selected item correctly triggers NouvelItem_ButtonGraphic_OnClick. However, dropping an item does not trigger it.
Here are the screenshots.
You don't need the Button to have an ActionList on click asset - this script, CombineNewItem.cs, should handle it:
Thank you.
Saving the script to Assets and adding it as a component of a scene object works.
But I have multiple scenes. Isn't there a way to listen to this script throughout the entire game, for example, using Global Events?
Yes - you can add this script to an empty GameObject, make it a prefab, and then spawn it when the game begins by running an Object: Add or remove Action in the Scene: Begin game event in the Events Editor.
If the prefab also has the Survive scene changes component, it will remain in the Hierarchy when switching scenes.
Thank you, I've integrated everything and it works wonderfully !