1.突然想到load数据之后用用反射的方法初始化一系列物体。反射,果然程序员的快乐。
Assembly ass=Assembly.GetExecutingAssembly();
Object obj=ass.CreateInstance(objName);
或
(调用静态方法)
System.Type tx = typeof(“类名”);
MethodInfo mf = tx.GetMethod(methodName);
string saf = (string)mf.Invoke(null, null);
2.想判断某个GameObject是否含有component script为“AAA"的组件。在C#的help里面绕了一大圈,反射啊,type,typeof都不符合我的要求。记得原来用过通过string找组件的方法,还是去翻了翻unity的document,用
function GetComponent (type : String) : Component
就好啦。唉,费半天劲。