我刚刚接触到统一和c#脚本语言......我只是想在团结中做出一些东西并且正在使用2DDL来点亮我遇到的问题是每当我点击玩和测试游戏时灯光跟随游戏对象是正确的,但过了一段时间它会卡在任何随机点......你可以查看屏幕截图中的完整错误细节。
2DLight脚本
void Update(){
getAllMeshes();
setLight ();
renderLightMesh ();
resetBounds ();
}
void getAllMeshes(){
//allMeshes = FindObjectsOfType(typeof(PolygonCollider2D)) as PolygonCollider2D[];
Collider2D [] allColl2D = Physics2D.OverlapCircleAll(transform.position, lightRadius, layer);
allMeshes = new PolygonCollider2D[allColl2D.Length];
for (int i=0; i<allColl2D.Length; i++) {
allMeshes[i] = (PolygonCollider2D)allColl2D[i];
}
}
void resetBounds(){
Bounds b = lightMesh.bounds;
b.center = Vector3.zero;
lightMesh.bounds = b;
}