Hitting Serialization depth, need a better way to access parent class

Hello, I’ve looked for similar questions but they all involve a game object or a monobehaviour but mine is a bit different (probably doing it the wrong way). I’m quite new to c# and Unity so apologies if this is obvious.

I have a GameManager Class that contains an array of Character classes, which in turn have CharacterStats class that then have a CharacterStat class. Based on that it’s only 4 classes deep so I think I’m hitting the Unity Serialisation Depth warning because of recursion(?).

The looping/recursion (as I’ve read) is because I’m passing in the CharacterStats class to the Stat class because I need a reference to it. I see people getting around this by accessing the instance or the game object then finding it with GetComponent but this won’t work in my case.

Is there a better way of accessing that “parent” class without passing it in as a parameter to the CharacterStat constructor?

Here is the code in question, you can see me passing in this to the CharacterStat:

public class CharacterStats {

    public CharacterStat STA, STR, AGI;
    public CharacterSkill Pistol, Bow;
    public CharacterAttribute HP, NP, Speed;

    public CharacterStats(Profession profession) {

        STA = new CharacterStat(this, "Stamina", StatType.STA, profession.STA);
        STR = new CharacterStat(this, "Strength", StatType.STR, profession.STR);
        AGI = new CharacterStat(this, "Agility", StatType.AGI, profession.AGI);
        Pistol = new CharacterSkill(this,"Pistol", StatType.Pistol, profession.Pistol, profession.PistolAffinitities);
        Bow = new CharacterSkill(this,"Bow", StatType.Bow, profession.Bow, profession.BowAffinitities);

I don’t believe that is your problem, but your description is not clear. Where are there any inheritance relationships? Or what do you mean by “parent - child” ? Are you talking about objects containing other objects in the hierachy?

You state that your gamemanager class contains an array of Character classes, but that language does not make sense. Perhaps you mean you have defined an array of e.g. Character within game manager. This will be an array of objects of type Character.

Another example: CharacterStats does in inherit from CharacterStat, according to your code.

So it is hard to tell what your problem is. What is the exact error message you are getting?