Search Issue Tracker
Fixed
Votes
22
Found in
4.2.0b2
Issue ID
549533
Regression
No
Cannot add assets to a ScriptableObject asset with AssetDatabase.AddObjectToAsset
In case the main Asset is a ScriptableObject, AssetDatabase.AddObjectToAsset (subObj, mainAsset) "mixes up" incoming parameters and adds the scriptable obj to a sub object
Expected: Vice versa.
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
- Crash on ScriptableRenderLoopDraw when rendering a specific VFX in Play Mode
- The script is not renamed in the Project window when renaming and a compilation Error is present
- Average FPS in Play Mode degradation on a newly created BiRP project when it's upgraded from 2020.3.48f1 to a newer Editor version
- DecoratorDrawer indentation is incorrect when it is called with EditorGUI
- "Unable to get the list of approved APIs." is thrown when testing the App Packages with Windows App Certification Kit
winxalex
Apr 08, 2016 10:21
Bug Not solved. Sub asset become main asset. U 5.3.3p2. Only way to do it is to set
subAsset.HideFlags=HideFlags.HideInHierachy before add. Then you out of Debugging option. Shame on Unity.
Sprakle
Apr 07, 2016 18:58
Update: It does seem to work if I change the name of the Scriptable Object before adding it. Yay!
Sprakle
Apr 07, 2016 18:49
Definitely still broken as of 5.3.4f1. When I try adding a Scriptable Object to an asset, the parent-child relationship seems to be reversed, and I get the following error:
NullReferenceException: SerializedObject of SerializedProperty has been Disposed.
Code:
Object child = ScriptableObject.CreateInstance(type);
AssetDatabase.AddObjectToAsset(child, parentAsset);
Michael-Ryan
Mar 04, 2016 02:36
This issue appears to be flagged as "resolved", since you can not longer vote on it ... but it's still not functioning as expected.
AssetDatabase.AddObjectToAsset (subObj, mainAsset)
When mainAsset is a ScriptableObject, the call results in a new generic object being created with both the mainAsset and subObj as children. Instead the subObj should become a child of the mainAsset. That's it.
DarkMeatGames
Feb 09, 2015 15:51
This still seems to be an issue. Is there any update?
yoyo
Jan 13, 2014 21:26
As of Unity 4.3.1 you can call AssetDatabase.AddObjectToAsset(sub, main), but you will get a new main asset (of type UnityEngine.Object) with two children -- sub and main.
Ayrik
Dec 10, 2013 18:21
This would clean up my plugin tremendously. Currently, I have to create a separate "main asset" and put all the children in a separate asset.