Hi,
is there an easy and quick way to test in a script whether we are currently in a “serialization context”, i.e. not allowed to call Unity functions like .gameObject or GameObject.name? Something like Application.isDuringSerializationContext ?
Use case is, we have an own logging facility that tries to gather some extended context information. We want this logging function to be usable from basically anywhere, included OnAfterDeserialize callbacks.
But nowadays (5.4.0b1) we get errors complaining that “ToString is not allowed to be called during serialization, call it from Awake or Start instead.”
Edit: Is it guaranteed that the Unity main thread stays the same and all code on this thread is never in this “during serialization”? Then I might compare Thread.CurrentThread?