Search Unity

Serialization Depth / Show Class in Inspector problem

Discussion in 'Scripting' started by CxydaIO, Apr 20, 2015.

  1. CxydaIO

    CxydaIO

    Joined:
    May 12, 2014
    Posts:
    61
    Hey guys, i have a problem ... I want to have some items in my game which can be crafted out of some other items (ingredients) so i wrote a class Item which contains an array of Ingredients but since you should be able to craft an item which is needed to craft better items the ingredient class contains basically an Item and an int how many of those items you need.

    Now i get a lot of "There may be an object composition cycle in one or more of your serialized classes." errors
    i googled it and i found that i can fix it when i make the Ingredient Array in my item class [NonSerialized]. So i did that, but now i loose obviously the possibility to set up my Item and crafting recipes in the inspector. Is there a way to solve this ? Or can i only store my recipes outside unity... in an XML file for example ? o.0.

    I know i could igore the errors but they bugging me -.-' Can i switch of those errors?
    Or is there a better way th build a crafting item class?!


    this is the post where i found the "solution" for my problem
    http://forum.unity3d.com/threads/4-5-serialization-depth.248321/

    Thank you!
     
    Last edited: Apr 20, 2015
  2. CxydaIO

    CxydaIO

    Joined:
    May 12, 2014
    Posts:
    61
    hm actually the question is can i NOT serialize a class and still have it visible in the Inspector!?