public void Initialize(string assetGuid) { try { var asset = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(AssetDatabase.GUIDToAssetPath(assetGuid)); if (asset == null) { return; } if (!EditorUtility.IsPersistent(asset)) { return; } if (selectedGuid == assetGuid) { return; } Type graphType; var path = AssetDatabase.GetAssetPath(asset); var extension = Path.GetExtension(path); var name = Path.GetFileNameWithoutExtension(path); switch (extension) { case ".NodeGraph": graphType = typeof(NodeGraph); break; default: return; } var textGraph = File.ReadAllText(path, Encoding.UTF8); graphObject = CreateInstance <GraphObject>(); graphObject.name = name; graphObject.hideFlags = HideFlags.HideAndDontSave; graphObject.graph = JsonUtility.FromJson(textGraph, graphType) as IGraph; selectedGuid = assetGuid; if (graphObject.graph == null) { graphObject.graph = Activator.CreateInstance(graphType) as IGraph; } graphObject.graph.OnEnable(); graphObject.graph.ValidateGraph(); graphEditorView = new GraphEditorView(this, m_GraphObject.graph as AbstractNodeGraph) { persistenceKey = selectedGuid, assetName = asset.name.Split('/').Last() }; graphEditorView.RegisterCallback <GeometryChangedEvent>(OnGeometryChanged); titleContent = new GUIContent(asset.name.Split('/').Last()); Repaint(); } catch (Exception) { m_HasError = true; m_GraphEditorView = null; graphObject = null; throw; } }