- Home /
Question by
xiewneqi · May 09, 2014 at 10:02 AM ·
prefabassetbundle
Re-load prefabs from assetbundles got null components
Hi, I find a strange behaviour of Unity when re-loading prefab from assetbundle. Say I have a assetbundle A, which contains a prefab with a BoxCollider and a CharacterController attached. Then I execute following codes:
GameObject m_prefab = A.Load ("prefab") as GameObject;
Collider collider = m_prefab.GetComponent<BoxCollider> ();
Debug.Log (collider);
CharacterController cc = m_prefab.GetComponent<CharacterController> ();
Debug.Log (cc);
GameObject.DestroyImmediate (m_prefab, true);
Then I repeat above codes in somewhere else, but it turns out that BoxCollider and CharacterController are all missing in the re-loaded prefab, while the first loaded one is correct.
WHY?
Comment
Your answer
Follow this Question
Related Questions
Add Asset Bundle Name to a prefab in "Editor Code" 1 Answer
Nested Prefabs in Asset Bundle 1 Answer
why does the error "Deleting persistent object without writing it first" occurs ? 4 Answers
Problems importing an asset bundle 1 Answer
Asset Bundle Prefabs missing textures & materials, but have geometry 1 Answer