flywlyx Posted August 19, 2020 Share Posted August 19, 2020 (edited) I am trying to add a model to a gameobject A, my plan is to create a new gameobject B with the model and attach B to A as child. But the KSPparticleemitter in B could not be got by GetComponentInChildren<KSPParticleEmitter>() after attachment. GameObject DebObj = GameDatabase.Instance.GetModel(SunbeamFXPath); KSPParticleEmitter pe = DebObj.GetComponentInChildren<KSPParticleEmitter>(); Debug.Log("<color=green>[RayMonitor] </color>Deb PE = "+ pe.name);//This log will return the name DebObj.transform.SetParent(RayObj.transform); KSPParticleEmitter rpe = RayObj.GetComponentInChildren<KSPParticleEmitter>(); Debug.Log("<color=green>[RayMonitor] </color>Ray PE = " + rpe.name);//This log will return NRE Is there better solutions? Edited August 19, 2020 by flywlyx Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.