Version: 2020.1
언어: 한국어

GameObjectUtility.GetUniqueNameForSibling

매뉴얼로 전환
public static string GetUniqueNameForSibling (Transform parent, string name);

파라미터

parent Target parent for a new GameObject. Null means root level.
name Requested name for a new GameObject.

반환

string Unique name for a new GameObject.

설명

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.