This commit is contained in:
CortexCore
2025-03-03 18:43:55 +08:00
parent 54f40090c9
commit 4402ae533b
32 changed files with 337 additions and 73 deletions

View File

@@ -14,20 +14,13 @@ namespace Net.Project.B.WorldNode
private void OnEnable()
{
if(Application.isEditor)return;
foreach (var staticGameObject in staticGameObjects)
{
staticGameObject.isStatic = true;
}
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic");
Execute();
Destroy(this);
}
private void Start()
{
foreach (var staticGameObject in staticGameObjects)
{
staticGameObject.isStatic = true;
}
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic");
Execute();
Destroy(this);
}
[ContextMenu("Build Index")]
@@ -36,6 +29,22 @@ namespace Net.Project.B.WorldNode
staticGameObjects = GetComponentsInChildren<Transform>().Where(x=>x.gameObject.isStatic).Select(x=>x.gameObject).ToArray();
Debug.Log($"已获取到{staticGameObjects.Length}个物体");
}
private void Execute()
{
var lost = 0;
foreach (var staticGameObject in staticGameObjects)
{
if (staticGameObject)
{
staticGameObject.isStatic = true;
continue;
}
lost++;
}
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic,丢失了:{lost}个");
}
}
}