Full Message:
A scripted object (probably AbyssMoth.Internal.Codebase.Runtime._AdvantureMode.Hero.HeroController?) has a different serialization layout when loading. (Read 148 bytes but expected 152 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
Cause of the problem:
// ********************************************************************
//
// Copyright (c) RimuruDev
// Contact information:
// Email: [email protected]
// GitHub: https://github.com/RimuruDev
// LinkedIn: https://www.linkedin.com/in/rimuru/
//
// ********************************************************************
using System;
using UnityEngine;
namespace RimuruDev
{
[Serializable]
[HelpURL("https://github.com/RimuruDev/Unity-ReactiveProperty-Helper.git")]
public class ReactiveProperty<T>
{
#if UNITY_EDITOR
[SerializeField]
#endif
private T value;
[NonSerialized] private Action<T> onChanged;
public event Action<T> OnChanged
{
add
{
onChanged += value;
value?.Invoke(this.value);
}
remove => onChanged -= value;
}
public T Value
{
get => value;
set
{
this.value = value;
onChanged?.Invoke(value);
}
}
public void OnNext(T nextValue)
{
Value = nextValue;
}
public ReactiveProperty(T initialValue = default)
{
value = initialValue;
}
}
}
The problem was in this line:
#if UNITY_EDITOR
[SerializeField]
#endif
It was needed purely to see the values in the editor for debugging. Removed this preprocessor directive and everything is ready as normal. Here is the corrected script, after which the error disappeared:
// ********************************************************************
//
// Copyright (c) RimuruDev
// Contact information:
// Email: [email protected]
// GitHub: https://github.com/RimuruDev
// LinkedIn: https://www.linkedin.com/in/rimuru/
//
// ********************************************************************
using System;
using UnityEngine;
namespace RimuruDev
{
[Serializable]
[HelpURL("https://github.com/RimuruDev/Unity-ReactiveProperty-Helper.git")]
public class ReactiveProperty<T>
{
[SerializeField] private T value;
[NonSerialized] private Action<T> onChanged;
public event Action<T> OnChanged
{
add
{
onChanged += value;
value?.Invoke(this.value);
}
remove => onChanged -= value;
}
public T Value
{
get => value;
set
{
this.value = value;
onChanged?.Invoke(value);
}
}
public void OnNext(T nextValue)
{
Value = nextValue;
}
public ReactiveProperty(T initialValue = default)
{
value = initialValue;
}
}
}