I have a Unity WebGL app that is using the AssetBundle Manager to load a prefab. It's successfully loading the prefab and associated animations, but I can't reference the script attached to the prefab. I'm not trying to include the script in the asset bundle - it's in the base application. I have code stripping disabled.
What's really confusing me is that my code able to reference it while running in the editor, but not when it's running in the browser.
My prefab is structured like this:
- Container GameObject
- 3D Text
MyScript is defined like this:
public class MyScript : MonoBehaviour {
public TextMesh Text;
}
My code where I try to access the script:
var container = Instantiate (prefab);
var script = container.GetComponent<MyScript> ();
The Container GameObject has a script component. The script references the 3D Text via a public property. When the prefab is instantiated while in the browser, the 3D Text object renders correctly, but script
is null.
Is there something I'm doing wrong, or is it just not possible to do this in the WebGL player?