Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Asset Bundles problem with scripts since 5.6.2

Discussion in 'Asset Bundles' started by Tuni, Jul 12, 2017.

  1. Tuni

    Tuni

    Joined:
    May 24, 2013
    Posts:
    74
    I posted already in the General support forum, but I think this is a better place for this problem. Sorry for reposting.

    We are using Asset Bundles since Unity 5.2. We have a custom build pipeline (NOT the Unity provided tools from bitbucket or the browser tool from the asset store) in place which was working fine until we switched from 5.6.1 to Unity 2017.1 yesterday (or 5.6.2 today - same problem). We changed nothing in our asset bundle codebase.

    Scriptable object assets and prefabs with scripts are a problem because Unity couldn't find the scripts when loaded from an asset bundle. We get messages like "The referenced script on this Behaviour is missing!" or "The file 'none' is corrupted! Remove it and launch unity again!".

    The assets are fine in the editor. It's just a problem if we put the assets in asset bundles. The files are in the asset bundles if you look at the manifest file.

    Our workaround is to go back to Unity 5.6.1 for now.

    Has anyone else similar problems and maybe a solution?

    Greetings

    Tuni
     
  2. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Hey @Tuni
    It's a known bug that we just recently fixed. It should be fixed in 2017.1f3 so make sure your 2017.1 install is fully up to date. If you are still getting that issue, please submit a bug report with a repro project.
     
    Leoo likes this.
  3. Tuni

    Tuni

    Joined:
    May 24, 2013
    Posts:
    74
    We tried 2017.1. Clean install, deleted the Library folder and reimported the whole project again. Same bug.

    I'm gonna try to create a sample project for a bug report because our current project is way too big to upload.
     
  4. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Ok, so there is one more issue I've seen recently that produces the same error msg. That is if you have a Prefab with a reference to a child object of another Prefab. For example prefab layout would look like this:

    Prefab 1 w/ MonoBehavior
    Child 1

    Prefab 2 w/ MonoBehavior that has an object reference to Child 1

    This issue though we don't have a fix just yet for it however are working to resolve it.
     
    Leoo likes this.
  5. Tuni

    Tuni

    Joined:
    May 24, 2013
    Posts:
    74
    I found another issue and a workaround for us. We load scriptable objects (will call it SO from here on) with LoadAllAssets(). This creates the same warning / error messages. LoadAsset() doesn't work correctly after this (at least for short period of time).

    I uploaded a very basic project with 2017.1f3. Case 930819. This project contains a simple script which loads a SO and a prefab from an asset bundle in the StreamingAssets folder.

    Our workaround: We created a SO which only holds an array with references to all the other SO and load this with LoadAsset() instead all SO with LoadAllAssets().
     
    Last edited: Jul 13, 2017
    rajantande likes this.
  6. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Thanks for the case number, I'll take a look at this shortly
     
    Leoo likes this.
  7. Tuni

    Tuni

    Joined:
    May 24, 2013
    Posts:
    74
    The Unity QA team has reproduced the bug.
     
    Leoo likes this.
  8. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Hey Tuni,
    I've got a fix for that case you submitted going through the PR process now. Great repro steps and project, made is super easy to track down. Thanks!
     
    Leoo likes this.
  9. Leoo

    Leoo

    Joined:
    May 13, 2013
    Posts:
    96
    Pretty happy you guys are fast working into the issue, i was about to recreate all my pipeline thinking i changed something before upgrading. This need to be patched ASAP, it is game-dev stopping for me.
     
  10. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Ok, so the fix has gone through PR and been merged into 2017.3.0a4, and 2017.2.0b7. It's currently going through the merge process for 2017.1; it should be in 2017.1.0p4 if nothing critical happens. As for 5.5 & 5.6, I'm still in queue waiting, so won't know more until it gets past approval.
     
    Leoo likes this.
  11. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Got final approval. So fix will be in 5.6.3p1 and 5.5.4p3
     
    Leoo likes this.
  12. Leoo

    Leoo

    Joined:
    May 13, 2013
    Posts:
    96
    @Ryanc_unity Thank you ryan! Nice work! One question tho, do you happend to know how long do we have to wait till we get the fix on 2017.1 ?
     
  13. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    @Leoo
    I don't have an exact eta for the 2017.1.0p4 release. Typically patches come out weekly to bi-weekly for the most recent Unity release and the latest path release (2017.1.0p2) was on 7/27.
     
  14. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Alright, the fix has been approved for the last two versions: 5.5.4p3 & 5.6.3p1.
     
  15. Leoo

    Leoo

    Joined:
    May 13, 2013
    Posts:
    96
    I can confirm this has been fixed on 2017.2.0b7.

    Thank you!
     
  16. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    Well, I found the new path version updated for 5.6.3p1
    But the update information is just one: Fixed Security Vulnerability UNITY-SEC-844
    Has this bug been fixed?
     
  17. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    This is the downside to stating which patch it is in before it's released. Sorry all, the security update takes priority and bumped all fixes going out. It looks like the answer is a mixed bag, some unity versions will still have this fix patched in the same release time frame (and just be called the next patch number instead) and some have had their release delayed. In 5.6's case, the fix will now be in 5.6.3p2 and it was delayed slightly.
     
  18. helton-lumentech

    helton-lumentech

    Joined:
    Feb 2, 2016
    Posts:
    3
    Looks like Unity is not even trying, been stuck for long time with the 5.6.1p2, any version after that is broken, and 5.6.1p2 has many issues, like tapjacking causing problem to users. How long does Unity pretend to keep us without an stability patch? This should be highest priority, without this, anyone who rely on the assetbundle system is unable to update. I'll take this into consideration next time I'm ask to put my vote on using assetbundle's system from Unity.

    In my perspective, such blocking issue should be priority. Why would you patch things that users will not be able to use since they can't even upgrade?
     
  19. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    If you need a work around for this issue, you can use the OfType to cast and return the values from LoadAllAssets and not trigger the bug. For Example:

    GameObject[] results = myBundle.LoadAllAssets<GameObject>(); // Will trigger the bug
    GameObject[] results = myBundle.LoadAllAssets().OfType<GameObject>().ToArray(); // Will not trigger the bug

    Another option is to write an extension method. Then when the bug is fixed, you can just update this method instead of having to change code all over the place.
    public static T[] LoadAllAssetsFix<T>(this UnityEngine.AssetBundle bundle)
    {
    return bundle.LoadAllAssets().OfType<T>().ToArray();
    }

    Sorry again for the delay on getting this fixed.
     
    Leoo likes this.
  20. Velawoods

    Velawoods

    Joined:
    Apr 30, 2018
    Posts:
    5
    Hello,

    I have update a project which is in unity 5.2.5 to unity 2017.3 p4. I have create my assetbundle from the same version as well as still I am unable to load assetbundle. Basically m_Request.isDone never gets true, I am always getting false in logs. @ryanc-unity Can you plz help.

    Here is the code :

    LoadedAssetBundle bundle = AssetBundleManager.GetLoadedAssetBundle (m_AssetBundleName, out m_DownloadingError);

    if(string.IsNullOrEmpty(m_DownloadingError) == false)
    {
    Debug.LogError("Asset bundle download error: " + m_AssetBundleName + " - " + m_DownloadingError);
    return false;
    }

    if (bundle != null)
    {

    m_Request = bundle.m_AssetBundle.LoadAssetAsync (m_AssetName, m_Type);
    Debug.Log (m_Request + " " + m_Request.isDone);
    if (m_Request != null && m_Request.isDone)
    {
    AssetBundleManager.AssetBundleManifestObject = GetAsset<AssetBundleManifest>();

    return false;
    }
    }

    return true;

    What I found is , m_Request.isDone never getting true. In unity 5.2.5 this code works fine and got true but after updating its not working. Please Help !!!!
     
    Last edited: May 1, 2018