using UnityEngine;
using System;
using System.Reflection;
public class NewBehaviourScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Test1();
}
public string TestMethod<T>()
{
Debug.Log($"TestMethod {typeof(T)}");
return ">";
}
class Person
{
public string Name { get; set; }
public int id { get; set; }
}
public void Test1()
{
Type targetType = typeof(Person);
//NewBehaviourScript.TestMethod<targetType>();
MethodInfo method = typeof(NewBehaviourScript).GetMethod("TestMethod").MakeGenericMethod(targetType);
Debug.Log(method.Invoke(this, null));
}
}