Search Issue Tracker

Fixed

Fixed in 1.22.3, 2.3.7

Votes

9

Found in [Package]

2.2.2

Issue ID

ADDR-3784

Regression

Yes

Exception "IndexOutOfRangeException" is thrown when assigning an addressable SpriteAtlas to an AssetReferenceSprite field

Package: Addressables

-

Reproduction steps:
1. Open the attached “BugRepro” project
2. Select the “DeclaringReferencesTest” Asset in the Project window
3. (Optional) If the Inspector window is empty, make sure to Reset the Asset
4. Set a new value for the “Sprite Reference” option
5. Set a new value for the “Subasset” option
6. Observe the Console window

Expected result: No errors are thrown
Actual result: Error “IndexOutOfRangeException: Index was outside the bounds of the array.” is thrown

Reproducible with: 2.0.3 (2023.2.20f1), 2.2.2 (6000.0.22f1)
Not reproducible with: 1.22.2 (2021.3.44f1, 2022.3.50f1)

Reproducible on: Windows 10, Windows 11 (user)
Not reproducible on: No other environment tested

Comments (1)

  1. VodaLechebna

    Dec 14, 2024 12:27

    Still an issue in 6000.0.31f1 and all Addressables package versions available there. So let's fix it by modifying some files in YourProject/Library/PackageCache/com.unity.addressables:

    In Runtime/Utility/AssetReferenceUtilities replace lines 28-31 with:

    ```cs
    for (int i = 0; i < sprites.Length; i++)
    {
    packables.Add((sprites[i], sprites[i]));
    }
    ```

    In Editor/Settings/AssetReferenceDrawerUtilities insert this code right at the start of foreach at line 507:

    ```cs
    if (string.IsNullOrEmpty(assetReference.SubObjectGUID) && FormatName(sprite.name) == assetReference.SubObjectName)
    {
    foundSubObject = true;
    break;
    }
    ```

    This will fix it.

Add comment

Log in to post comment