ドキュメント

Unity Engine

Download Unity

Unity Engine

SetOwner

Set the owner object using the specified owner key. You can only set the owner once, multiple attempts will produce a warning. This call does not bind the lifetime of the specified owner object, it is simply a reference. Whilst it is valid to not specify an owner object (NULL), it is recommended for debugging purposes.
読み終わるまでの所要時間 3 分最終更新 5時間前

Definition

  • Type: Method
  • Namespace: Unity.U2D.Physics
  • Assembly: UnityEngine.PhysicsCore2DModule

SetOwner(ReadOnlySpan<PhysicsBody>, Object, int)

Set the owner object using the specified owner key. You can only set the owner once, multiple attempts will produce a warning. This call does not bind the lifetime of the specified owner object, it is simply a reference. Whilst it is valid to not specify an owner object (NULL), it is recommended for debugging purposes.
public static void SetOwner(ReadOnlySpan<PhysicsBody> bodies, Object owner, int ownerKey)

Parameters

The bodies to set ownership for.

owner

The object that owns this key. Whilst it is valid to not specify an owner object (NULL), it is recommended for debugging purposes.

ownerKey

The owner key to be used. The value must be non-zero. You can use PhysicsWorld.CreateOwnerKey for this value although any non-zero integer will work.

Remarks

The owner also decides whether the bodies are kept when a scene loads in Single mode. They are kept when their owner is a GameObject, or a component on one, that is in the DontDestroyOnLoad scene or has HideFlags.DontSave set. See PhysicsWorld.SceneLoadMode.

SetOwner(Object, int)

Set the owner object using the specified owner key. You can only set the owner once, multiple attempts will produce a warning. This call does not bind the lifetime of the specified owner object, it is simply a reference. It is also valid to not specify an owner object (NULL) to simply gain an owner key however it can be useful, if simply for debugging purposes and discovery, to know which object is the owner.
public void SetOwner(Object owner, int ownerKey)

Parameters

owner

The object that owns this key. This can be NULL if not required but is recommended as the key is formed in part by the hash-code of the owner object.

ownerKey

The owner key to be used. If zero then a new owner key is created. You can use PhysicsWorld.CreateOwnerKey for this value although any non-zero integer will work.

Remarks

The owner also decides whether the body is kept when a scene loads in Single mode. The body is kept when its owner is a GameObject, or a component on one, that is in the DontDestroyOnLoad scene or has HideFlags.DontSave set. See PhysicsWorld.SceneLoadMode.

SetOwner(Object)

Set the owner object using the specified owner key. You can only set the owner once, multiple attempts will produce a warning. This call does not bind the lifetime of the specified owner object, it is simply a reference. It is also valid to not specify an owner object (NULL) to simply gain an owner key however it can be useful, if simply for debugging purposes and discovery, to know which object is the owner.
public int SetOwner(Object owner)

Parameters

owner

The object that owns this key. This can be NULL if not required but is recommended as the key is formed in part by the hash-code of the owner object.

Returns

Type

Description

intThe owner key assigned.

Remarks

The owner also decides whether the body is kept when a scene loads in Single mode. The body is kept when its owner is a GameObject, or a component on one, that is in the DontDestroyOnLoad scene or has HideFlags.DontSave set. See PhysicsWorld.SceneLoadMode.