PhysicsWorld.Snapshot
An opaque, point-in-time capture of a PhysicsWorld simulation state, produced by PhysicsWorld.CreateSnapshot. Restore it into the same world with PhysicsWorld.ApplySnapshot, or create a new world from it with PhysicsWorld.Create.
読み終わるまでの所要時間 1 分最終更新 5日前
Definition
- Type: Struct
- Namespace: Unity.U2D.Physics
- Assembly: UnityEngine.PhysicsCore2DModule
- Implements: IDisposable
public struct PhysicsWorld.Snapshot : IDisposable
Remarks
A snapshot owns native memory and must be disposed after use. A snapshot is only valid for the same Unity build that produced it and is not a portable on-disk format. A snapshot stores the world's PhysicsBody, PhysicsShape, PhysicsChain and PhysicsJoint objects. It also stores their user data, owner user data and owner, and the transform write mode of each body. Restoring a snapshot keeps each object's owner as information, but nothing restored is owned, because every owner key is restored as zero. No restored body has a PhysicsBody.transformObject, so a restored world never writes to a Transform until you set one again. Callback targets are not restored, and the world's own state, such as its user data, name and draw settings, is never changed by a restore.
Properties
Property | Description |
|---|---|
| IsCreated | Whether this snapshot holds a valid captured image. |
| Length | The size of the snapshot image in bytes. |
Methods
Method | Description |
|---|---|
| Dispose | Release the native memory held by this snapshot. |