x


Problem with assetbundled scripts in scenes loaded via Application.LoadLevel

I created simple Unity application that allows to load different scenes downloaded from internet. It works great if a scene doesn't contain any scripts. If there is a script connected with GameObject it fails with the error:

The class defined in script file named 'XXX' does not match the file name!

If that scene is started as separate application script works without any problem, but if that scene is saved via BuildPipeline.BuildStreamedSceneAssetBundle I've got described error.

I load scenes via simple code:

    WWW www = new WWW("file://" + file);
    yield return www;

    loadedBundle = www.assetBundle;
    Application.LoadLevel(name);

The main script stays in scene, because I call DontDestroyOnLoad for it.

I checked this scenaria via Unity3D 3.5.0 and 3.5.1

Where I do a mistake?

Thanks a lot.

more ▼

asked Apr 27 '12 at 10:35 PM

der_wolf gravatar image

der_wolf
32 2 2 3

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Scripts are not being included in asset bundles due to security reasons. References to scripts are, however.

If you built your scene bundle from the same project as your scripts exists in, then it should work. If you built the asset bundles in a separate project, those scripts can't be referenced and as a result it is expected not to work.

If you create your asset bundles from the main project that the scripts reside in, and that you load the asset bundles from and this fail, please consider submitting a bug report.

more ▼

answered Apr 28 '12 at 12:52 AM

Statement gravatar image

Statement ♦♦
20.1k 35 70 175

Then one more question: is this possible to include TextAsset to scene? I can't find a way how to do this. Thanks

Apr 28 '12 at 03:10 PM der_wolf

I don't understand the wording in the answer. Are you saying that in order for the streamed asset bundle to work correctly the original scene and all scripts referenced in that scene have to be created from the base project?... which for me defies the point I'm wanting to load in scenes from separate projects. Also could this be solved by importing the scripts into the base project?

Feb 16 at 12:49 PM Caiuse
(comments are locked)
10|3000 characters needed characters left

Check here for help on Storing and loading binary data in an AssetBundle

more ▼

answered Sep 03 '12 at 11:10 AM

appearance gravatar image

appearance
401 2 4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x381

asked: Apr 27 '12 at 10:35 PM

Seen: 802 times

Last Updated: Feb 16 at 12:49 PM