void MakeNameUnique()

robot_2Generated
code_blocksInput

Description

The MakeNameUnique method ensures that the Name property of the GameObject is unique within its scene. This is useful when you want to avoid name conflicts, especially when dynamically creating or cloning objects in the scene.

Usage

Call this method on a GameObject instance when you need to ensure its name is unique within the scene. This is particularly useful after cloning objects or when multiple objects are created with the same initial name.

Example

// Example of using MakeNameUnique
GameObject myObject = new GameObject();
myObject.Name = "Player";

// Ensure the name is unique within the scene
myObject.MakeNameUnique();

// Now myObject.Name is guaranteed to be unique in the scene