Search Issue Tracker
By Design
Votes
0
Found in
2021.2.19f1
2021.3
2022.2.0a3
Issue ID
1422311
Regression
Yes
JavaScript file loaded as TextAsset using AssetDatabase.LoadAssetAtPath returns null
Reproduction steps:
1. Open the attached '1422311-sample' project
2. Open the 'SampleScene'
3. Enter Play mode
Expected result: No errors are in the Console
Actual result: 'NullReferenceException: Object reference not set to an instance of an object' is in the Console
Reproducible with: 2021.3.3f1, 2022.2.0a3, 2022.2.0a15
Not reproducible with: 2019.4.39f1, 2020.3.34f1, 2022.1.2f1, 2022.2.0a2
Reproducible on: macOS 11.6 (Intel)
-
GabKBelmonte
May 25, 2022 15:25
JavaScripts are not text assets since they were dropped in 2017, there was legacy code that still treated them as such. (https://docs.unity3d.com/Manual/class-TextAsset.html)
By dropping that, we allow the flexibility of allowing users to load them as assets themselves, an
example here: https://forum.unity.com/threads/loading-a-file-with-a-custom-extension-as-a-textasset.625078/It will also allow future dev for support of Unity CloudCode.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Resolution Note:
JavaScript files are not TextAssets anymore, it was legacy code that has been lingering from the UnityScript days (removed in 2017). Workaround: https://forum.unity.com/threads/loading-a-file-with-a-custom-extension-as-a-textasset.625078/