- 原问题
You are trying to create a MonoBehaviour using the ‘new’ keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all
UnityEngine.MonoBehaviour:.ctor ()
GameDataMgr:.ctor () (at Assets/Scripts/UI/SettingPanel/Data/GameDataMgr.cs:12)
GameDataMgr:.cctor () (at Assets/Scripts/UI/SettingPanel/Data/GameDataMgr.cs:7)
BKMusic:Awake () (at Assets/Scripts/UI/SettingPanel/Data/BKMusic/BKMusic.cs:17)
- 翻译
你正在尝试使用“new”关键字创建一个MonoBehaviour。这是不允许的。单行为只能通过AddComponent()添加。或者,你的脚本可以继承ScriptableObject,或者根本不继承基类
UnityEngine.MonoBehaviour
- 解决方案
该类不继承MonoBehaviour即可