IL to match is pretty much just some form of value/field load followed by a brtrue/brtrue.s. The latter just needs to be replaced with a call to [UnityEngine.CoreModule]UnityEngine.Object::op_Inequality(class [UnityEngine.CoreModule]UnityEngine.Object, class [UnityEngine.CoreModule]UnityEngine.Object) and a brfalse/brfalse.s afterwards.
Only do this when the loaded value/field is inheriting from UnityEngine.Object of course.
https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-coalescing-operator https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operators
IL to match is pretty much just some form of value/field load followed by a
brtrue
/brtrue.s
. The latter just needs to be replaced with a call to[UnityEngine.CoreModule]UnityEngine.Object::op_Inequality(class [UnityEngine.CoreModule]UnityEngine.Object, class [UnityEngine.CoreModule]UnityEngine.Object)
and abrfalse
/brfalse.s
afterwards. Only do this when the loaded value/field is inheriting fromUnityEngine.Object
of course.