Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Scriptable objects showing as No MonoScript

Discussion in 'Editor & General Support' started by nankink, Sep 26, 2021.

  1. nankink


    May 6, 2017
    I'm restructuring my code and got the idea of putting all the scriptable objects code into a namespace.
    It seems to work but when I create the object, the field Script is missing the script, saying No MonoScript.
    I thought it was because of the CreateAssetMenu attribute as numberkrunch didn't use it in this post, but wrote an editor script following his steps and got the same result. Even though, it displayed the intended behaviour in his tests.
    I really wish to put all these scriptable objects together.. is there any way to make it work?

    Code (CSharp):
    1. namespace BBMM.UI.ScriptableObjects
    2. {
    3.     [CreateAssetMenu(fileName = "New Size Preset", menuName = "BBMM/Size Preset")]
    4.     public class SO_UI_SizePreset : ScriptableObject
    5.     {
    6.         public string presetName;
    7.         public Vector2 realSize;
    8.         public UnitType unit;
    9.     }
    11.     [CreateAssetMenu(fileName = "New Object", menuName = "BBMM/Object Container")]
    12.     public class SO_UI_ObjectList_Item : ScriptableObject
    13.     {
    14.         public string objectName;
    15.         public GameObject prefab;
    16.     }
    17. }
  2. Neto_Kokku


    Feb 15, 2018
    Scriptable objects follow the same rule as Monobehaviour: their classes must be placed in a cs file with the same name as the class in order for the Unity serialization system to be able to identify them. This means you cannot have multiple SO or MB classes defined in the same file.
  3. nankink


    May 6, 2017
    aw got it. That's sad, but thanks for the reply!