Pass UnityAction with paramater, as parameter

Trying to send an UnityAction as a parameter for one of my methods, like so:

testMethod(1, "somestring", MyAction);

this works fine, but now I want to pass the following Action as a parameter:

public void ActivateQuest(int questId)
        {
            Debug.Log("This is the id: " + questId);
        }

However, it will not work when I use an action that has a parameter:

testMethod(1, "somestring", ActivateQuest(2));

The above gives error: Cannot convert from void to UnityAction.

If I try the only solution I found online:

UnityAction<int> test = QuestManager.Instance().ActivateQuest;
    testMethod(1, "somestring", test(2));

I get the same error. How can I pass a UnityAction with a parameter, as a parameter?

EDIT:
I finally call my action like so:

 dialog.OnAccept(onLastPagePrompt, () =>
                {
                    conversation.action();
                    dialog.Hide();
                });
1 Like

Was the edit to say you solved it?

It wasn’t clear from your code posted if you setup your UnityEvent like so (above).

1 Like

Thanks, I solved it by using:

dialogHolder.PopulateConversationList(stage1, "Okay", _name, 1, () =>
        {
            QuestManager.Instance().ActivateQuest(0);
            npcManager.ChangeStage();
        });

Cool :slight_smile: