Hello everyone.
I’ve been building out a bunch of Visual Scripting elements, but found a cool Inventory module written in C#. I’d like to build the entire inventory system in VS, but to save time, used the Asset Store sample in its place.
It works as-is, with the mouse interacting with everything. I am looking to continue to use my existing Visual Scripting as well as this C# section.
The problem I am having is trying to use a keyboard interaction to active/de-active the objects. The C# script, below, runs an update when the player closes the inventory window out with the ‘x’ button in the corner - which would not occur if I just active/de-active the objects through VS.
I’d like to know how to run a section of C# script (public void UpdatePanelSlotsForUsedItems), shown below, but similar to how you would run a Custom Event Trigger (when I click a keyboard button).
It is easy enough to get the objects to be visible / not visible on screen, but triggering this specific C# component, which is a critical element in updating the inventory, escapes me right now.
How can I run just ‘parts of code’ from VS, as if they were Custom Events?

public void UpdatePanelSlotsForUsedItems()
{
var index = 0;
foreach (Item item in list)
{
// do not take more items with you when there is no more space
if (index >= maxActivatedPowerUps)
{
return;
}
if (!item.IsActivated())
{
continue;
}
var obj = inventoryPanel.transform.GetChild(index);
obj.gameObject.SetActive(true);
var slot= obj.GetComponent<InventorySlotController>();
slot.item = item;
slot.UpdateSelectedInfo();
index++;
}
// update the rest of the free spots
for(var i = index; i < maxActivatedPowerUps; i++)
{
var obj = inventoryPanel.transform.GetChild(i);
obj.gameObject.SetActive(true);
var slot= obj.GetComponent<InventorySlotController>();
slot.item = null;
slot.UpdateSelectedInfo();
}
}



