NodeCanvas Forums › Support › IOS Deserialization error custom event
Tagged: IOS
Hi! I have a deserialization error when building in iPhone which goes like this:
1 2 3 4 5 6 |
<b>(Deserialization Error)</b>: Constructor of CheckEventEnumWithGameObject 1[ActionType] threw an exception when creating an instance at ParadoxNotion.Serialization.FullSerializer.fsMetaType.CreateInstance () [0x00000] in <filename unknown>:0 at ParadoxNotion.Serialization.FullSerializer.Internal.fsReflectedConverter.CreateInstance (ParadoxNotion.Serialization.FullSerializer.fsData data, System.Type storageType) [0x00000] in <filename unknown>:0 |
and then I already made the AOTClass and noticed my CheckEventEnumWithGameObject class is not part of it. So, I tried adding it but it doesn’t add to the list of preferred types. Can you please help me with this? Here is the code for my class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
using NodeCanvas.Framework; using NodeCanvas.Framework.Internal; using ParadoxNotion.Design; using ParadoxNotion; using System; using UnityEngine; [Category ("✫ Utility/Custom")] [Description ("Check if an event using enum name is received and return true for one frame")] [EventReceiver ("OnCustomEvent")] public class CheckEventEnum<T> : ConditionTask<GraphOwner> where T : struct { [RequiredField] public BBParameter<T> eventName; protected override string info{ get { return "[" + eventName.ToString () + "]"; } } protected override bool OnCheck () { return false; } public void OnCustomEvent (EventData receivedEvent) { if (isActive && receivedEvent.name.ToUpper () == Enum.GetName (typeof(T), eventName.value).ToUpper ()) { #if UNITY_EDITOR if (NodeCanvas.Editor.NCPrefs.logEvents) { Debug.Log (string.Format ("Event '{0}' Received from '{1}'", receivedEvent.name, agent.gameObject.name), agent); } #endif YieldReturn (true); } } } |
Hey,
You don’t need to add this type in the preferred types list. Instead only the types used by this should be added if not already. In this case for example, type “ActionType”, should be in the Preferred Types List.
Now, the reason this class is not appended in the AOTClasses.cs file, is because of the struct constraint (where T:struct) due to how the generator works now (which I will try to fix). Other type of constraints should work though. If you remove the struct constraint, then this class will be appended normally.
I’ve also realized a small bug in the generator caused because the class is outside of a namespace. Basically a dot “.” is added without needed 🙂
I’ve send you an email with the fix to this “.” problem though.
By the way there is already a condition “Check Event Value” which can be used for what you are after here (checking an event enum value)
Let me know if the send fix in the email and the above works for you.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Yes Thank you! It works. However, I have another problem:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
NullReferenceException: A null value was found where an object instance was required. at System.Reflection.EventInfo.CreateAddEventDelegate (System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0 at System.Reflection.EventInfo.AddEventHandler (System.Object target, System.Delegate handler) [0x00000] in <filename unknown>:0 at NodeCanvas.Tasks.Conditions.CheckCSharpEvent.OnInit () [0x00000] in <filename unknown>:0 at NodeCanvas.Framework.Task.Initialize (UnityEngine.Component newAgent, System.Type newType) [0x00000] in <filename unknown>:0 at NodeCanvas.Framework.Task.Set (UnityEngine.Component newAgent, IBlackboard newBB) [0x00000] in <filename unknown>:0 at NodeCanvas.Framework.ConditionTask.Enable (UnityEngine.Component agent, IBlackboard bb) [0x00000] in <filename unknown>:0 at NodeCanvas.StateMachines.FSMState.OnExecute (UnityEngine.Component agent, IBlackboard bb) [0x00000] in <filename unknown>:0 at NodeCanvas.Framework.Node.Execute (UnityEngine.Component agent, IBlackboard blackboard) [0x00000] in <filename unknown>:0 at NodeCanvas.StateMachines.FSM.EnterState (NodeCanvas.StateMachines.FSMState newState) [0x00000] in <filename unknown>:0 at NodeCanvas.StateMachines.FSMState.CheckTransitions () [0x00000] in <filename unknown>:0 at NodeCanvas.StateMachines.FSMState.Update () [0x00000] in <filename unknown>:0 at NodeCanvas.StateMachines.FSM.OnGraphUpdate () [0x00000] in <filename unknown>:0 at NodeCanvas.Framework.Graph.UpdateGraph () [0x00000] in <filename unknown>:0 at System.Action.Invoke () [0x00000] in <filename unknown>:0 at ParadoxNotion.Services.MonoManager.Update () [0x00000] in <filename unknown>:0 |
I checked the FSM and it’s not NULL
and here is the code it listens to:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
using UnityEngine; using System; using System.Collections; public class LevelLoader : MonoBehaviour { public LevelGenerator generator; private bool isLoaded = false; private bool isUnloaded = false; private GameObject _level; public event Action LoadFinished; public event Action UnloadFinished; public void Load () { if (isLoaded) { Debug.LogError ("Level already loaded, please unload first"); return; } generator.GetNewLayout ((obj) => { _level = obj; if (LoadFinished != null) { LoadFinished.Invoke (); } isLoaded = true; isUnloaded = false; }); } public void Unload () { if (isUnloaded) { Debug.LogError ("no Level is loaded, please load first"); } if (generator.RecycleLayout (_level)) { if (UnloadFinished != null) { UnloadFinished.Invoke (); } isLoaded = false; isUnloaded = true; } } } |
Hello,
Are you using IL2CPP backend? Does this problem takes place when using Mono scripting backend?
Let me know.
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Yeah, I’m using IL2CPP, because when I use the Mono one I’m having JIT Compiler errors
Hi! The game now works in the IOS simulator. What I did was instead of listening to the CSharpEvent from the script I just used the SendEvent method in the graphOwner. I was using the Multiplatform/Common version of CSharpEvent. I don’t know if its a bug though.
Hello,
Were the JIT compile errors relevant to NodeCanvas? If yes, can you please provide me the log?
It seems that there is something in CheckCSharp event that iOS does not support. I will double check this one.
Thanks for letting me know!
Join us on Discord: https://discord.gg/97q2Rjh