diff options
author | chai <215380520@qq.com> | 2023-06-30 19:20:16 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-06-30 19:20:16 +0800 |
commit | 7de061b5595c3b849c3e010ed7c7deed9ce7a1ff (patch) | |
tree | be6305a7db6645b865ecc3073ff121222ae4241b /WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs | |
parent | 6dbca86d957f774059068b8dbe01170d71cb0e8f (diff) |
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs')
-rw-r--r-- | WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs b/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs index ae5a132..b4de592 100644 --- a/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs +++ b/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs @@ -1,7 +1,11 @@ +using System; +using System.Reflection; +using System.Reflection.Emit; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; +using System.Linq; public static class CommonFunction { @@ -22,4 +26,27 @@ public static class CommonFunction File.WriteAllText(file, content); } + public static Type GetTypeByName(string name) + { + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies().Reverse()) + { + var tt = assembly.GetType(name); + if (tt != null) + { + return tt; + } + } + + return null; + } + + public static System.Object CreateInstance(string typeName) + { + Type t = GetTypeByName(typeName); + if (t == null) + return null; + var obj = Activator.CreateInstance(t); + return obj; + } + } |