Search Issue Tracker

By Design

By Design in 6000.5.X

Votes

0

Found in

6000.0.66f1

6000.3.4f1

6000.4.0b5

6000.5.0a5

Issue ID

UUM-132567

Regression

No

Error "NullReferenceException: Object reference not set to an instance of an object" is present and Asset Bundle is not loaded when using a relative path in a Windows Standalone Player

Windows

-

Reproduction steps:
1. Open the attached project "ReproProj"
2. Open the “/Assets/Scenes/SampleScene.unity” Scene
3. In Menu bar click “Assets > Build AssetBundles”
4. Enter the Play Mode
5. Observe that penguin is present
6. Open Build Profiles (File > Build Profiles)
7. Build And Run
8. Observe the Player

Expected result: Penguin exists and no Errors are present
Actual result: Penguin is not present and Error “NullReferenceException: Object reference not set to an instance of an object“ is present

Reproducible with: 6000.0.66f1, 6000.3.5f1, 6000.4.0b5, 6000.5.0a5

Reproducible on:
Windows Standalone Player

Not reproducible on:
Play Mode

Testing environment: Windows 10 Enterprise 21H2
Not reproducible on: No other environment tested

Note:
- If you copy the Bundles folder into the "_Data" folder then the bundle is loaded correctly

  1. Resolution Note:

    Thank you for reporting a bug to Unity.

    After reviewing the behavior, we've confirmed it aligns with the current design and intended use of the feature. We understand this may differ from your expectations or workflow.

    This issue is not caused by a Unity bug. The project’s OnPostprocessBuild script copies AssetBundles to the build root using Directory.GetCurrentDirectory(), which is not guaranteed to return the project directory. In Unity 6 and higher, the Player’s LocalFileSystem root resolves to the <BuildName>_Data folder, so bundles must be placed inside this directory to load correctly. Because the bundles are copied to the wrong location, the Player cannot locate them and a NullReferenceException occurs. Updating the post‑build script to derive the data folder path from report.summary.outputPath resolves the problem. For reference on how Player data paths are structured, see Unity’s documentation for Application.dataPath: https://docs.unity3d.com/ScriptReference/Application-dataPath.html

  2. Resolution Note (6000.5.X):

    Thank you for reporting a bug to Unity.

    After reviewing the behavior, we've confirmed it aligns with the current design and intended use of the feature. We understand this may differ from your expectations or workflow.

    This issue is not caused by a Unity bug. The project’s OnPostprocessBuild script copies AssetBundles to the build root using Directory.GetCurrentDirectory(), which is not guaranteed to return the project directory. In Unity 6 and higher, the Player’s LocalFileSystem root resolves to the <BuildName>_Data folder, so bundles must be placed inside this directory to load correctly. Because the bundles are copied to the wrong location, the Player cannot locate them and a NullReferenceException occurs. Updating the post‑build script to derive the data folder path from report.summary.outputPath resolves the problem. For reference on how Player data paths are structured, see Unity’s documentation for Application.dataPath: https://docs.unity3d.com/ScriptReference/Application-dataPath.html

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.