public void LoadGraph(NoduxLinkGraph component) { NoduxGraphOperation.ClearGraph(_graphView); _graphView.SetSerializeTarget(component); var graphNodeMap = new Dictionary <string, NoduxGraphNodeView>(); // create nodes for (var i = 0; i < component.GraphContainer.Nodes.Count; i++) { var graphNode = NoduxGraphNodeViewCreator.Load(_graphView.SerializedGraph, component.GraphContainer.Nodes[i], i); _graphView.AddElement(graphNode); graphNodeMap[graphNode.Guid] = graphNode; } // connect nodes foreach (var link in component.GraphContainer.Links) { if (link.TargetNodeGuid == null || link.SourceNodeGuid == null) { continue; } if (!graphNodeMap.ContainsKey(link.TargetNodeGuid) || !graphNodeMap.ContainsKey(link.SourceNodeGuid)) { Debug.LogWarning($"Link nodes failed {link.SourceNodeGuid} -> {link.TargetNodeGuid}"); continue; } var source = graphNodeMap[link.SourceNodeGuid]; var target = graphNodeMap[link.TargetNodeGuid]; NoduxGraphOperation.LinkNode(_graphView, source, target); } }
public void SaveGraph(NoduxLinkGraph component) { // node, link, LinkedNodeの更新 _graphView.SerializedGraph.RemoveUnExistNodes(_nodes); _graphView.SerializedGraph.UpdateNodeMeta(_nodes); _graphView.SerializedGraph.UpdateLinks(_edges); var nodesArray = NoduxGraphOperation.ExtractGraphNodeChains(_graphView.SerializedGraph.Container); _graphView.SerializedGraph.UpdateLinkedNodes(nodesArray); }
public void AlignNodes(int columns) { var nodesList = NoduxGraphOperation.ExtractGraphNodeChains(this); if (nodesList == null) { return; } var origin = StartNodeOrigin; foreach (var nodes in nodesList) { var rect = NoduxGraphOperation.LayoutNodes(columns, origin, nodes); origin.y += rect.height; } }
public void OnHierarchyChange() { var graphSceneName = _serializedGraph?.GraphSceneName; if (graphSceneName == null) { return; } var found = false; for (var i = 0; i < EditorSceneManager.sceneCount; i++) { var scene = EditorSceneManager.GetSceneAt(i); if (graphSceneName == scene.name) { if (scene.isLoaded) { return; } found = true; break; } } // XXX: it may be prefab edit. avoid clear if (!found) { return; } NoduxGraphOperation.ClearGraph(this); _internalGameObject = null; _serializedGraph = null; }
private void RequestClear() { NoduxGraphOperation.ClearGraph(_graphView); }