Description
The AddSibling
method allows you to add a sibling GameObject
to the current GameObject
. This method is useful when you want to organize your scene hierarchy by adding objects at the same level as the current object. You can specify whether the new sibling should be placed before or after the current object, 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 to place it before the current object, and another boolean indicating whether to keep the world position unchanged.
Example
// Example of using AddSibling
GameObject currentObject = new GameObject();
GameObject newSibling = new GameObject();
// Add newSibling as a sibling after currentObject, keeping the world position
currentObject.AddSibling(newSibling, false, true);