x


Missing reference to Texture2D after loading prefab from AssetBundle

This problem occurs when loading a prefab dynamically, that was previously exported as an AssetBundle.

Scene setup:

  • There is one scene containing the instance of a single prefab.
  • The prefab contains a cube rendered using a material referencing texture A.
  • The prefab also has a MonoBehaviour attached to it, referencing the same texture A in the inspector.

public class MyScript : MonoBehaviour { public Texture2D A;

void OnGUI()
{
    if (a)
        GUI.Label(new Rect(0, 0, 50, 50), A);
    else
        GUI.Label(new Rect(0, 0, 100, 50), "missing reference");
}

}

I export the scene and the AssetBundle as a WebPlayer build, all according to the usual practices. In fact the loading of the prefab and rendering the cube with texture A works fine!

Here comes the problem: The reference of texture A in the MonoBehaviour script is still missing, even though the same asset is used to render the cube inside of the prefab. This means the asset is loaded in memory, but for some reason the inspector reference is broken.

I can provide a simple test scene to replicate this. Sounds like a bug to me, but would appreciate feedback :)

Cheers, Tommy

more ▼

asked Sep 22 '11 at 09:31 AM

Tommynator gravatar image

Tommynator
381 3 4 11

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x466
x382
x354
x263
x15

asked: Sep 22 '11 at 09:31 AM

Seen: 823 times

Last Updated: Sep 23 '11 at 02:33 AM