Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by MisterGasman · Jun 19, 2013 at 09:49 AM · assetbundleassetloadfromcacheordownload

AssetBundles, not working ... "not been added to the build settings"

Hi guys,

i'm pretty new to unity. I have a few big landscape scenes (all in different projects) i'd like to load these dynamically in one unity game (pc/mac). I created seperate assetBundles from them.

So in my first landscape scene when u enter a door, it loads another scene. The script in the bottom is attached to that door. When i run it it gives the error: "Level: 'Ename_test.unity' (-1) couldn't be loaded because it had not been added to the build settings."

I've been looking on this forum for hours, but nothing solved this, although a lot of the same topics :/ Anyone knows a solution? thanks!

code:

 using System;
 using UnityEngine;
 using System.Collections;
 
 public class CachingLoadExample : MonoBehaviour {
     public string BundleURL;
     public string AssetName;
     public int version;
 
     void OnTriggerEnter(Collider other)
     {
         StartCoroutine (DownloadAndCache());
     }
 
     IEnumerator DownloadAndCache (){
         // Wait for the Caching system to be ready
         while (!Caching.ready)
             yield return null;
 
         // 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)){
             yield return www;
             
             if (www.error != null)
                 throw new Exception("WWW download had an error:" + www.error);
             AssetBundle bundle = www.assetBundle;
             bundle.LoadAll();

             Application.LoadLevel(AssetName);
         }
     }
 }
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 whydoidoit · Jun 19, 2013 at 10:26 AM 0
Share

And how do you create the bundle?

avatar image MisterGasman · Jun 19, 2013 at 05:33 PM 0
Share

I put the complete scene in a bundle via:

 using UnityEngine;
 using UnityEditor;
 
 public class ExportSceneAssetBundle {
 
     [$$anonymous$$enuItem("Assets/Build SceneAssetBundle (full scene export)")]
     static void ExportResourceNoTrack () {
        
         // Bring up load panel
         string[] level = new string[]{EditorUtility.OpenFilePanel("Load scene", "", "unity")};
         
        
         if (level.Length != 0) {
             // Bring up save panel
             string export = EditorUtility.SaveFilePanel("Save scene Asset", "", "scene Asset", "unity3D");
             
             if (export.Length != 0) {
                 //build assetBundle from scene
                 BuildPipeline.BuildStreamedSceneAssetBundle(level, export, BuildTarget.StandaloneWindows64);
             }
         }
     }
 }

The game loads the assetBundle (seems to), but when i use the loadLevel function it gives an error...

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by whydoidoit · Jun 20, 2013 at 12:51 AM

Ok so with a stream scene asset bundle you don't do bundle.LoadAll - you just take the reference to it from the WWW.

Secondly you need to open the scene with its name - not it's file name, just the scene name part of it (like you would if it was added to the build).

Comment
Add comment · Show 2 · 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 MisterGasman · Jun 20, 2013 at 09:14 AM 0
Share

Ok thanks sir! It seems to work now. The scene from another project loads fine.

Now the problem is when the first scene loads again it got the following error:

"Exception: WWW download had an error:Cannot load cached AssetBundle. A file of the same name is already loaded from another AssetBundle."

When i add this "bundle.Unload(false);" under the LoadLevel the second scene is complete black, no polys or textures, nothing...

$$anonymous$$gestions? I search meanwhile on the forum

thanks

avatar image whydoidoit · Jun 20, 2013 at 02:13 PM 0
Share

Yeah you only have to do it once and keep a reference to the bundle

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.

Follow this Question

Answers Answers and Comments

15 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 avatar image avatar image

Related Questions

Memory Locking While Loading Issue 0 Answers

Assets Bundle... in Pro? 2 Answers

Accessing an already loaded Asset Bundle 1 Answer

WWW::Dispose doesn't work 1 Answer

How to download multiple asset bundles in serial order? The error of "cant load 'name' assetbundle as it is already loaded" comes after first assetbundle download. Please help. Needed urgently! 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges