CreateAssetMenu not working

[SOLVED] I updated Unity to 2021.1.25f1 and it seemed to have fixed the problem. I did not ever find the actual reason for it failing but updating and upgrading the project seemed to have fixed it.


Issue: CreateAssetMenu not working for Scriptable object

Description: Created a Dialogue script and changed type to ScriptableObject then added [CreateAssetMenu] attribute. With no compile errors the menu does not appear when right clicking within the Project asset folder(s).

Fixes Attempted

  • Ensured script type was ScriptableObject
  • Checked syntax
  • Checked compile errors (none)
  • Restarted Unity and Visual Studio

Software Version(s)

  • Unity 2021.1.16f1
  • Visual Studio Community 2019 Version 16.8.2

Code

using UnityEngine;

[CreateAssetMenu(fileName = "UnnamedDialogue", menuName = "Dialogue")]
public class Dialogue : ScriptableObject
{
    [SerializeField]
    DialogueNode[] nodes;
}

Screenshot

Thanks for sharing your solution. :slight_smile:

That’s definitely an odd error. I think what happened is that the code failed to update when you edited it. This happens occasionally, and the causes can vary, but are usually linked to a communication failure between your editor and Unity. When you upgraded the project to a newer version, it forced a recompile of the code, which brought it up to date with the real code.

Here are some things you can do in the future if you encounter errors like this:

  • Make sure that the plugin for your code editor is up to date in Unity. You can do this through the Package Manager.
  • Make sure that the right Editor is selected in your Editor/Preferences/External Tools
  • Where applicable, Refresh Solution in the same Editor/Preferences/External Tools
  • Exit Unity and delete the Library folder.
  • Avoid creating new classes from within the code editor. This can confuse Unity.
  • Sometimes the issue is that the file gets tagged as read-only, not allowing updates. Usually for this, copying the new code, closing both Unity and your code editor, then reopening the code editor and pasting in the new code.

Thanks Brian!
For others reading and for future info, the Editor and Unity in this scenario seemed fine in cross talking in all other obvious scenarios.

The Package/Plugin was updated that morning manually.

Cannot confirm if it could be permission related l. Good thought. Ran into no other symptoms of issue though.

I have a vague suspicion it is related to the first project upgrade when importing the lesson. I just can’t prove it and it is probably a rare occurrence.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms