It's not Auto-open for selection. I want to use the clicked document item in the script and open the document. But I can't find the relevant function.
public void ChangeDocument()
{
KickStarter.runtimeDocuments.OpenDocument(KickStarter.runtimeInventory.LastSelectedItem.???);
print("Click the" + DocumentName.text);
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Welcome to the community, @zfh2773.
Though Documents are defined in the Inventory tab, they are separate to inventory items. Instead of LastSelectedItem, you can access a Document by passing its ID number to the InventoryManager's GetDocument function:
A Document's ID number is written to the left of its name in the Inventory Manager.
Thank you. I mean, how do I know which document the item slot I clicked on is? Is there a function method that opens the document of the clicked item?
Inventory items are not linked to Documents inherently - you need to create a link manually.
The easiest way to do this is though use of the Document: Open Action inside the inventory item's "Use interaction" ActionList asset, so that clicking it in the menu will open your intended Document.
This can be handled through scripting, by hooking into the OnMenuElementClick custom event, but not necessary just to get documents to open when clicking items.
Collected Documents can, however, be displayed as their own list. An InventoryBox menu element's Inventory box type property can be set to Collected Documents, which will cause it to display all Documents collected using the Document: Add or remove Action. Clicking a Document from this list will automatically open it.
Thank you! I succeeded! I made a stupid mistake!