cancel
Showing results for 
Search instead for 
Did you mean: 

Adding colliders by List Loop - after load - would that decrease load time significantly?

ShardNZL
Level 3
Just a general Unity knowledge query....
I have scenes with 50-60 mesh/box colliders in them. In some scenarios I don't need them so I thought why not make a list of GameObjects that use them and then on scene load check to see if they're needed and apply one per frame. I believe that if you turn them off in the editor and on by script that Unity recreates them form scratch anyway?
Would this significantly reduce load time since it'll only be loading geometry/lighting etc - and 60 colliders per second shouldn't slow down the page load??
3 REPLIES 3

bkj
Level 5
On mobile most time is spent loading big textures.

ShardNZL
Level 3
hmmmm - any insights into why this isn't working?? .....
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
....
public BoxCollider bc;
public List<GameObject> BoxColliders = new List<GameObject>();
....
void Start () {
StartCoroutine(drawBoxes());
}

public IEnumerator drawBoxes(){
foreach(GameObject data in BoxColliders){
bc = data.AddComponent<BoxCollider>();
yield return new WaitForEndOfFrame();
}
}







PAalto
Level 5
That code snippet does not show where you add items to the BoxColliders list? I assume you do that somewhere.. 🙂
Working on LineWars VR: http://linewars.patrickaalto.com/LWVR.html