# GetUniqueName(string[], string)

> Make a unique name using the provided name as a base. If the target name is in the provided list of existing names, a unique name is generated by appending the next available numerical increment.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.3/script-reference/unityeditor.md)
* **Assembly:** UnityEditor

```csharp
public static string GetUniqueName(string[] existingNames, string name)
```

### Parameters

**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): A list of pre-existing names.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Desired name to be used as is, or as a base.

### Returns

| Type                                                           | Description                                         |
| -------------------------------------------------------------- | --------------------------------------------------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) | A name not found in the list of pre-existing names. |

### Remarks

Additional Resources: [GameObjectUtility.GetUniqueNameForSibling](/engine/6000.3/script-reference/unityeditor/gameobjectutility/getuniquenameforsibling.md), [GameObjectUtility.EnsureUniqueNameForSibling](/engine/6000.3/script-reference/unityeditor/gameobjectutility/ensureuniquenameforsibling.md).

### Examples

```csharp
using UnityEngine;
using UnityEditor;

public class ExampleClass
{
    public void Example()
    {
        string[] names = new string[] { "Object", "Thing", "Thing (1)" };

        // will display "Object (1)"
        Debug.Log(ObjectNames.GetUniqueName(names, "Object"));

        // will display "Thing (2)"
        Debug.Log(ObjectNames.GetUniqueName(names, "Thing"));

        // will display "Other"
        Debug.Log(ObjectNames.GetUniqueName(names, "Other"));
    }
}
```
