Search Issue Tracker

Won't Fix

Votes

1

Found in

2019.4

2019.4.16f1

2020.2

2021.1

2021.2

Issue ID

1309841

Regression

No

Editor does not reimport Texture2DArray when Build Target is changed

Asset - Importers

-

How to reproduce:
1. Open the attached "Texture2DArraySwitchPlatform.zip" Project on the Android platform
2. Navigate to "Assets > textures" in the Project view
3. Notice the compression on the "New Texture2DArray.texture2darray" and other files in the directory is ASTC 6x6
4. Make sure that Asset Pipeline in Project settings is set to Version 2
5. Change the platform to Windows
6. Inspect the compression on the "New Texture2DArray.texture2darray" file

Expected Behavior: The compression is "DXT1" since the array is made of "DXT1" assets
Actual Behavior: The compression is still "ASTC"

Reproducible with: 2019.4.20f1, 2020.2.4f1, 2021.1.0b6, 2021.2.0a4
Could not test with: 2018.4, could not create texture2d array

Note:
- After you reimport the asset manually - compression is right
- Customer attached a 5min repro video "unity-assetpipeline-v2-platformchange-reimport.mp4"

  1. Resolution Note:

    The custom importer wrote by the user, in that case, is using AssetImportContext.DependsOnSourceAsset to depend on a list of Textures used during the import.
    Because this importer is not only referencing the textures but also use their values, it should use AssetImportContext.DependsOnArtifact instead.

    The differences between both methods are explained in their respective documentation:
    https://docs.unity3d.com/2020.2/Documentation/ScriptReference/AssetImporters.AssetImportContext.DependsOnSourceAsset.html
    https://docs.unity3d.com/2020.2/Documentation/ScriptReference/AssetImporters.AssetImportContext.DependsOnArtifact.html

    DependsOnSourceAsset should only be used when referencing an asset without reading its values.
    DependsOnArtifact should be used whenever the import result depends on the values of the other asset.

Add comment

Log in to post comment

All about bugs

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