Question by
samDawg · Feb 16, 2019 at 11:59 AM ·
meshvrchild objectcomponentsmeshfilter
GetComponentsInChildren only works sometimes
I am using SteamVR and VRTK at the moment. I'm trying to swap out the default steamVR controller with VRTK, the way it works is steamVR loads the model externally at runtime. So I added a script to the steamVR model prefab to find all the meshFilter in children and null the mesh on Start. But this only works sometimes and not everytime. I can't think of why, can someone please help?
public class DisableControllerMeshRenderer : MonoBehaviour {
MeshFilter[] ControllerMeshFilterComponents;
void Start () {
MeshFilter[] Components = GetComponentsInChildren<MeshFilter>(true);
ControllerMeshFilterComponents = Components;
foreach (MeshFilter component in ControllerMeshFilterComponents )
{
component.mesh = null;
}
}
}
Comment