Search Unity

Serialization depth limit exceeded at 'XXX'. error at unity4.6.2 and unity 4.6.3.

Discussion in 'Scripting' started by xuanyusong, Feb 27, 2015.

  1. xuanyusong

    xuanyusong

    Joined:
    Apr 10, 2013
    Posts:
    49
    hi all.

    run time ,I have this problem in unity4.6.2 and unity 4.6.3. but unity4.6.1 is OK .

    Serialization depth limit exceeded at 'XXX'. There may be an object composition cycle in one or more of your serialized classes.

    Code (CSharp):
    1. [System.Serializable]
    2. public class XXX
    3. {
    4.     public List<XXX> childPrefabs = new List<XXX>();
    5.     public XXX(){
    6.  
    7.     }
    8. }

    I don't want remove this code .

    public List<XXX> childPrefabs = new List<XXX>();
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You've created an infinite loop here. Just be glad Unity has a loop counter and didn't lock you out altogether.

    You create an XXX. This has a list of XXX which is serialised. This List contains a serialised XXX. And so on forever. You could remove the [Syste.Serializable] tag, or you could tan the List as [NonSerialised].
     
  3. xuanyusong

    xuanyusong

    Joined:
    Apr 10, 2013
    Posts:
    49


    Code (CSharp):
    1. public class AAA : ScriptableObject
    2. {
    3.     public XXX xxx;
    4. }
    5.  
    6.  
    7. AssetDatabase.CreateAsset(AAA, "Assets/aaa.asset");
    8.  

    I am creat ScriptableObject.but when I used Resources.Load<AAA>(“aaa”);
    error : Serialization depth limit exceeded at 'XXX'. There may be an object composition cycle in one or more of your serialized classes.