Onerat Games
  • Home
  • Games
    • Elden: Path of the Forgotten
    • Outback
    • Itch.io
  • Learn
    • Onerat's C# Console Engine >
      • Getting Started
      • Scripting API >
        • GameObject
        • Rigidbody
        • Transfrom
        • Component
        • Input
        • Rect
        • Screen
        • Vector2
        • Console Engine Math
      • Lessions >
        • Lesson 1: Snake
        • Lesson 2: Particle Simulation
        • Lesson 3: Tetris
      • Donate
      • Download
  • Asset Store
GameObject Class Documentation

GameObject Class


Constructor

GameObject(Vector2Int Position, string Name = "GameObject"): Constructs a new instance of the GameObject class with the specified position and name.

Properties

  • _Name: The name of the GameObject.
  • transform: The Transform component attached to the GameObject, representing its position, rotation, and scale.

Methods

  • AddComponent(Component component): Adds a new Component to the GameObject.
  • AddComponent<T>(): Adds a new instance of a specified Component type to the GameObject.
  • GetComponent<T>(): Retrieves the first Component of a specified type attached to the GameObject.

Example Usage


// Create a new GameObject
Vector2 position = new Vector2Int(0f, 0f);
string name = "MyObject";
GameObject myObject = new GameObject(position, name);

// Add a custom Component to the GameObject
myObject.AddComponent<Component>();

// Get a custom Component from the GameObject
myObject.GetComponent<Component>();

// Retrieve the Transform component
Transform transform = myObject.transfrom;
  
Powered by Create your own unique website with customizable templates.
  • Home
  • Games
    • Elden: Path of the Forgotten
    • Outback
    • Itch.io
  • Learn
    • Onerat's C# Console Engine >
      • Getting Started
      • Scripting API >
        • GameObject
        • Rigidbody
        • Transfrom
        • Component
        • Input
        • Rect
        • Screen
        • Vector2
        • Console Engine Math
      • Lessions >
        • Lesson 1: Snake
        • Lesson 2: Particle Simulation
        • Lesson 3: Tetris
      • Donate
      • Download
  • Asset Store