[Solved] Serialization error at runtime

Hi,

When I deploy my game to Windows Store profil, I’ve a serialization error and this message :

A script behaviour has a different serialization layout when loading. (Read 24 bytes but expected 76 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

(Filename: C:/BuildAgent/work/d63dfc6385190b60/Runtime/Serialize/SerializedFile.cpp Line: 1170)

I readed a lot of post about this problem which seems to be old.

I tryied some tricks such as remove the Library folder, rebuild le project, etc…

What can I do to solve this problem ?

I think that is maybe my code, I’m using inheritance of MonoBehavior and polymorphism and maybe it’s that the problem ?

This is a typical piece of code that I use :

// Class BasePlayer

public class BasePlayer : MonoBehaviour
{
    public int health = 100;
    public int maxHealth = 100;
    public int shieldValue = 25;
    public int attackValue = 25;
    public float luck = 1.0f;
    protected Transform _transform;
}

// Class BaseFIghter

[RequireComponent(typeof(BasePlayer))]
public class BaseFighter : MonoBehaviour
{
    public const int ScoreToEscape = 9;

    public enum CombatActions
    {
        None = 0, Attack, Defend, Escape
    }

    protected BasePlayer _basePlayer;
    protected Transform _transform;
    private BaseFighter _target;

    // Some code without preprocessor
}

// Class MazeMonsterFighter

[RequireComponent(typeof(MazeMonster))]
public class MazeMonsterFighter : BaseFighter
{
    // Some code again
}

// Class MazePlayerFighter

public class MazePlayerFighter : BaseFighter
{
    // Some code again
}

The problem is maybe because BaseFighter contains references to Base class ?

I have this problem ONLY with Windows Store Apps, all works well on Windows classic, Mac, Web, Windows Phone 8 and Android.

Thanks for the help !

Yann.

Is this 4.5?

Hi,

Yes my version of Unity is 4.5.1 f 3.

After a new debug session I’ve discovered that it’s not my player scripts that cause this problem but apparently it’s a part of my UI. I’m using NGUI.

Edit: I solved this problem by renaming some of my GameObjects.

@demonixis could you explain what you did in renaming GO’s and what about the names caused the problem? We’re experiencing a similar issue…

It seems to be solved with latest versions of Unity