"ArgumentException: failed to convert parameters" Error

This error seems to occur when the following code is run:

    static GameObject Previous;
    public GameObject OwnerPanel;


    public void GoToPanel(GameObject To)
    {
        Previous = this.OwnerPanel;
        gameObject.SetActive(false);
        To.SetActive(true);
    }
    public void ReturnToPrevious()
    {
        gameObject.SetActive(false);
        Previous.SetActive(true);
    }

The ‘OwnerPanel’ variable is set in the inspector, as is ‘To’. Not exactly sure why this is happening but I am pretty sure it is an issue with setting the Static ‘previous’ to an instance variable. Is there any solution other than having a separate global script to store ‘Previous’?

NOTE: I am 100% sure it is this code, it is the only script in the entire project that is running and the error occurs when ‘GoToPanel’ is called. The error itself is a mess of internal UnityEngine calls that are beyond me.

Assuming that you’re using the method as event subrscriber in the editor, it looks like it’s actually not properly assigned.
If it’s not someone wired to an event, how do you call it and what exactly do you pass into it as argument?

Not entirely sure what you mean.

The script is added to a UI Button as a component and the function is called via the “OnClick()” event in the inspector.

…oh

The issue has just become glaringly obvious, things don’t exactly work when there is no GameObject assigned.

2996616--223273--ButtonDebug.PNG

That’s what I meant. You hooked it up as an event subscriber for the onclick event, but did not specify a gameobject which would be the argument for the method.