依赖倒转原则
高层模块不依赖底层模块,都依赖于接口
抽象不依赖于细节,细节依赖于抽象
针对接口编程,不针对实现编程
依赖倒转原则
高层模块不依赖底层模块,都依赖于接口
抽象不依赖于细节,细节依赖于抽象
针对接口编程,不针对实现编程
设计原则
单一职责
开闭原则
对扩展开放
对修改关闭
只需要把assets目录下的内容拷贝到unity就行了
测试
页面的关闭遇到大型的建议直接Destroy,以提高性能,需将UI框架稍作修改,地方比较零散就不贴码了。
//创建物体的3种方式
public GameObject prefab;
void Start () {
GameObject go = new GameObject("cube");
GameObject.Instantiate(prefab);
GameObject.CreatePrimitive(PrimitiveType.Capsule);
}
//测试方法的性能用的
public int count = 10000000;
void Start()
{
float time1 = Time.realtimeSinceStartup;
for (int i = 0; i < count; i++)
{
Method1();
}
float time2 = Time.realtimeSinceStartup;
Debug.Log(time2-time1);
float time3 = Time.realtimeSinceStartup;
for (int i = 0; i < count; i++)
{
Method2();
}
float time4 = Time.realtimeSinceStartup;
Debug.Log(time4-time3);
}