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

Scripting

-

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.

Comments (17)

  1. 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.

  2. 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!

  3. 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);

  4. 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.

  5. DarkMeatGames

    Feb 09, 2015 15:51

    This still seems to be an issue. Is there any update?

  6. 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.

  7. 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.

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.