- Home /
Load Scene from Asset Bundle, lose gameObject Hierarchy order?
Hi guys, I create an asset bundle from my scene in Unity 5 and I try to load it from www.
using UnityEditor;
public class CreateAssetBundles
{
[MenuItem("Assets/Build AssetBundles")]
static void BuildAllAssetBundles()
{
BuildPipeline.BuildAssetBundles("AssetBundles", 0, EditorUserBuildSettings.activeBuildTarget);
}
}
I load the scene by this code
IEnumerator DownloadAndCacheScene()
{
// Wait for the Caching system to be ready
while (!Caching.ready)
yield return null;
Debug.Log("start load");
// Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
using (WWW www = WWW.LoadFromCacheOrDownload(BundleURL, version))
{
StartCoroutine(UpdateProgress(www));
yield return www;
Debug.Log("get www");
if (www.error != null)
throw new Exception("WWW download had an error:" + www.error);
AssetBundle bundle = www.assetBundle;
bundle.LoadAllAssets();
Application.LoadLevel(SceneName);
Debug.Log("instant asset");
// Unload the AssetBundles compressed contents to conserve memory
bundle.Unload(false);
} // memory is freed from the web stream (www.Dispose() gets called implicitly)
}
The scene was loaded well but the only problem is the order of gameObject in Hierarchy is not right.
The parent-child order is right but the child-sibling order is not right.
Some help would be appreciated. Thanks.
I am having the escat same weird issue. just cannot find a way around it. Have you discovered anything new?
I temporary handle it with transform set sibling api.
To add to the severity of this issue - It seems that the order of children deter$$anonymous$$es draw order in uGUI's screen overlay mode. When the order of children is not preserved - very bad things happen. Just ran into this today as we attempted to load bundles that have uGUI screen overlays.
Your answer