public void OnSearchedTaskClicked(SearchTasksWindow.NodeType nodeType) { CreateNodeView(nodeType, new Rect(_mousePosition.x, _mousePosition.y, BaseNodeView.kNodeWidht, BaseNodeView.kNodeHeight), nodeType.taskType.ToString()); //without the type.fullname it does not work }
private void CreateNodeView(SearchTasksWindow.NodeType nodeType, Rect windowRect, string windowTitle) { var instance = CreateInstance(nodeType.DrawerType.FullName) as BaseNodeView; instance.name = nodeType.DrawerType.Name; AssetDatabase.AddObjectToAsset(instance, currentGraph); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(currentGraph)); Debug.Assert(instance != null, nameof(instance) + " != null"); instance.Task = CreateInstance(nodeType.taskType) as ATask; instance.Task.name = nodeType.taskType.Name; AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(currentGraph)); AssetDatabase.AddObjectToAsset(instance.Task, currentGraph); instance.windowRect = windowRect; instance.windowTitle = windowTitle; if (instance.Task is IComposite cast) { instance.Init(null, false, _nodeViews.Count == 0 ? true : false, true); // if we pass null to the guid a new one will be created } else { instance.Init(null, false, _nodeViews.Count == 0 ? true : false, false); } _nodeViews.Add(instance); instance.OnClickedNode += OnClickedNode; instance.CopyVariables(null); if (_autoSave) { SaveGraphData(); } }