blob: b4de592b1fe728d4413c85fbce91d4a02c385c02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
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
{
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;
}
}
|