Search Issue Tracker
Active
Under Consideration for 6000.0.X, 6000.1.X
Votes
0
Found in
6000.0.16f1
6000.1.0a7
Issue ID
UUM-79533
Regression
No
AssetDatabase.LoadAssetAtPath returns null when loading sub-asset in OnEnable
*+Description+*
We have an issue where AssetDatabase.LoadAssetAtPath is returning null when trying to get a subasset / child asset of an asset in OnEnable.
We have a workaround by using AssetDatabase.LoadAllAssetsAtPath, but this seems like a dirty workaround and it brought confusion and errors multiple times now, as even today someone changed it to the single AssetDatabase.LoadAssetAtPath not realising the issue and I had to find they did that and revert it back.
This is also mentioned in the forums and various places by users
https://discussions.unity.com/t/loadassetatpath-returns-null-after-compiling/865875
*+Initial setup+*
6000.0.16f1+
You can use our package to repro it, specifically on this branch:
https://github.cds.internal.unity3d.com/unity/com.unity.ai.designer-monorepo/tree/feature/blackboard-asset-group
If you import the 2 packages in the repo from disk.
*+Reproduction steps+*
1. Setup the packages from the branch (feature/blackboard-asset-group) in the repo linked above.
2. Inside BehaviorAuthoringBlackboardAsset.cs, find the method GetOrCreateBlackboardAsset. Replace LoadAllAssetsAtPath with AssetDatabase.LoadAssetAtPath<RuntimeBlackboardAsset>
3. In the package manager, import "Unity Behavior Example".
4. Find Example Behavior Graph.asset and expand it in the project window to see its subassets
*+Expected behaviour+*
(Describe in as much detail as possible what you expect to see happen, ideally with examples, screenshots, links, and logs.)
There should only be a single RuntimeBlackboardAsset child asset in the mentioned asset. Also, the AssetDatabase.LoadAssetAtPath shouldn't be null if there is already a subasset.
*+Actual behavior+*
(Describe in as much detail as possible what is actually happening, ideally with logs, screenshots, links etc.)
AssetDatabase.LoadAssetAtPath inside GetOrCreateBlackboardAsset returns null even if the asset already exists, when it's called from OnEnable.
This causes our system to create another subasset and add it to the asset, and you'll see there are multiple subassets of the same type now.
*+Logs and Links+*
(Add links to Yamato jobs, links to logs, and add a stack trace in this section)
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Animation Clip with Legacy enabled does not play when Time.timeScale is set to 0 despite Update mode set to "Unscaled time"
- Rename is enabled on subfolder empty space - "Can't rename to empty name" warning
- SamplerState Property Missing Anisotropic Filtering
- Visual glitches when using Handles API
- The RGBA color values are inconsistent when comparing two identical colors set in the Inspector
Add comment