The GameObject
property of a Component
in the Sandbox API provides access to the GameObject
that the component is attached to. This property is essential for interacting with the GameObject's properties and other components.
The GameObject
property of a Component
in the Sandbox API provides access to the GameObject
that the component is attached to. This property is essential for interacting with the GameObject's properties and other components.
Use the GameObject
property to access the parent GameObject of a component. This is useful when you need to manipulate or query the GameObject that a component is part of.
// Example of accessing the GameObject property public class MyComponent : Component { public void PrintGameObjectName() { // Access the GameObject this component is attached to GameObject myGameObject = this.GameObject; // Print the name of the GameObject Log.Info($"This component is attached to: {myGameObject.Name}"); } }