Hi!
Im making a game which recently landed me in a pile of warnings, and one error. I just got done reformatting several scripts, so I dont know precisely where to look to solve this issue.
THE WARNING:
Serialization depth limit 10 exceeded at ‘CardSaveLoad.effectValue’. There may be an object composition cycle in one or more of your serialized classes.
Serialization hierarchy:
11: CardSaveLoad.effectValue
10: Item.metaCardList
9: CardSaveLoad.sourceItem
8: Item.metaCardList
7: CardSaveLoad.sourceItem
6: Item.metaCardList
5: CardSaveLoad.sourceItem
4: Item.metaCardList
3: CardSaveLoad.sourceItem
2: Item.metaCardList
1: CardSaveLoad.sourceItem
0: PassiveSavaLoad.boundCard
THE ERROR:
Recursive Serialization is not supported. You can’t dereference a PPtr while loading. (Constructors of C# classes may not load objects either. See stacktrace.)
rather than posting all the scripts here, I feel it would be better to explain the structure im using to create/save instances of things for my game.
Important note, most items in my game are customizable, copy able, and need multiple instances to function.
For almost all Classes I have in the game, there are 2 sister classes.
-The First is a gameobject controller which applies data to the gameobject, manages child gameobjects and interactions with other gameobjects.
-the Second is a Scriptable Object, so I can easily save different version of each type of thing
-the Third is a Serializable class which contains all serializable data for the thing, including values that have been changed from the set Scriptable object. Its a bad naming scheme, but I call these SaveLoads. (shown in error above)
Now, this error/warning are supposed to be coming from “infinite loops” but im not sure where that could be. Right now, I have Classes (and sister classes) for the following things.
-Characters
-Cards
-Decks
-Items(which add cards to your deck when equipped)
-Passives (which essentially work in tandom with characters to cause things to happen
I have a feeling the problem is coming from cards, which sort of reverse the flow of references to easily remove them from a deck when an item is taken away.
characters reference cards, decks, items, passives
Passives reference cards (to play at certain times automatically) and other passives (for stacking effects or spreading to other characters, maybe this is being read as recursive? )
decks are basically just a list of cards with extra functions
items have a list of cards which they add to your deck, among other effects
cards however keep track of other cards (multiplying or adding staged cards) and also the equipment that added them to the deck, if thats how they got there.
I can post any code to look at at request, I just dont know where to even look for this.