- Home /
scriptable object is broken everytime
scriptable object is broken everytime like below image.. when I start game its fine but after the game, its broken often and I will have to start game and comeback to modify paramters of it.
here is the code:
using UnityEngine;
using UnityEngine.UI;
[System.Serializable]
public class StageData
{
public int level; // current level
public float[] layers;
public float [] reward;
public int gamemode;
public int hp;
}
[CreateAssetMenu(fileName = "Data", menuName = "GameDesign/StageDesigner", order = 1)]
public class StageDesigner : ScriptableObject
{
public StageData[] stageDatas;
}
Let me know what I am missing.. Unity 5.504b
Answer by TimHeijden · Nov 20, 2016 at 12:35 AM
The Class name and filename always need to be the same for Unity's classes, including ScriptableObject. In addition, they should be the first class in the file.
Please make sure this is the issue or not :)
edit: To clarify, I'm talking about the ScriptableObject SCRIPT filename, not the ScriptableObject instance ^^
changed filename to be same but still same issues are occurring..
You most likely need to recreate your ScriptableObject asset that you created. The old one used a faulty class.
@TimHeijden: The order of classes inside a file doesn't matter. It's only important to have only one $$anonymous$$onoBehaviour / ScriptableObject class inside one file and the classname need to match the filename.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Player gets stuck between platforms!!! 1 Answer
Multi Button Script Help 1 Answer
Script Help for click and auto drop . 0 Answers
Script Performance: 1 central or many independent? 2 Answers