1
This commit is contained in:
@@ -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}个");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user