I have created a simple asset bundle:
http://tagenigma.com/qa/Unity3d/AssetBundleTester/UpdateGUITextPrefab.unity3d
- Contains a Prefab
- Contains a GUIText Object
- Contains a Script attached to the GUIText Object that changes the text of the GUIText Object in the OnEnable event
I have an asset bundle loader test project:
http://tagenigma.com/qa/Unity3d/AssetBundleTester/AssetBundleTester.html
When the asset bundle loads the GUIText does not update.
I have to conclude that scripts don’t actually make it to the asset bundle in any form.
Is this correct?
I found that if I already have “UpdateGUITextScript” script in my project when the asset bundle is loaded, the GUIText’s script will reference the script in my project folder. However, the reference to the GUIText is missing. I think the MonoScripts in the AssetBundles are just references back to your scene and project files. Apparently, you need your source assets and scene that you used to create the asset bundle for the references to work properly.
UnassignedReferenceException: The variable m_guiText of 'UpdateGUITextScript' has not been assigned. This happened in the game object "UpdateGUITextPrefab".
You probably need to select the "UpdateGUITextPrefab" in the hierarchy and assign the m_guiText variable of the UpdateGUITextScript script in the inspector.
UpdateGUITextScript.OnEnable () (at Assets\UpdateGUITextScript.cs:11)
UnityEngine.Object:Internal_CloneSingle(Object)
UnityEngine.Object:Internal_CloneSingle(Object)
UnityEngine.Object:Instantiate(Object) (at C:\builds\unity-trunk\unity\Runtime\Export\Generated\BaseClass.cs:59)
AssetBundleDownloader:OnGUI() (at Assets\AssetBundleDownloader.cs:78)
(Filename: Assets/UpdateGUITextScript.cs Line: 11)
Mono: successfully reloaded assembly
Reload assembly time: 0.271655
UnassignedReferenceException: The variable m_guiText of 'UpdateGUITextScript' has not been assigned. This happened in the game object "UpdateGUITextPrefab".
You probably need to select the "UpdateGUITextPrefab" in the hierarchy and assign the m_guiText variable of the UpdateGUITextScript script in the inspector.
UpdateGUITextScript.OnEnable () (at Assets\UpdateGUITextScript.cs:11)
UnityEngine.Object:Internal_CloneSingle(Object)
UnityEngine.Object:Internal_CloneSingle(Object)
UnityEngine.Object:Instantiate(Object) (at C:\builds\unity-trunk\unity\Runtime\Export\Generated\BaseClass.cs:59)
AssetBundleDownloader:OnGUI() (at Assets\AssetBundleDownloader.cs:78)
(Filename: Assets/UpdateGUITextScript.cs Line: 11)
141728–5183–$updateguitextscript_413.cs (237 Bytes)