I'm curious about the following line of code, I've had some users report their game crashing inconsistently. The output_log shows the game crashes around the following snipped of code (though I can't quite yet be 100% sure).
My question is, is Unity known for having issues with gameObject.GetComponents.()? This code is reused on all items that can be picked up in game. So depending on the item, it could be built using a single box collider, or a single mesh collider or multiple box colliders. Could this cause the game to crash? Has anyone had issue with this before?
Many thanks.
Written in Unity's Javascript.
var myColliders: BoxCollider[] = gameObject.GetComponents.();
for (var bc : BoxCollider in myColliders)
{
bc.isTrigger = true;
}
var myMeshColliders: MeshCollider[] = gameObject.GetComponents.();
for (var bc2 : MeshCollider in myMeshColliders)
{
bc2.isTrigger = true;
}
↧