- changed status to on hold
Non-serialized values with ShowInInspector on Odin Serialized instances dissapears on prefab instances, dissapears when any modifications are made.
Issue #290
wontfix
public class NewBehaviourScript : SerializedMonoBehaviour
{
public Dummy dummy;
}
public class Dummy
{
[SerializeField]
private string a; // When modifications are made to this in prefab instances.
// The entire dummy instance gets recreated.
// Which means changes to the temporaryVariable gets resets as we type.
[ShowInInspector]
private int temporaryVariable;
}
[OdinDrawer]
[DrawerPriority(DrawerPriorityLevel.SuperPriority)]
public class DebugThing : OdinValueDrawer<Dummy>
{
public static System.Runtime.Serialization.ObjectIDGenerator gen = new System.Runtime.Serialization.ObjectIDGenerator();
protected override void DrawPropertyLayout(IPropertyValueEntry<Dummy> entry, GUIContent label)
{
bool a;
var id = gen.GetId(entry.WeakSmartValue ?? "", out a);
GUILayout.Label(id.ToString());
this.CallNextDrawer(entry, label);
GUILayout.Space(10);
}
}
Comments (2)
-
reporter -
- changed status to wontfix
I'm afraid this is fundamentally impossible to do with the way prefab modifications work in Unity, since changing a prefab instance's modifications immediately causes it to be deserialized with the new modifications applied, therefore losing old non-serialized values.
- Log in to comment
We'll revisit this issue in the future, but a fix is at this point not guaranteed. We need Tor's eyes on the issue as it's deeply tied to how prefab modifications work. Tor will join us again in 2 months time.
For now though, just keep in mind that that is happening, and work around it. A simple fix to the problem could be would be for instance to make the temporaryVariable static, and show it through a property: