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

Question Scriptable Objects unassignable and sometimes empty

Discussion in 'Scripting' started by Encounter4592, May 3, 2023.

  1. Encounter4592

    Encounter4592

    Joined:
    May 3, 2023
    Posts:
    5
    Hello,
    I cannot assign my scriptable objects to the list.
    upload_2023-5-3_18-23-40.png

    Also, after launching Unity, they sometimes are empty, and script is set to "Mono". What could be the issues?
    Thanks!


    Here is the code:

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. [CreateAssetMenu(fileName = "xxx", menuName = "xxx")]
    4. public class TypeAssetCreator : ScriptableObject
    5. {
    6.     [SerializeField] private Sprite sprite;
    7.     [SerializeField] private Gradient gradient;
    8.  
    9.     [SerializeField] private bool isDowngradable;
    10.     [SerializeField] private bool isUpgradable;
    11. }
    Code (CSharp):
    1. public List<TypeAssetCreator> typesList;
     
  2. MartinMa_

    MartinMa_

    Joined:
    Jan 3, 2021
    Posts:
    455
    I think issue is exactly same as is stated in error. "File and class name must match".
    What is your filename of TypeAssetCreator .
     
    Encounter4592 likes this.
  3. Encounter4592

    Encounter4592

    Joined:
    May 3, 2023
    Posts:
    5
    You are right, thanks