The same field name is serialized multiple times in the class or its parent class.

I am getting this error:
The same field name is serialized multiple times in the class or its parent class. This is not supported: Base(AddComponentWindow) <setInitialSelectionPosition>k__BackingField

This is the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class QuestionGenerator : MonoBehaviour
{
    public int level = 1;
    public int secondNumber = 1;
    public TextMeshPro textmeshPro;

    void Start()
    {
        TextMeshPro text = textmeshPro.GetComponent<TextMeshPro>();
        text.SetText("{0} + {1} = ", level, secondNumber);
    }
}

Why am I getting this error?

You’re sure that’s the code that’s giving you the error? That code seems fine. The error you’re seeing usually happens when you’ve set up some redundant fields in inherited classes. Do you have a “AddComponentWindow” class in your project anywhere? Anything have an “InitialSelectionPosition” property? Or just double check where the error really is by double-clicking it.

1 Like