Asset Bundle Scene Loading Bug????
I have two simple projects, one that builds an asset bundle with a scene trough this script
using UnityEngine;
using System.Collections;
using UnityEditor;
public class AssetBundleBuilder : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
[MenuItem("Menu/Export package")]
public static void Export()
{
AssetBundleBuild build = new AssetBundleBuild();
build.assetNames = new[] {"Assets\\" + "mainScene.unity"};
build.assetBundleName = "test";
BuildPipeline.BuildAssetBundles(Application.dataPath, new[] { build }, BuildAssetBundleOptions.None,
BuildTarget.StandaloneWindows);
}
}
and another, on the other project, that's supposed to load it:
using System;
using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
public class ImportAssetBundle : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
[MenuItem("Menu/Import package")]
public static void ImportPackage()
{
var bundl = AssetBundle.LoadFromFile(EditorUtility.OpenFilePanel("", "", ""));
try
{
//SceneManager.LoadScene("mainScene");
//bundl.GetAllScenePaths();
foreach (var sce in bundl.GetAllScenePaths())
{
Debug.Log(sce);
}
//bundl.LoadAllAssets();
//Application.LoadLevel("Assets/mainScene.unity");
EditorSceneManager.OpenScene("Assets/mainScene.unity");
}
finally
{
bundl.Unload(true);
}
}
}
if i import this on Editor, with the line bundl.LoadAllAssets() uncommented I get the exception at that specific line:
and if I do it with that line commented (suggested here https://forum.unity3d.com/threads/5-3-5p6-bug-loading-scenes-from-asset-bundle.414621/) I get this error instead:
On runtime, the error with that line uncommented is the same, but with it commented I get this: "Scene 'Assets/mainScene.unity' (-1) couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded." - and
"AssetBundle has not been loaded" <-- what exactly does Unity mean by this, my code has found the bundle and can see what's inside it, I listed it and found the asset (scene) I was looking for I've also change the name being loaded to just "mainScene.unity" and "mainScene" and nothing changes.
What I want to do is: Make a scene on a unity project and load it on a run it on another Unity3d app, it may or may not come with scripts but that's a talk for another time. I've tried asset bundles because it seemed the most adequate way but this bug is being really annoying, is this a bug? if so, is there a fix? and if it is not a bug please correct me.
AssetBundle manifest:
ManifestFileVersion: 0
CRC: 1309189354
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: 1b0a0d23e505bd1cabeda6fb6d8ad706
TypeTreeHash:
serializedVersion: 2
Hash: 47a7ad651cdb1fc19a4f0400c76144ba
HashAppended: 0
ClassTypes:
- Class: 1
Script: {instanceID: 0}
- Class: 4
Script: {instanceID: 0}
- Class: 20
Script: {instanceID: 0}
- Class: 21
Script: {instanceID: 0}
- Class: 23
Script: {instanceID: 0}
- Class: 28
Script: {instanceID: 0}
- Class: 33
Script: {instanceID: 0}
- Class: 43
Script: {instanceID: 0}
- Class: 48
Script: {instanceID: 0}
- Class: 65
Script: {instanceID: 0}
- Class: 81
Script: {instanceID: 0}
- Class: 89
Script: {instanceID: 0}
- Class: 92
Script: {instanceID: 0}
- Class: 104
Script: {instanceID: 0}
- Class: 108
Script: {instanceID: 0}
- Class: 114
Script: {fileID: -943895431, guid: bf4fa8de1287ded4aac863efb70b55ee, type: 3}
- Class: 115
Script: {instanceID: 0}
- Class: 124
Script: {instanceID: 0}
- Class: 157
Script: {instanceID: 0}
- Class: 258
Script: {instanceID: 0}
Assets:
- Assets/mainScene.unity
Dependencies: []
Thank you.
Your answer
![](https://koobas.hobune.stream/wayback/20220612111611im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Variable Scene Loader 0 Answers
Switch scene on collsion C# 1 Answer
Fade out / fade in scene w/ loading screen 0 Answers
Unexpected symbol error ? 1 Answer
Why isn't my mobile single joystick showing on screen, PLEASE HELP? 1 Answer