summaryrefslogtreecommitdiff
path: root/YesCommander/Assets/Scripts/Common/CommonFunction.cs
diff options
context:
space:
mode:
Diffstat (limited to 'YesCommander/Assets/Scripts/Common/CommonFunction.cs')
-rw-r--r--YesCommander/Assets/Scripts/Common/CommonFunction.cs57
1 files changed, 57 insertions, 0 deletions
diff --git a/YesCommander/Assets/Scripts/Common/CommonFunction.cs b/YesCommander/Assets/Scripts/Common/CommonFunction.cs
new file mode 100644
index 0000000..e5b8d30
--- /dev/null
+++ b/YesCommander/Assets/Scripts/Common/CommonFunction.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using UnityEngine;
+using System.Linq;
+
+namespace YC
+{
+
+ public static class CommonFunction
+ {
+
+ public static void WriteFile(string content, string file)
+ {
+ if (File.Exists(file))
+ {
+ File.Delete(file);
+ }
+
+ string dir = Path.GetDirectoryName(file);
+ if (!Directory.Exists(dir))
+ {
+ Directory.CreateDirectory(dir);
+ }
+
+ 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;
+ }
+
+ }
+
+}