Skip to content

Commit d1440ca

Browse files
authored
Merge pull request #264 from Cysharp/hadashiA/readme
Add note about unity
2 parents 8b8ae95 + ce6b747 commit d1440ca

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,9 +1339,6 @@ For more information on Unity and Source Generator, please refer to the [Unity d
13391339

13401340
Source Generator is also used officially by Unity by [com.unity.properties](https://docs.unity3d.com/Packages/[email protected]/manual/index.html) and [com.unity.entities](https://docs.unity3d.com/Packages/[email protected]/changelog/CHANGELOG.html). In other words, it is the standard for code generation in the next generation of Unity.
13411341

1342-
> [!WARNING]
1343-
> Unity version does not support CustomFormatter.
1344-
13451342
You can serialize all unmanaged types (such as `Vector3`, `Rect`, etc...) and some classes(`AnimationCurve`, `Gradient`, `RectOffset`). If you want to serialize other Unity-specific types, see [Serialize external types](#serialize-external-types) section.
13461343

13471344
In Unity performance, MemoryPack is x3~x10 faster than JsonUtility.
@@ -1352,6 +1349,19 @@ If shared code has Unity's type(`Vector2`, etc...), MemoryPack provides `MemoryP
13521349

13531350
The `MemoryPack.UnityShims` package provides shims for Unity's standard structs (`Vector2`, `Vector3`, `Vector4`, `Quaternion`, `Color`, `Bounds`, `Rect`, `Keyframe`, `WrapMode`, `Matrix4x4`, `GradientColorKey`, `GradientAlphaKey`, `GradientMode`, `Color32`, `LayerMask`, `Vector2Int`, `Vector3Int`, `RangeInt`, `RectInt`, `BoundsInt`) and some classes(`AnimationCurve`, `Gradient`, `RectOffset`).
13541351

1352+
> [!WARNING]
1353+
> Currently, the following limitations exist for use in Unity
1354+
1355+
1356+
1. Unity version does not support CustomFormatter.
1357+
2. If you are using .NET7 or later, MemoryPack binary format is not fully compatible with Unity.
1358+
- This problem occurs with value types that `[StructLayout(LayoutKind.Auto)]` is explicitly specified. (The default for struct is `LayoutKind.Sequencil`.) For such types, binaries serialized in .NET cannot be deserialized in Untiy. Similarly, a binary serialized in Unity cannot be serialized in .NET side.
1359+
- The affected types typically include the following types.
1360+
- `DateTimeOffset`
1361+
- `ValueTuple`
1362+
- Currently, the simple solution is to not use these types.
1363+
1364+
13551365
Native AOT
13561366
---
13571367
Unfortunately, .NET 7 Native AOT causes crash (`Generic virtual method pointer lookup failure`) when use MemoryPack due to a runtime bug. It

0 commit comments

Comments
 (0)