string Name { get; set; }

robot_2Generated
code_blocksInput

Description

The Name property of a GameObject is a string that is typically used for debugging purposes and for locating the object within a scene. It provides a human-readable identifier for the GameObject, which can be useful when inspecting the scene or when logging information about the object.

Usage

To get or set the name of a GameObject, you can use the Name property directly. This property is not static, so it must be accessed through an instance of a GameObject.

Example

// Example of setting and getting the Name property of a GameObject

// Create a new GameObject
GameObject myObject = new GameObject();

// Set the name of the GameObject
myObject.Name = "PlayerCharacter";

// Retrieve the name of the GameObject
string objectName = myObject.Name;

// Output the name
// Note: Use a logging system or UI element to display the name instead of Console.WriteLine
// Debug.Log(objectName);