Building asset bundles and wanting to move game objects from one parent to a newly created parent

As part of a build process I am trying to separate parts of a max model into separate asset bundles.

I have a GameObject that has lots of children that are game objects lets say 20+, i want to take 4 of those child GameObjects detach them from there shared Parent and Parent them to a new GameObject that i have just created.

Ive tried just assigning the objects parent to a new object but this fails at runtime as its read only.

instance.m_gameObj.transform.parent.gameObject = newGO;

So i think i need to either make a copy of the child and add it is as a new component to my new GameObject.

And possibly even destroy the original parent object, but im worried that will destroy all the other child objects i want to copy over as well as there still attached to it.

* Update *

What ive tried since posting.

  1. Use EditorUtility.InstantiatePrefab to create clones of the 4 game objects i want
  2. Then use UnityEngine.Object.DestroyImmediate to destroy each game objects parent
  3. Then create a new dummy game object like this - `GameObject newGO = new GameObject("MainAsset");`
  4. Then make the parent of my 4 game objects the new dummy game object `m_gameObj.transform.parent = newGO.transform;`
  5. Then build the asset bundle of the new GameObject - `bool buildOk = BuildPipeline.BuildAssetBundle(newGO, null, bundleTarget, BuildAssetBundleOptions.CollectDependencies);`
  6. But still no luck even tho there is no crashes or warnings the BuildAssetBundle returns false, and im still trying to work out what part of this its not liking.

Does anyone have any ideas for this?

I cannot see from the information provided what is wrong, however, we created a relatively complex project that uses asset bundles extensively to show how to effectively use assetbundles in a real world scenario. (It also takes a fbx file, and creates different assetbundles from different subsets of the fbx file). You can find it at: