Unity 泛型方法参数判空问题

项目tolua使用过程中出现了这样一个问题,一个unity的object在 如下方法中,ret 为空,而作为参数传到ToLua.PushSealed(L,ret) 中判断o == null 却返回false.

	static int get_sprite(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			UnityEngine.UI.Image obj = (UnityEngine.UI.Image)o;
			UnityEngine.Sprite ret = obj.sprite;
			ToLua.PushSealed(L, ret);
			return 1;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index sprite on a nil value");
		}
	}
 public static void PushSealed<T>(IntPtr L, T o)
{
     if (o == null)
     {
          LuaDLL.lua_pushnil(L);
     }
     else
     {
       int reference = TypeTraits<T>.GetLuaReference(L);

        if (reference <= 0)
        {
             reference = LoadPreType(L, o.GetType());
         }

           ToLua.PushUserData(L, o, reference);
         }
       }

产生这个问题的原因 是因为 unity 做了“假空(fake null)”,具体细节在unity 官方blog中有详细解释

https://blogs.unity3d.com/cn/2014/05/16/custom-operator-should-we-keep-it/