ArgumentException: get_useNat can only be called from...

As Unity Beta 3.0.0b6, I’m now getting this compile error:

ArgumentException: get_useNat can only be called from the main thread
Multiplayer…ctor ()

My script is named Multiplayer, which would explain part of the message. Calls to the useNat property aren’t in the constructor/initializers, so I’m not sure why it says “Multiplayer…ctor”.

I did notice that Network.useNat isn’t in the documentation. Maybe it’s been obsoleted?

Any suggestions to deal with this change?

Can you post the script that is producing this error?

I am having this same issue… Unity 3.0.0f1

eg: the following line in C#:

private Material mySkybox = RenderSettings.skybox;

results in this error:

the whole script (with all irrelevant stuff taken out) is :

using UnityEngine;

public class testing : MonoBehaviour
{
    private Material mySkybox = RenderSettings.skybox;

    void Update()
    {

    }
}

there is another discussion about this here as well, http://forum.unity3d.com/viewtopic.php?t=62287 but I still can’t quite work out what the alternative to this approach would be?

cheers

after thinking about this for a little bit, I moved the offending code into the Start() method and all is well.

using UnityEngine;

public class testing : MonoBehaviour
{
    Material mySkybox;

    void Start()
    {
        mySkybox = RenderSettings.skybox;
    }

    void Update()
    {
        
    }
}