GameObjectUtility.GetUniqueNameForSibling

Switch to Manual
public static string GetUniqueNameForSibling (Transform parent, string name);

Parameters

parentTarget parent for a new GameObject. Null means root level.
nameВозвращает navmesh слой для указанного GameObject'а.

Returns

string Возвращает navmesh слой для указанного GameObject'а.

Description

You can use this method before instantiating a new sibling, or before parenting one GameObject to another, to ensure the new child GameObject has a unique name compared to its siblings in the hierarchy.

To use this method, you must provide a "target parent", and a "requested name". The method uses an incremental numeric suffix appended to the name to avoid duplicate names.

If the target parent that you specify does not already have a child with the requested name that you specify, the method will return the requested name. If the target parent does have a child object matching the requested name, the method will add an incremental number after the requested name until it finds one that is unique. This is useful when trying to avoid duplicate naming.

Note: You should use this method before the GameObject becomes a child of the target parent. If you use this method after the GameObject is already a child of the target parent, it will detect its own name among the siblings as a conflict! If you want to perform the check after the GameObject is a child of the target parent, you can use GameObjectUtility.EnsureUniqueNameForSibling instead.

See Also: GameObjectUtility.EnsureUniqueNameForSibling, ObjectNames.GetUniqueName.

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