Version: 2022.2
言語: 日本語
public static bool SetManagedReferenceIdForObject (Object obj, object scriptObj, long refId);

パラメーター

hostObj The "host" object that supports SerializeReference. For example, MonoBehaviour or ScriptableObject.
refObj The C# object, to which the reference Id will be assigned.
refId A positive number between 0 and Int64.MaxValue. This managed reference Id cannot be used by another object on the same host object. You can reuse the same managed reference Id on separate hosts.

戻り値

bool Returns true if the Id was successfully set false otherwise.

説明

Assigns a managed reference Id to an object that is referenced using SerializeReference on a specified host.

In normal usage, it is not necessary to use this method. By default, the Unity Editor automatically generates a unique id for the object when it is first serialized.

If you use this method, it should be called after the referenced object is created and before the next serialization of the host object that references it. If the object is not referenced when the host object is serialized, Unity prunes the object and discards its assigned Id. An object is "referenced" if it is directly assigned to at least one field of the host object, or is referenced indirectly via fields on other referenced objects.

After being assigned, the managed reference id persists as a permanent local identifier for the object provided the object is referenced by the host. This identifier is retained even when the host object is unloaded and reloaded.

See Also: GetManagedReferenceIdForObject, GetManagedReference, SerializeReference, SerializedProperty.managedReferenceId.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961