Ejemplo n.º 1
0
        private static TaskNode DeserializeNode(JToken token, TaskSerializationData data, BehaviourGraphView view)
        {
            var obj = token as JObject;

            var type     = TaskUtility.GetTypeWithinAssembly(obj.Value <string>("Type"));
            var nData    = obj.Value <JObject>("NodeData");
            var position = nData.GetValue("Offset").ToObject <Vector2>(NodeSerializer.Serializer);

            var node = view.CreateNode(type, position);

            var name    = obj.Value <string>("Name");
            var id      = obj.Value <int>("ID");
            var instant = obj.Value <bool>("Instant");

            node.title = name;

            node.Data = DeserializeObject(obj, type, view, data.fieldSerializationData.unityObjects, node) as Task;
            node.Data.FriendlyName = name;
            node.Data.IsInstant    = instant;
            node.Data.ID           = id;

            var children = obj.GetValue("Children");

            if (children is JArray array)
            {
                foreach (var entry in array)
                {
                    var child = DeserializeNode(entry, data, view);
                    view.Connect(child, node);
                }
            }

            return(node);
        }
Ejemplo n.º 2
0
        public static void Deserialize(TaskSerializationData data, BehaviourGraphView view)
        {
            if (string.IsNullOrEmpty(data.JSONSerialization))
            {
                return;
            }

            var obj = JObject.Parse(data.JSONSerialization);

            var entry = DeserializeNode(obj.GetValue("EntryTask"), data, view);
            var root  = DeserializeNode(obj.GetValue("RootTask"), data, view);

            DeserializeVariables(obj.GetValue("Variables"), view);

            view.Connect(root, entry);
        }