返回「计算机、信息技术与工程」
研究Unity引擎的技巧
本文目录 1 个章节
研究Unity引擎的技巧
创建时间:2020/6/4 11:12
参考: https://www.xuanyusong.com/archives/4263(获取资源内存和硬盘大小)
Unity Editor实现的一些功能,调用了Editor本身的一些函数。这些函数可能没有作为API提供出来。如果想要调用,可以看Editor的源码:用dnSpy反编译一下,找到相关的代码与函数。 然后利用反射,根据函数名调用相应函数。
此外,该方法提供了一个思路:想要深入理解UnityEditor的实现,就多看看Editor的包文件,反编译看看源码。一个是顺藤摸瓜,看相应功能的实现。一个是看包的整体结构组织,了解各个模块的功能以及实现,理解模块之间的关系。 d 一个小工具(用来调用内部函数):
class Program
{
static void Main(string[] args)
{
dynamic dyn = 1;
object obj = 1;
dyn = dyn + 3;
//obj = obj + 3; 报错
// Rest the mouse pointer over dyn and obj to see their
// types at compile time.
System.Console.WriteLine(dyn.GetType());
System.Console.WriteLine(obj.GetType());
}
}
class Program
{
static void Main(string[] args)
{
dynamic dyn = 1;
object obj = 1;
dyn = dyn + 3;
//obj = obj + 3; 报错
// Rest the mouse pointer over dyn and obj to see their
// types at compile time.
System.Console.WriteLine(dyn.GetType());
System.Console.WriteLine(obj.GetType());
}
}
监听Unity编辑器关闭的事件
class Program
{
static void Main(string[] args)
{
dynamic dyn = 1;
object obj = 1;
dyn = dyn + 3;
//obj = obj + 3; 报错
// Rest the mouse pointer over dyn and obj to see their
// types at compile time.
System.Console.WriteLine(dyn.GetType());
System.Console.WriteLine(obj.GetType());
}
}