Hello!! I have a small but annoing problem with Serialization... I have a class, for example, Node, that holds a refrense to the previous Node's class everything works fine except the fact that nothing is saved after I click play :\ this is the class Code (CSharp): using UnityEngine; [System.Serializable] public class Node { [SerializeField]public string Name; [SerializeField]public Node Previous; } But! if I create something like this Code (CSharp): using UnityEngine; [System.Serializable] public class Node { [SerializeField]public string Name; [SerializeField]public Node2 Previous; } [System.Serializable]public class Node2 : Node {} it is working :\ If that matters, I am using Unity5, and I am using a custom editor to set the classes (I have tried to set as dirty but its still not working) Can anyone help? ** And on the same issue, does anyone knows a way to keep a referense to a class? kind of like a pointer, but something that I can serialize?
You're most likely getting a serialisation warning in the log, which you should really stop ignoring With regards to solving this shortcoming of the Unity serialisation system, see "I want to serialise something which Unity's serialiser doesn't support. What do I do?" in this post: http://blogs.unity3d.com/2014/06/24/serialization-in-unity/
Yea well I figured it out... Its because the compiler is afraid of an endless loop of referenses, makes sense kind of So I just store a string ID, and on Start I search the nodes database for that ID (I have a dictinary<ID, NODE>) But thanks for the replay! and the link