Home > OS >  Public Function cant be found in OnClick Event
Public Function cant be found in OnClick Event

Time:02-26

So I have an Inventory and the Items have MataData, that I am scanning for. Although when I try to hook up the public void to the OnClick selection on the Button, it does not show up, why? Code Snipped:

public void ScanForFlashlightMetaData(string type, string Flashlight)
    {
        foreach (Slot slot in inventory)
        if (slot.type == type && slot.metaData == Flashlight)
        {
            Debug.Log("Test");
        }
    }

CodePudding user response:

Callback functions assigned to ButtonClickEvent can only take zero or one parameters (which is why it shows up when you remove them).

Try looking here for workarounds, or consider creating a custom Button class that uses the generic UnityEvent<T0, T1, ...> which supports up to four arguments.

  • Related