Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Assetbundle loading error

Discussion in 'Unity 5 Pre-order Beta' started by gear, Feb 12, 2015.

  1. gear

    gear

    Joined:
    May 11, 2009
    Posts:
    35
    Hello,
    I am using Unity b19, while loading one of our game bundle i am getting GameObject (named 'PfGameManager') references runtime script in scene file. Fixing! ). Any idea when we get this kind of error.

    Thanks
     
  2. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    Last edited: Feb 13, 2015
  3. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    Are you using LoadAssetAsync?

    We recently just found and fixed a bug in this.
     
  4. gear

    gear

    Joined:
    May 11, 2009
    Posts:
    35
    Yes i am using LoadAssetAsync with Unity b22.
     
  5. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    I was also using LoadAsset Async. Will this fix be in RC2?
     
  6. Roni92

    Roni92

    Joined:
    Nov 29, 2013
    Posts:
    225
    Im using loadAssetAsync, and its working just fine(RC1).
     
  7. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    I have a feeling it's to do with scripts. I was exporting ScriptableObjects from one project with matching scripts in the other project.
     
  8. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    Yes sorry, I should have been more specific.
    It has when you include an object that references a script, eg. a prefab or ScriptableObject.

    Texture and other asset type will load fine with LoadAssetAsync
     
  9. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    So I should use LoadAsset in the mean time?
     
  10. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    yes, that works fine
     
  11. gear

    gear

    Joined:
    May 11, 2009
    Posts:
    35
    changing to LoadAsset doesn't fix the issue.
     
  12. Anozireth

    Anozireth

    Joined:
    Feb 7, 2013
    Posts:
    71
    I am also getting the "GameObject (named 'leftAnchor') references runtime script in scene file. Fixing!" error. I am using using RC2 and LoadAsset<T>. I get the error several times for a fairly complex prefab, with the GameObjects referenced containing various different scripts (some more than one). This group of errors is preceded by a large group of "The referenced script on this Behaviour is missing!" errors, but when I look at the loaded prefab in the Hierarchy view, there doesn't appear to be any scripts missing.
     
  13. Anozireth

    Anozireth

    Joined:
    Feb 7, 2013
    Posts:
    71
    I'm also seeing a weird error where some scripts on objects in my startup scene seem to lose object references. For example, I initialize an object in Start(), and when I try to access it in Update(), I get a null reference exception, even through it is not set anywhere other than Start(). This particular script has nothing to do with AssetBundles, but this error only seems to happen when I enable my 5.0 AssetBundle system. It did not happen with my 4.X AssetBundle system (that is very similar).

    I'm having this issue on a few different scripts. The scripts that have this problem all seem to be on prefabs that are NOT bundled (while most are), and are either in the startup scene or loaded from /Resources with Resources.Load. They all are OK until the Update() loop fires, at which point they have lost some values.

    I know this probably isn't enough detail to get any answers, but I thought I would put this out there in case someone else is having a similar issue.
     
  14. Tim-Wiese

    Tim-Wiese

    Joined:
    Jul 7, 2012
    Posts:
    77
    I switched from LoadAsset<T> to LoadAsset().

    I was having similar issues, then I switch from LoadAsset<T> to LoadAsset() and the errors went away.

    I also noticed this in the AssetBundle Thread:

    1. "AssetBundle loading APIs changed, now we have:
      • AssetBundle.GetAllAssetNames(). Return all the asset names in the AssetBundle.
      • AssetBundle.GetAllScenePaths(). Return all the scene asset paths if it's a streamed scene AssetBundle.
      • AssetBundle.LoadAsset(). Load asset from AssetBundle.
      • AssetBundle.LoadAllAssets()
      • AssetBundle.LoadAssetWithSubAssets()
      • Asynchronous version also provided
      • We won’t return component type any more, please load the game object first and then look up the component on the object."
    So now I just always load it as a Object first then change it to a GameObject and do a GetComponent if I need to.
     
  15. Anozireth

    Anozireth

    Joined:
    Feb 7, 2013
    Posts:
    71
    Unfortunately I am already using LoadAsset() and then casting to the type I need. However, I just found that my issue was related to using AssetBundle.CreateFromFile to load the bundle. I submitted a bug (674181) with a repro, so hopefully it will get looked at.
     
  16. Keldrin

    Keldrin

    Joined:
    May 27, 2013
    Posts:
    9
    @SteenLund, Did the LoadAssetAsync fix get into RC3? I still have the issue (just using the demo code from Vincent's thread with a small tweak to download from a website).
     
  17. captain_zero

    captain_zero

    Joined:
    Mar 1, 2015
    Posts:
    6
    2015.3.1 still have the issue