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