• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Ab00 · Nov 19, 2012 at 03:07 AM · sceneunity4load levelasset bundle

Loading scene from asset bundle fails in Unity 4

I used to load a level (scene) from a bundle after I it is downloaded in Unity 3. Same code fails to run in Unity 4 throwing an exception saying that :

Level 'name of my scene' (-1) couldn't be loaded because it has not been added to the build settings. To add a level to the build settings use the menu File->Build Settings...

Here is a code I am using:

 ...
 stream = new WWW(url));
 yield return stream;
 stream.assetBundle.LoadAll();
 Application.LoadLevel(levelName);
 ...

Even the Unity's sample project generates the same exception and doesn't work.

Please note that the scene is not available in the starter package and has to be loaded from a bundle.

Any idea?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kryptos · Nov 19, 2012 at 02:08 PM 0
Share

$$anonymous$$y guess is you should rebuild the bundle. I don't think that 3.x-bundles are loadable with Unity 4.x.

avatar image Ab00 · Nov 19, 2012 at 10:49 PM 0
Share

I did that but it didn't work. Actually with 3.x bundle there was another error after I rebuilt it with 4 the I got the above error message.

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Ab00 · Nov 20, 2012 at 04:05 AM

The problem was that in Unity 4 when you want to load a level (scene) the name is case-sensitive. In Unity 3 this was not case-sensitive.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kryptos · Nov 20, 2012 at 08:23 AM 0
Share

As far as I know, every string-based method has been case-sensitive in Unity for ages.

avatar image Ab00 · Nov 20, 2012 at 08:41 AM 0
Share

Well, I have to downgrade and test it again in unity 3.x to be 100% sure but as far as I look at my codes from before I used call ToLower() before loading the level and it used to work.

avatar image vikram Jadhav · Dec 22, 2013 at 02:02 PM 1
Share

Thanks!

I was having the same issue. As soon as I started using the case-sensitive name it worked. Note that, the issue wasn't really apparent as loading scene without asset bundle doesn't require case-sensitive scene name.

avatar image
-1

Answer by Baastax · Nov 19, 2012 at 12:14 PM

You can't use Application.LoadLevel to load assets in asset bundles.

Instead you should call Instantiate(stream.assetBundle.mainAsset);

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ab00 · Nov 19, 2012 at 10:50 PM 0
Share

I am not instantiating an object. What I want to do is loading a scene which is inside a bundle.

avatar image Kryptos · Nov 20, 2012 at 08:24 AM 0
Share

@Baastax you can load scenes that are inside bundles.

avatar image cowlinator · May 08, 2013 at 05:22 PM 0
Share

This is incorrect. stream.assetBundle.mainAsset is always null for a streamed scene assetBundle.

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why am I losing all scene data when loading an Asset Bundle-loaded scene? 0 Answers

How do i say, if ball is -5 and scene is "MainGame1", go to scene GameOver1 ??? 1 Answer

How can I stop my editor from crashing everytime it loads a new Scene during runtime? (since Unity 4) 2 Answers

dynamic prefabs in streamed scene asset bundle 1 Answer

2D Character Movement 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges