Search Issue Tracker

By Design



Found in




Issue ID




Asset is not found when instantiating it when it was loaded using "Resources.Load() as GameObject" and 2 same name Assets exist

Asset Import Pipeline


How to reproduce:
1. Open the attached "1301355_Repro" project
2. Open the Scene "SampleScene"
3. Enter the Play Mode

Expected results: No errors are thrown, a cube is instantiated in the Scene
Actual results: The "ArgumentException: The Object you want to instantiate is null." error is thrown, the cube is not instantiated in the Scene

Reproducible with: 2020.2.0a5, 2020.2.1f1, 2021.1.0b1
Not reproducible with: 2018.4.30f1, 2019.4.17f1, 2020.1.17f1, 2020.2.0a4

- The issue is reproducible when using this syntax:
Resources.Load("Cube") as GameObject;
- The issue is not reproducible when using these syntaxes:
Resources.Load("Cube", typeof(GameObject)) as GameObject;

  1. Response avatar

    Resolution Note (2021.2.X):

    This change in behaviour occurred because of performance improvements under the hood, which affected the internal ordering of the assets indexed by the Resources system.

    However, when using Resources.Load() with multiple assets of different types with the same name, there has never been a documented guarantee for which asset will be returned, and internally we don't prioritise the different types in any particular way. In more complex scenarios, the apparent consistency of the result might well have broken down.

    In this situation, we recommend using an explicit type to get the correct asset, e.g. Resources.Load<T>()

    The scripting API docs are being updated to clarify this point.

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.