RPC Failed because the script couldn't be loaded.

Hello, I am currently working on making buttons ans switches networked so that they perform what is needed on all client.

I am running into the error "RPC call failed because the script couldn't be loaded. The function was 'ToggleSwitch'." on a few of my scripts. Most work fine though.

Here is the code: `

function OnMouseDown () 
{
    //ToggleSwitch();
    networkView.RPC("ToggleSwitch", RPCMode.All);
}

@RPC
function ToggleSwitch()
{
    switch (lcu_static_variables.back_text)
    {
          .....
    }
}

`

the exact same setup works in other scripts... Any ideas what is wrong?

This happens when you have a "Missing Monobehaviour" on the same gameobject (a missing script).

This can still happen if you have an script that is attached (not missing) but empty. For instance, a script, the entirity of which is wrapped in:

#IF UNITY_IPHONE
//code here
#endif

Would produce this error when on a platform other than iOS. Its an edge case, but perhaps this kind of thing is what’s causing this issue for you.

I’ve received the same runtime error message and I think that my GameObject hasn’t got any missing script attatched to…I’ve revised a lot of times and well…I don’t know what can be…

Any idea?