Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by monkaS98 · Jan 08, 2019 at 12:09 AM · serializationlimitcombo

Serialization depth limit 7 exceeded during serialization

Hello,

I'm trying to create a combo system for my game, where each combo would be an array, with different characteristics for each attack in it. To create such combo system, I made the following class:

 [System.Serializable]
 public class AttackCharacteristics : IAttacks
 {
   //diffrerent values for each attack here

     public AttackCharacteristics[] attacks;
 
     public AttackCharacteristics(int _amount)
     {
         attacks = new AttackCharacteristics[_amount];
     }
 
     AttackCharacteristics[] IAttacks.attacks()
     {
         return attacks;
     }
 }

The problem is that, because I have

 public AttackCharacteristics[] attacks;

it buids an infinite structure and I get an error "Serialization depth limit 7 exceeded...". I can't use [System.NonSerialized], because I want to manualy enter values for each attack in the inspector, and I can't find any other workaround to solve this error.

Thanks in advance for your answer.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by kaarloew · Jan 08, 2019 at 07:17 AM

As a workaround, you can always use index instead of reference. So you have one big array for all AttackCharacteristics and in each AttackCharacteristic you have list of indexes that point to right AttackCharacteristic.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image monkaS98 · Jan 08, 2019 at 09:15 PM 0
Share

Unfortunately, I can't use this workaround, because in my script I have the following code:

 private IAttacks[] combos = new IAttacks[2];
 public AttackCharacteristics firstCombo = new AttackCharacteristics(3);
 public AttackCharacteristics secondCombo = new AttackCharacteristics(3);
 
 void Awake()
     {
         combos[0] = firstCombo;
         combos[1] = secondCombo;
     }

It allows me to later easely control all my combos. Hovewer, I can't add an array of AttackCharacteristics to IAttacks array. Or maybe I'm missing something?

avatar image monkaS98 · Jan 11, 2019 at 01:32 AM 0
Share

It took me some time to figure out how to implement your workaround to my script, but in the end, your workaround helped me solve my issue, so thanks for correct answer :)

avatar image
1

Answer by shatteredeyeinc · Jan 11, 2019 at 01:36 AM

you could user newtonsoftjson instead get the dll and put it into your plugins folder in unity and set ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;

and use this instead of [System.Serializable]

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

104 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Serialization depth limit exceeded with a private field. 1 Answer

Are there any repercussions to ignoring the Serialization depth limit warning? 0 Answers

Limit reached when serializating XML 0 Answers

Array of arrays = No serialization? 4 Answers

Unbound Objects Are Not Null? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges