void WriteToData() { Debug.Log("try write... " + (data != null) + " / " + isDirty); if(data != null && isDirty) { int counter=0; data.nodes = nodes.Select((EditorNode n) => { var node = new graphNode(); node.ID = counter++; node.position = n.position; return node; }).ToList(); data.edges = edges.Select((EditorConnection c)=> { var gc = new graphConnection(); gc.A = c.nodeA.ID; gc.B = c.nodeB.ID; gc.dir = c.dir; gc.forced = c.forceConnection; gc.supressed = c.supressConnection; return gc; }).ToList(); dataObj.Update(); EditorUtility.SetDirty(data); AssetDatabase.SaveAssets(); isDirty = false; } }
EditorConnection CreateConnection(EditorNode a, EditorNode b, graphConnection gc) { EditorConnection c = CreateConnection(a, b, gc.dir, gc.forced); if(c != null) c.supressConnection = gc.supressed; return c; }