Unity graph tool solution based on different implementation now focused on Unity.Experimental.Graphview
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
732 B

using System;
using TNode.Models;
namespace TNode.Editor.Tools.NodeCreator{
public static class NodeHelper{
/// <summary>
/// always use this to create a new node.
/// </summary>
/// <typeparam name="T"></typeparam>
public static T InstantiateNodeData<T>() where T:NodeData{
var res = Activator.CreateInstance<T>();
res.id = Guid.NewGuid().ToString();
return res;
}
public static NodeData InstantiateNodeData(Type type){
if (Activator.CreateInstance(type) is NodeData res){
res.id = Guid.NewGuid().ToString();
return res;
}
return null;
}
}
}