Search Issue Tracker

Fixed in 2019.1.X

Votes

2

Found in

2018.2.12f1

Issue ID

1092051

Regression

No

Using the Reset() context menu option on a Scriptable Object clears its name property in the Inspector window

Scripting

-

How to reproduce:
1. Create a new Unity project
2. Create a new Scriptable Object/Import the user-attached package
3. Select the Scriptable Object and in the Inspector window select the 'Reset' context menu option

Expected result: the name property displayed in the Inspector window after the reset is unchanged
Actual result: the name property displayed in the Inspector window after the reset is cleared

Reproducible with: 2017.4.13f1, 2018.1.9f2, 2018.2.13f1, 2018.3.0b6, 2019.1.0a5

Notes:
The name of the Scriptable Object is not affected in the Project window, only the Inspector window
Reimporting the Scriptable Object fixes its name property when viewing in the Inspector window

Comments (3)

  1. uaknight

    Jun 02, 2019 06:02

    I should add that like NoiseCrime said, reimporting the asset from the project view helps.

    And it's an underlying issue. In the following code, o.name is empty ("") on inspection:

    [MenuItem("Assets/Update Asset Name")]
    static void UpdateAssetName() {
    UnityEngine.Object o = Selection.activeObject;
    string path = AssetDatabase.GetAssetPath(o);
    AssetDatabase.RenameAsset(path, o.name);
    }

  2. uaknight

    Jun 02, 2019 05:54

    I'm also having this issue. The name displayed in the inspector window gets cleared when using the Reset context menu. The name on the selected scriptable object in the project view is unaffected.

    I'm using Unity 2019.1.4, so it doesn't seem to have been fixed.

  3. Noisecrime

    May 17, 2019 08:53

    Just want to add there is a deeper issue here than just the missing display name and while displaying the name might be fixed the underlying issue is unresolved as of 2019.1.2.

    So calling Reset on a scriptableObject causes it to loss its name property completely!

    Once Reset is called using this.name on the object will return empty or null. Trying to get the m_Name property via serializedProperty returns the same result. This is observable by adding a custom Reset() method to the scriptableObject script and logging to the console.

    However looking at the .asset file I can clearly see m_Name property and the correct asset name assigned to it and that never changes. So it appears its only the editor that seems to lose track of the name property and not the asset.

    Thankfully this issue only remains until the asset is re-imported, and from testing it appears you can do this in the Reset() method by using AssetDatabase.ImportAsset().

    This workaround should suffice until the bug can be fixed.

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.