• 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 Siewart · Oct 13, 2011 at 06:25 AM · assetbundle

Scriptname and classname do not match in assetbundle.

I have an asset using the the ColorCube script. This works fine when loaded in the scene from the editor. But when I want to load this asset from an assetbundle (built using the script found in the Unity docs) in webplayer-mode it gives the following error:

 The class defined in script file named 'ColorCube' does not match the file name!
 UnityEngine.Object:Instantiate(Object)
 <Start>c__IteratorA:MoveNext() (at Assets/Scripts/GameLogic/LoadAsset.cs:14)


LoadAsset.cs:

 using UnityEngine;
 using System.Collections;
 
     public class LoadAsset : MonoBehaviour {
             IEnumerator Start () {
                     WWW www = new WWW("file:///C:/Users/Someone/Folder 1/Folder2/
     Folder3/Folder4/Folder5/simpleColorCubes.unity3d");
                     yield return www;
                     Instantiate(www.assetBundle.mainAsset); //Line 14
         }
    }

I confirmed that the script's main class that was compiled in the assetbundle (and inherits MonoBehaviour) also has the same name 'ColorCube'.

Does anyone have any idea what I could have done wrong?

Unity Pro 3.4.1f5 - Win7 64x - Webplayer mode

Comment
Add comment · Show 3
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 Siewart · Oct 13, 2011 at 10:11 AM 0
Share

I think I should add that it gives this error not just with the ColorCube script, but with all scripts that I have tested so far.

avatar image Bunny83 · Oct 14, 2011 at 11:45 AM 0
Share

What exactly did you include in the assetbundle? A prefab that has this script attached or only the script? A script can only be instantiated when it's attached to a gameobject. Yet i didn't used assetBundles but as long as you pack prefabs into the bundle you should be ok.

avatar image Siewart · Oct 18, 2011 at 03:23 PM 0
Share

I have a prefab with all scripts attached to it, the scripts themselves are packed inside the same asset bundle.

2 Replies

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

Answer by Siewart · Nov 04, 2011 at 03:23 PM

I re-imported everything into a new Unity Project and now it works.

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 syclamoth · Nov 04, 2011 at 03:28 PM 0
Share

Like magic. Unfortunately, for big projects this isn't really an option...

avatar image Siewart · Nov 04, 2011 at 03:30 PM 0
Share

Nope, it took me a whole night... Also I didn't re-import everything, because I need to merge another project into it later, that contains the same assets.

avatar image
0

Answer by chemicalvamp · Oct 13, 2011 at 10:32 AM

Did you by chance rename the AssetBundle.cs and if so did it used to be named LoadAsset.cs, cuz if you did you need to change the class name "LoadAsset" in the file to match the filename.

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 Siewart · Oct 13, 2011 at 12:03 PM 0
Share

Oh sorry, my mistake. (But the name problem lies in that the file ColorCube.cs, and not in the LoadAsset.cs script) Thanks though :) (Updated the question)

avatar image chemicalvamp · Oct 13, 2011 at 04:50 PM 0
Share

And that class name matches its filename.cs as well?

avatar image Siewart · Oct 14, 2011 at 11:26 AM 0
Share

I am afraid does :(

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to import the object from server to unity 2 Answers

AssetDatabase.LoadAllAssetsAtPath(...) Yields Mysterious Nameless Asset 1 Answer

DontDestroyOnLoad() assetbundle 1 Answer

Streaming Tutorial anywhere? 2 Answers

Runtime loaded assemblies 1 Answer


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