public object GetObject(StringHash key, object @default = null) { IntPtr result = IntPtr.Zero; var type = 0; Urho3D_Object_Event_GetObject(_map, key.Hash, ref type, ref result); if (result == IntPtr.Zero) { return(@default); } if (type == 1) { // Managed object @default = GCHandle.FromIntPtr(result).Target; } else if (type == 2) { // Native object @default = NativeObject.GetManagedInstanceGeneric <RefCounted>(result); } else { throw new Exception(); } return(@default); }