Ejemplo n.º 1
0
        public string Serialize()
        {
            SerGraph sg = new SerGraph();

            sg.Init(this);
            return(JsonConvert.SerializeObject(sg, Formatting.Indented));
        }
Ejemplo n.º 2
0
        public void Load(string content)
        {
            Blackboard = new Blackboard();
            SerGraph sg = JsonConvert.DeserializeObject <SerGraph>(content);

            Load(sg);
        }
Ejemplo n.º 3
0
        public static bool OnOpen(int instanceID, int line)
        {
            string path = AssetDatabase.GetAssetPath(EditorUtility.InstanceIDToObject(instanceID));

            if (path.Contains(".ue."))
            {
                filePath = Path.Combine(System.IO.Directory.GetParent(Application.dataPath).FullName, path);
                string   data = Util.ReadTextFile(path);
                SerGraph sg   = JsonConvert.DeserializeObject <SerGraph>(data);
                graph = new Graph();
                graph.Load(sg);
                var ge = GetWindow <GraphEditor>();
                ge.Init();
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public void Load(SerGraph sg)
        {
            // 加载blackboard
            if (sg.Blackboard != null)
            {
                Blackboard = new Blackboard();
                Blackboard.Load(sg.Blackboard);
            }

            foreach (var sn in sg.Nodes)
            {
                Node node = (Node)Activator.CreateInstance(Type.GetType(sn.Type));
                node.Load(this, sn);
                nodes.Add(node.ID, node);
            }

            foreach (var connect in sg.Connections)
            {
                Connection connection = new Connection(this);
                connection.Connect(connect.Type, connect.Source, connect.SourcePort, connect.Target, connect.TargetPort);
                Connections.Add(connection);
            }
        }