Search Unity

CreateAssetMenu doesn't show up

Discussion in 'Scripting' started by OneUnity3D, Sep 26, 2022.

  1. OneUnity3D

    OneUnity3D

    Joined:
    Aug 7, 2019
    Posts:
    28
    Hey folks,

    I have a problem with my code and I don't know what's wrong. I want to create an AssetMenu but it doesn't show up in unity. The two scripts I'm using are:

    ChooseScene.cs:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [CreateAssetMenu(fileName = "NewChooseScene", menuName = "Data/New Choose Scene")]
    6. [System.Serializable]
    7. public class ChooseScene : GameScene
    8. {
    9.     public List<ChooseLabel> labels;
    10.  
    11.     [System.Serializable]
    12.     public struct ChooseLabel
    13.     {
    14.         public string text;
    15.         public StoryScene nextScene;
    16.     }
    17. }
    and StoryScene.cs:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [CreateAssetMenu(fileName = "NewStoryScene", menuName = "Data/New Story Scene")]
    6. [System.Serializable]
    7. public class StoryScene : GameScene
    8. {
    9.     public List<Sentence> sentences;
    10.     public Sprite background;
    11.     public GameScene nextScene;
    12.  
    13.     [System.Serializable]
    14.     public struct Sentence
    15.     {
    16.         public string text;
    17.         public Speaker speaker;
    18.     }
    19. }
    20.  
    21. public class GameScene : ScriptableObject { }
    In my StoryScene.cs I create the GameScene as ScriptableObject, but in ChooseScene I declare ChooseScene as GameScene and in my opinion it should work, but it doesn't...

    Greets,
    One
     
  2. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,648
    Worked for me. You save your code?
     
    TheDevloper likes this.
  3. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,935
    And on top of this, make sure there's no compiler errors elsewhere in your project.
     
    OneUnity3D and TheDevloper like this.
  4. TheDevloper

    TheDevloper

    Joined:
    Apr 30, 2019
    Posts:
    69
    Check Speaker type script
    Code (CSharp):
    1. public Speaker speaker;
    i have tried the script by removing this line and it works great for me.
    best of luck
     
  5. OneUnity3D

    OneUnity3D

    Joined:
    Aug 7, 2019
    Posts:
    28
    You were right, I got a compiler error and I thought I fix it later but this was the issue.

    Thanks

    -closed