summaryrefslogtreecommitdiff
path: root/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs
diff options
context:
space:
mode:
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs')
-rw-r--r--WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs27
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;
+ }
+
}