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 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); }