void AddSibling( GameObject go, bool before, bool keepWorldPosition )

robot_2Generated
code_blocksInput

Description

The AddSibling method allows you to add a sibling GameObject to the current GameObject. This method is useful when you want to organize GameObjects in a specific order within the scene hierarchy. You can specify whether the new sibling should be placed before or after the current GameObject and whether the world position should be maintained.

Usage

To use the AddSibling method, call it on an instance of a GameObject. Pass the GameObject you want to add as a sibling, a boolean indicating whether it should be placed before the current GameObject, and another boolean indicating whether to keep the world position unchanged.

Example

// Example of using AddSibling
GameObject currentGameObject = new GameObject();
GameObject newSibling = new GameObject();

// Add newSibling as a sibling after the currentGameObject, keeping the world position
currentGameObject.AddSibling(newSibling, before: false, keepWorldPosition: true);