public static ChipmunkShape _FromHandle(IntPtr handle) { if (handle == IntPtr.Zero) { return(null); } else { return(GCHandle.FromIntPtr(CP._cpShapeGetUserData(handle)).Target as ChipmunkShape); } }
protected override void OnDestroy() { // Debug.Log("Destroying a Shape."); if (_handle == IntPtr.Zero) { Debug.LogError("ChipmunkShape handle is already null."); return; } if (CP._cpShapeGetSpace(_handle) != IntPtr.Zero) { Debug.LogError("Attempted to destroy a shape that was still added to a space."); return; } GCHandle gch = GCHandle.FromIntPtr(CP._cpShapeGetUserData(_handle)); if (gch.Target != this) { Debug.Log("ChipmunkShape handle does not match"); } gch.Free(); }