//TODO: Move this in GraphSerializationData object Reconstruction? bool LoadGraphData(GraphSerializationData data, bool validate) { if (data == null) { Debug.LogError("Can't Load graph, cause of null GraphSerializationData provided"); return(false); } if (data.type != this.GetType()) { Debug.LogError("Can't Load graph, cause of different Graph type serialized and required"); return(false); } data.Reconstruct(this); //grab the final data and set fields directly this._name = data.name; this._comments = data.comments; this._translation = data.translation; this._zoomFactor = data.zoomFactor; this._nodes = data.nodes; this._primeNode = data.primeNode; this._canvasGroups = data.canvasGroups; this._localBlackboard = data.localBlackboard; //IMPORTANT: Validate should be called in all deserialize cases outside of Unity's 'OnAfterDeserialize', //like for example when loading from json, or manualy calling this outside of OnAfterDeserialize. if (validate) { Validate(); } return(true); }
bool LoadGraphData(GraphSerializationData data, bool validate) { if (data == null) { Debug.LogError("Can't Load graph, cause of null GraphSerializationData provided"); return(false); } if (data.type != this.GetType()) { Debug.LogError("Can't Load graph, cause of different Graph type serialized and required"); return(false); } data.Reconstruct(this); this._name = data.name; this._translation = data.translation; this._zoomFactor = data.zoomFactor; this._nodes = data.nodes; this._primeNode = data.primeNode; if (this is UIGraph) { UIGraph.uiDics = data.uiDic; } else if (this is GameStateGraph) { UIGraph.uiDics = data.uiDic; } return(true); }
//TODO: Move this in GraphSerializationData object Reconstruction? bool LoadGraphData(GraphSerializationData data) { if (data == null) { Debug.LogError("Can't Load graph, cause of null GraphSerializationData provided"); return(false); } if (data.type != this.GetType()) { Debug.LogError("Can't Load graph, cause of different Graph type serialized and required"); return(false); } data.Reconstruct(this); //grab the final data and set 'raw' this._name = data.name; this._comments = data.comments; this._translation = data.translation; this._nodes = data.nodes; this._primeNode = data.primeNode; this._canvasGroups = data.canvasGroups; this._localBlackboard = data.localBlackboard; Validate(); return(true); }
public void SerializeConfigurationData(System.Windows.Forms.SaveFileDialog result) { List <GraphSerializationData> graphSerializationData = new List <GraphSerializationData>(); foreach (CableConfiguration cc in mainWindow.GlobalCableConfiguration.Values) { GraphSerializationData gsd = new GraphSerializationData() { Data = cc }; graphSerializationData.Add(gsd); } FileServiceProvider.SerializeDataToFile(result.FileName + "_cable_config", graphSerializationData); }
public void SerializeEdgeData(System.Windows.Forms.SaveFileDialog result) { List <GraphSerializationData> graphSerializationData = new List <GraphSerializationData>(); foreach (DataEdge ec in Area.EdgesList.Keys) { GraphSerializationData gsd = new GraphSerializationData() { Data = ec, IsVisible = true, HasLabel = true }; graphSerializationData.Add(gsd); } FileServiceProvider.SerializeDataToFile(result.FileName + "_edge_data", graphSerializationData); }
static void TestBTree() { GameObject rootObj = new GameObject("Unit"); BehaviourTreeOwner owner = rootObj.AddComponent <BehaviourTreeOwner>(); BehaviourTree jsonTree = new BehaviourTree(); string path = "./../../Resources/LLogTree.BT"; //string path = "./../../Resources/LLogTree.BT"; string jsonGraph = System.IO.File.ReadAllText(path); Console.WriteLine(jsonGraph); GraphSerializationData graphData = jsonTree.Deserialize(jsonGraph, true, null); owner.StartBehaviour(jsonTree, (bool val) => { Loger.Log("StartBehaviour Callback : " + val); }); }
public void SerializeVertexData(System.Windows.Forms.SaveFileDialog result) { List <GraphSerializationData> graphSerializationData = new List <GraphSerializationData>(); Console.WriteLine(mainWindow.GlobalVertices.Count); foreach (VertexControl vc in Area.VertexList.Values) { Point p = vc.GetPosition(); GraphSerializationData gsd = new GraphSerializationData() { Data = (DataVertex)vc.Vertex, Position = new GraphX.Measure.Point(p.X, p.Y), IsVisible = true, HasLabel = true }; graphSerializationData.Add(gsd); } FileServiceProvider.SerializeDataToFile(result.FileName + "_vertex_data", graphSerializationData); }