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
733 B
25 lines
733 B
using System;
|
|
using TNode.Models;
|
|
|
|
namespace TNode.Editor.Tools.NodeCreator{
|
|
public static class NodeCreator{
|
|
|
|
/// <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;
|
|
}
|
|
}
|
|
} |