Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Feedback A workaround to IN-10552, which is closed with the resolution As Designed

Discussion in 'Addressables' started by Alan-Liu, Feb 1, 2023.

  1. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    397
    Hello,
    I received an email from Unity which told me that my bug report IN-10552 was closed with the resolution As Designed:
    Resolution Notes: Intended behavior by design. Non-recursive dependency calculation mode collects extra dependency information to improve build times and reduce runtime memory overhead when assets have circular dependencies. This mode is enabled by default when using Unity 2021.2+.

    This issue caused the size of the asset bundle became larger when Non-Recursive Dependency Calculation is enabled, because it contained the UNUSED raw textures of the sprites.

    The reply from Unity above made me confused. Before I submitted this bug report, I did some invesitgation myself, found it can be avoided using a simple workaround which worked for our project:
    Code (CSharp):
    1. Index: ExtensionMethods.cs
    2. ===================================================================
    3. --- ExtensionMethods.cs    (revision 78539)
    4. +++ ExtensionMethods.cs    (revision 78540)
    5. @@ -99,6 +99,19 @@
    6.              // can find something that can be appended, otherwise the necessary data will fail to load correctly in all cases. (EX: prefab A has reference to component on prefab B)
    7.              foreach (var dependency in encounteredDependencies)
    8.              {
    9. +                if (EditorSettings.spritePackerMode != SpritePackerMode.Disabled)
    10. +                {
    11. +                    var type = BuildCacheUtility.GetMainTypeForObject(dependency);
    12. +                    if (type == typeof(UnityEngine.Sprite))
    13. +                    {
    14. +                        var includedObjects = ContentBuildInterface.GetPlayerObjectIdentifiersInAsset(dependency.guid, target);
    15. +                        var referencedObjects = ContentBuildInterface.GetPlayerDependenciesForObjects(includedObjects, target, typeDB, DependencyType.ValidReferences);
    16. +
    17. +                        if (referencedObjects.Length > 0)
    18. +                            continue;
    19. +                    }
    20. +                }
    21. +
    22.                  // For each dependency, add just the main representation as a reference
    23.                  var representations = ContentBuildInterface.GetPlayerAssetRepresentations(dependency.guid, target);
    24.                  collectedImmediateReferences.Add(representations.First());
    Can Unity developers take a look at my workaround? Does it work at all situations?
    If it is, hope a similar implemetation can be added to the official package to fix this issue.
     
    Last edited: Feb 21, 2023
  2. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    397
  3. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    397
    Hi, @Ryanc_unity, @unity_shane
    Can you take a look at this?
    Really hope the issues about Non-recursive dependency calculation can get fixed.