string Name { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Name property of a GameObject is a string that represents the name of the object. This name is primarily used for debugging purposes and for locating the object within a scene. It is a public, non-static property, meaning it can be accessed and modified from outside the class, and each instance of GameObject can have its own unique name.

Usage

To get or set the name of a GameObject, you can use the Name property directly. This can be useful for identifying objects during debugging or when you need to find a specific object in the scene by name.

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: Avoid using Console.WriteLine in Sandbox, use appropriate logging or debugging tools
// Debug.Log(objectName);