jacobdufault / fullserializer

A robust JSON serialization framework that just works with support for all major Unity export platforms.
MIT License
1.11k stars 166 forks source link

"MonoBehaviour using the 'new' keyword. This is not allowed." #167

Open zkMyst opened 3 years ago

zkMyst commented 3 years ago

Hi! I've been using the serializer with unity and firebase realtime database, but for some reason when trying to pull a json from a node, and I deserialize it: var gameInfo = StringSerializationAPI.Deserialize(typeof(GameInfo), args.Snapshot.GetRawJsonValue()) as GameInfo; I get the following error. Any idea what could cause this? Thanks 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() GameInfo:.ctor() System.Activator:CreateInstance(Type, Boolean) FullSerializer.fsMetaType:CreateInstance() (at Assets/FullSerializer/Source/Reflection/fsMetaType.cs:354) FullSerializer.Internal.fsReflectedConverter:CreateInstance(fsData, Type) (at Assets/FullSerializer/Source/Converters/fsReflectedConverter.cs:92) FullSerializer.fsSerializer:InternalDeserialize_3_Inheritance(Type, fsData, Type, Object&, List1&) (at Assets/FullSerializer/Source/fsSerializer.cs:890) FullSerializer.fsSerializer:InternalDeserialize_2_Version(Type, fsData, Type, Object&, List1&) (at Assets/FullSerializer/Source/fsSerializer.cs:835) FullSerializer.fsSerializer:InternalDeserialize_1_CycleReference(Type, fsData, Type, Object&, List1&) (at Assets/FullSerializer/Source/fsSerializer.cs:789) FullSerializer.fsSerializer:TryDeserialize(fsData, Type, Type, Object&) (at Assets/FullSerializer/Source/fsSerializer.cs:757) FullSerializer.fsSerializer:TryDeserialize(fsData, Type, Object&) (at Assets/FullSerializer/Source/fsSerializer.cs:731) APIs.StringSerializationAPI:Deserialize(Type, String) (at Assets/Scripts/APIs/StringSerializationAPI.cs:29) <>cDisplayClass21_0:b0(ValueChangedEventArgs) (at Assets/Scripts/NetworkManager.cs:117) APIs.<>cDisplayClass14_0:gCurrentListener|0(Object, ValueChangedEventArgs) (at Assets/Scripts/APIs/DatabaseAPI.cs:202) Firebase.Database.Internal.cAnonStorey0:<>m0() (at Z:/tmp/tmp.lovKbPiy9W/firebase/database/client/unity/proxy/InternalValueListener.cs:53) Firebase.ExceptionAggregator:Wrap(Action) (at Z:/tmp/tmp.9ewH1DXgzz/firebase/app/client/unity/src/Platform/ExceptionAggregator.cs:112) Firebase.Database.Internal.InternalValueListener:OnValueChangedHandler(Int32, IntPtr) (at Z:/tmp/tmp.lovKbPiy9W/firebase/database/client/unity/proxy/InternalValueListener.cs:45) Firebase.AppUtilPINVOKE:PollCallbacks() Firebase.AppUtil:PollCallbacks() (at Z:/tmp/tmp.BJ3HwuSQbT/firebase/app/client/unity/proxy/AppUtil.cs:32) Firebase.Platform.FirebaseAppUtils:PollCallbacks() (at Z:/tmp/tmp.BJ3HwuSQbT/firebase/app/client/unity/proxy/FirebaseAppUtils.cs:33) Firebase.Platform.FirebaseHandler:Update() (at Z:/tmp/tmp.9ewH1DXgzz/firebase/app/client/unity/src/Unity/FirebaseHandler.cs:208) Firebase.Platform.FirebaseMonoBehaviour:Update() (at Z:/tmp/tmp.9ewH1DXgzz/firebase/app/client/unity/src/Unity/FirebaseMonoBehaviour.cs:45) `