Search Issue Tracker

Fixed in 5.0.1

Votes

1

Found in

5.0.0f2

Issue ID

674181

Regression

No

[AssetBundle] When loading prefab from asset bundle "GameObject references runtime script in scene file. Fixing" error is thrown

Asset Loading

-

Steps to reproduce this issue:

1. Open the attached project
2.Build AssetBundles (AssetBundles->Build AssetBundles from the menu)
3. Load the "Main" scene.
4. Press Play
5. Observe the errors logged ("GameObject ("name") references runtime script in scene file. Fixing!")

This also results in strange errors where MonoBehaviour fields that are initialized in Start() are null in Update() despite never being set anywhere but Start(). See the "How did testObject become null?" error appear in the console after entering playmode

Comments (23)

  1. 8676ce705aee2158c11162addfdae175?d=mm

    danfranklinusa

    Aug 02, 2017 21:25

    There is still a problem in 5.5.1f1 as far as I can tell.

    If a script is referenced from a prefab, and the script (class) is renamed but it keeps the same GUID, then the prefab stays unchanged, and the AssetFileHash is unchanged, but the asset bundle file itself is different!

    Since the AssetFileHash is unchanged, if you've already cached the previous asset bundle, LoadFromCacheOrDownload does not download the new bundle, and you get errors such as "The referenced script on this Behaviour is missing!".

    But you don't see this error if you haven't already cached the previous version, so it's easy to miss until final production & test.

  2. 6ae63d01339e77c185274fc5c2494f46?d=mm

    nventimiglia

    Nov 23, 2016 00:55

    Behold, I have a workaround for this issue.

    In my case I had an asset bundle with a scene, a scriptable object, and a few prefabs. The script references on the prefabs broke. The scene reference to the scriptable object was broke. I think the cause of this was a name refactor.

    My solution was to duplicate my project assets (prefabs and scriptable objects) and then reference the duplicates. (e.g. MyPrefab --> BetterMyPrefab). This fixed my asset bundle.

  3. 03067d37b7781bc80cae6b9898738468?d=mm

    Usmith

    Nov 27, 2015 02:56

    I forgot my Unity version is 5.2.2f1

  4. 03067d37b7781bc80cae6b9898738468?d=mm

    Usmith

    Nov 27, 2015 02:55

    Is this really fixed? I have a exactly same issue like in this thread:
    http://forum.unity3d.com/threads/error-fixing-reference-to-the-runtime-script-in-scene-file.325016/
    I have a base AnimatorController that attached StateMachineBehaviour scripts in some of the states, and I have OverrideAnimatorControllers that override the base AnimatorController. The base AnimationController and OverrideAnimatorControllers are separated to different bundles, that means when i load the OverrideAnimatorControllers, i load it's dependency AnimationController first. I think this work flow shouldn't has problem, and it works almost, unless it involves the animation and baked GI things. By the animator, the first time i load the gameobject that has a OverrideAnimatorController, it seems all right, but the second time, this error appears and follows an error without any info but only error:(-1)

  5. 0dab7b3708eecefc2bbf15cfc08114c2?d=mm

    lermy3d

    Aug 25, 2015 14:58

    Great news! I already test this on 5.2.0f2 and is working, I also tested to bundle several scenes in one prefab and works! So i can now have a bundle with my scenes! Finally!

    Great work Unity!

  6. 9609eb43e6ed498388feb012de0bbd19?d=mm

    sawek1

    Aug 24, 2015 10:51

    In Unity 5.1.1 I had the same problem, but it was caused by changing any normal class in abstract class... For MonoDevelop everything was right, but Unity couldn't work with it.

  7. 2baeca49f28fcbbea2e24a2796cc8e57?d=mm

    watsonsong

    Jun 29, 2015 13:20

    I known what happend here. I attach a script to a prefab of a scene, and make assetbundle for them.
    When I change the script namespace and load the asset from assetbundle, the reference from the script is missing. That correct because I am not rebuilding the assetbundle.
    But when I rebuild the assetbundle, the assetbundle file updated and changed. The CRC in manifest file is changed too. But both the asset hash and type tree hash is not changed.
    Because I am downloading the script using WWW.LoadFromCacheOrDownload, and using the assetbundle hash as the version, so the downloaing new assetbunlde is failing because the hash is not changed. And of course the script reference is still missing.

    I need clear the cache to force redownload, and everything is OK. So I think unity engine should track the script class name or namespace change, and reforce the hash code update. And even the CRC is change, why the hash is not change, what the different between them?

  8. 2baeca49f28fcbbea2e24a2796cc8e57?d=mm

    watsonsong

    Jun 24, 2015 13:23

    It still not fixed in 5.1.1p1, again and again and again...

  9. 2baeca49f28fcbbea2e24a2796cc8e57?d=mm

    watsonsong

    Jun 13, 2015 10:36

    I ask this question:
    http://forum.unity3d.com/threads/bug-the-new-assetbundle-in-5-x-can-not-keep-reference-to-script-when-it-change-name.327721/

    But I can not seem the progress of this problem, and any way can communicate with the person met the same situation.

    I really want to known how to resolve it, I am waiting more than one month.

  10. Dc33936afd9b01043a4c293a0e039a52?d=mm

    Lermy KefSensei

    Jun 04, 2015 19:11

    Hello! I'm ussing Unity 5.1.0f3 and I still have this bug. Actually, I also have a missing reference in a prefab that has an sprite that is located in the resources folder of the projects, but the wierdest thing is that I have a background that reference to an image in the same folder and the background it does load!

    Removing and setting the asset's reference and then building the bundle again, does Not solve the issue for me.

    Thanks for any advice!

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.