A script behaviour (script unknown or not yet loaded) has a different serialization layout when loading.

Here is the full error: http://puu.sh/nz8dL/08c73fb0f1.png It only happens in a build. I have tried completely removing all plugins from the project, but it wasn’t that. The only 2 serialized classes I have are these:

[System.Serializable]
public class PlayerStats
{
    public int startHealthPoints;

    public float baseSpeed;
}

and

[System.Serializable]
public class GameRoom
{
    public string roomName;
    public int playerLimit;
    public string hostIp;
    public int hostPort;

    public GameRoom(string roomName, int playerLimit, string hostIp, int hostPort)
    {
        this.roomName = roomName;
        this.playerLimit = playerLimit;
        this.hostIp = hostIp;
        this.hostPort = hostPort;
    }
}

They were working fine before, but then I swapped computer, and now it’s not working in the build anymore.

Edit: It seems to not be a problem with my [Serializable] classes, but rather with my ScriptableObjects. Here is how I have them structured: http://hastebin.com/vetecuwoma.hs If I remove all references to the ScriptableObject, the errors disappear, even when the objects are still in my assets. So as the error suggests, it’s with the serialization. Any help is much appreciated!

@Bmandk
I was having the same error on builds only.
For the record (and Google searches) the problem is:
you are referencing an object in a public property of a script that was generated dynamically in the editor.
This happens easily on scripts that can run both in editor and at runtime.
Once you run the build, this script is expecting this reference to exist but it doesn’t because it hasn’t been generated yet, so it returns null and raises an error.
However, since that object is very likely to be generated later by code, your game will run just fine.
The solution is to ensure you never reference an object generated by code in a public property of a script.
Public Static objects are fine though…