The same field name is serialized multiple times in the class or its parent class. This is not supported:

Can someone please explain why I am getting this error even though it is an override? Is this a bug in unity or am I doing something wrong?
Error:

The same field name is serialized multiple times in the class or its parent class. This is not supported: Base(ShieldCustomInspector) <LastEditor>k__BackingField

Relevant Code:

[CustomEditor(typeof(Item),true)]//customizes the item class in the inspector
public class ItemCustomInspector : Editor
{
	public virtual string LastEditor { get; set; } = "item";
	
	public override void OnInspectorGUI()
    {
		if(LastEditor == "item")
        {
			//draw crap that I want to have at the very end of my inspector only once
		}
	}
}

[CustomEditor(typeof(HeldItem),true)]//customizes the item class in the inspector
public class HeldItemCustomInspector : ItemCustomInspector
{
	public override string LastEditor { get; set; } = "heldItem";
	
	public override void OnInspectorGUI()
    {
		if (LastEditor == "heldItem")
		{
		  //draw crap that I want to have at the very end of my inspector only once
		}
	}
}



[CustomEditor(typeof(Shield), true)]//customizes the item class in the inspector
public class ShieldCustomInspector : HeldItemCustomInspector
{
    public override string LastEditor { get; set; } = "shield";
	
	public override void OnInspectorGUI()
    {
		if (LastEditor == "shield")
		{
		  //draw crap that I want to have at the very end of my inspector only once
		}
	}
}

Inheritance is not the best pattern if what you want is polymorphism.


Removing the CustomEditorAttribute from the ItemCustomInspector would be the quickest fix but refactoring it to a better pattern would be the better one.


But to answer your question. No it doesn’t look like a bug it looks like a misuse of a reasonably sensible implementation.