Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ProwlEngine/Prowl/llms.txt

Use this file to discover all available pages before exploring further.

GameObject is the fundamental entity type in Prowl. Every object you place in a scene — characters, lights, cameras, UI roots — is a GameObject. It does not contain gameplay logic itself; instead it acts as a host for MonoBehaviour components that implement behavior. Each GameObject owns a Transform, a parent reference, a list of children, and a collection of components sorted by execution order. GameObject inherits from EngineObject, giving it an InstanceID, an AssetID, a Name, and the two-phase destroy system.

Constructors

public GameObject()
public GameObject(string name = "New GameObject")
public GameObject(AssetRef<Prefab> prefab)
var go = new GameObject();           // Name = "New GameObject"
var go2 = new GameObject("Player");  // Named explicitly

Core Properties

Transform
Transform
The Transform component that controls this object’s position, rotation, and scale. Every GameObject has exactly one Transform; it is not removable.
public Transform Transform { get; }
go.Transform.position = new Vector3(0, 1, 0);
go.Transform.localEulerAngles = new Vector3(0, 90, 0);
enabled
bool
Whether this GameObject is explicitly enabled. Setting this to false disables the object and all its descendants in the hierarchy, triggering OnDisable on every active MonoBehaviour.
public bool enabled { get; set; }
enabledInHierarchy
bool
true only when this object and every ancestor up to the scene root are all enabled. Read-only; updated automatically when the hierarchy changes.
public bool enabledInHierarchy { get; }
tag
string
The string tag of this object, resolved through TagLayerManager. Setting this stores an index internally; reading it looks up the current string for that index.
public string tag { get; set; }
go.tag = "Player";
bool isPlayer = go.CompareTag("Player"); // true
layer
string
The string layer name, also managed through TagLayerManager by index.
public string layer { get; set; }
isStatic
bool
Marks this object as static for baking/batching purposes. Runtime changes may not propagate to all subsystems immediately.
public bool isStatic { get; set; }
hideFlags
HideFlags
Controls visibility in the editor hierarchy, inspector, and serialization output.
public HideFlags hideFlags = HideFlags.None;

Hierarchy Properties

parent
GameObject?
The direct parent of this object, or null if this is a scene root object. Use SetParent(...) to modify the hierarchy.
public GameObject? parent { get; }
children
List<GameObject>
The direct children of this object. Treat as read-only; use SetParent on a child to add or remove it.
public List<GameObject> children;
childCount
int
Shorthand for children.Count.
public int childCount { get; }
Identifier
Guid
A persistent GUID that survives serialization round-trips (unlike InstanceID). Used by the prefab and cloning systems to correlate objects across copies.
public Guid Identifier { get; }
Scene
Scene?
The Scene this object belongs to, held as a WeakReference. Returns null if the object has not been added to a scene. Set automatically by Scene.Add(...).
public Scene? Scene { get; internal set; }
The link that connects this object (or one of its ancestors) to a source Prefab. null for ordinary GameObjects with no prefab ancestry.
public PrefabLink PrefabLink { get; internal set; }
Walks up the hierarchy to find the nearest PrefabLink. Returns this object’s own link first, then walks to parents. Returns null if no ancestor has a link.
public PrefabLink AffectedByPrefabLink { get; }

Hierarchy Methods

SetParent

Re-parents this GameObject under NewParent. Optionally preserves the object’s world-space position and rotation. If the new parent belongs to a different scene, the object is moved to that scene automatically.
public bool SetParent(GameObject NewParent, bool worldPositionStays = true)
NewParent
GameObject
required
The new parent. Pass null to make this object a scene root.
worldPositionStays
bool
When true (default), the object’s world-space position, rotation, and scale are preserved by recalculating local values. When false, local transform values are kept, which changes the world position.
returns
bool
true if the parent was changed; false if the operation was rejected (e.g. NewParent is a descendant of this object).
child.SetParent(parentGO);                            // preserve world position
child.SetParent(parentGO, worldPositionStays: false); // keep local values
child.SetParent(null);                                // detach to scene root

IsChildOf

Returns true if this object is anywhere in the descendant hierarchy of parent. Returns false if this object is the same as parent.
public bool IsChildOf(GameObject parent)

IsParentOf

Returns true if this object is a direct parent (or grandparent, etc.) of go. Searches the entire subtree recursively.
public bool IsParentOf(GameObject go)

IsChildOrSameTransform (static)

Returns true if transform is the same as inParent or is one of its descendants.
public static bool IsChildOrSameTransform(GameObject transform, GameObject inParent)

GetChildrenDeep

Returns all descendants (children, grandchildren, …) of this object in a flat enumerable.
public IEnumerable<GameObject> GetChildrenDeep()
public void GetChildrenDeep(List<GameObject> resultList)

GetChildAtIndexPath

Traverses the child hierarchy by following a sequence of child indices and returns the resulting object. Returns null if any index is out of range.
public GameObject GetChildAtIndexPath(IEnumerable<int> indexPath)

GetIndexPathOfChild

Determines the sequence of child indices that leads from this object down to the specified child (or grandchild, etc.).
public List<int> GetIndexPathOfChild(GameObject child)

GetSiblingIndex / SetSiblingIndex

Gets or sets the zero-based index of this object within its parent’s children list. GetSiblingIndex returns null when the object has no parent.
public int? GetSiblingIndex()
public void SetSiblingIndex(int index)

FindChildByIdentifier

Searches this object and optionally all descendants for a child with a matching Guid identifier. Returns this if this object’s own identifier matches.
public GameObject FindChildByIdentifier(Guid identifier, bool deep = true)

Component Management

AddComponent<T>

Adds a new component of type T to this GameObject. If T carries [RequireComponent], its dependencies are also added automatically. Components are sorted by [ExecutionOrder] after every add.
public T AddComponent<T>() where T : MonoBehaviour, new()
returns
T
The newly created and attached component instance.
var rb = go.AddComponent<Rigidbody>();

AddComponent (Type overload)

Non-generic version. Returns null if type does not derive from MonoBehaviour.
public MonoBehaviour AddComponent(Type type)

AddComponent (instance overload)

Attaches an already-constructed MonoBehaviour instance. Useful when you need to configure the component before Awake is called.
public void AddComponent(MonoBehaviour comp)

RemoveComponent<T>

Removes a specific component instance. Calls OnDisable (if active) and OnDestroy (if started). Will refuse to remove a component that another component declares via [RequireComponent].
public void RemoveComponent<T>(T component) where T : MonoBehaviour
component
T
required
The exact component instance to remove.

RemoveComponent (untyped overloads)

public void RemoveComponent(MonoBehaviour component)
public void RemoveComponent(Guid component)   // removes by Identifier

RemoveAll<T>

Removes all components of type T at once.
public void RemoveAll<T>() where T : MonoBehaviour

GetComponent<T>

Returns the first component of type T attached to this object, or null.
public T? GetComponent<T>() where T : MonoBehaviour
public MonoBehaviour? GetComponent(Type type)
var cam = go.GetComponent<Camera>();

TryGetComponent<T>

Pattern-match variant. Returns true and sets component when found.
public bool TryGetComponent<T>(out T? component) where T : MonoBehaviour
if (go.TryGetComponent<Rigidbody>(out var rb))
    rb.AddForce(Vector3.Up * 10f);

GetComponents<T>

Returns all components of type T on this object.
public IEnumerable<T> GetComponents<T>() where T : MonoBehaviour
public IEnumerable<MonoBehaviour> GetComponents(Type type)
public IEnumerable<MonoBehaviour> GetComponents()   // all components

GetComponentInParent<T>

Searches this object (optionally) and walks up through parents until a component of type T is found.
public T? GetComponentInParent<T>(bool includeSelf = true, bool includeInactive = false)
    where T : MonoBehaviour

public MonoBehaviour? GetComponentInParent(Type componentType,
    bool includeSelf = true, bool includeInactive = false)
includeSelf
bool
When true (default), the search starts with this object itself.
includeInactive
bool
When true, disabled objects in the parent chain are also searched.

GetComponentsInParent<T>

Returns all components of type T across this object and its ancestors.
public IEnumerable<T> GetComponentsInParent<T>(bool includeSelf = true, bool includeInactive = false)
    where T : MonoBehaviour

public IEnumerable<MonoBehaviour> GetComponentsInParent(Type type,
    bool includeSelf = true, bool includeInactive = false)

GetComponentInChildren<T>

Searches this object (optionally) and recurses through children until a component of type T is found.
public T? GetComponentInChildren<T>(bool includeSelf = true, bool includeInactive = false)
    where T : MonoBehaviour

public MonoBehaviour GetComponentInChildren(Type componentType,
    bool includeSelf = true, bool includeInactive = false)

GetComponentsInChildren<T>

Returns all components of type T across this object and all descendants.
public IEnumerable<T> GetComponentsInChildren<T>(bool includeSelf = true, bool includeInactive = false)
    where T : MonoBehaviour

public IEnumerable<MonoBehaviour> GetComponentsInChildren(Type type,
    bool includeSelf = true, bool includeInactive = false)
// Find every renderer under this root object
foreach (var r in root.GetComponentsInChildren<MeshRenderer>())
    r.material = newMat;

GetComponentByIdentifier

Finds a component on this object by its persistent Guid identifier rather than type.
public MonoBehaviour? GetComponentByIdentifier(Guid identifier)

GetComponentInChildrenByIdentifier

Finds a component by persistent Guid identifier, searching this object (optionally) and all its children.
public MonoBehaviour GetComponentInChildrenByIdentifier(Guid identifier, bool includeSelf = true)

Messaging

BroadcastMessage

Invokes a named method on every MonoBehaviour attached to this object and all of its children (recursive). Parameters are passed as a params object[].
public void BroadcastMessage(string methodName, params object[] objs)
methodName
string
required
The method name to invoke via reflection. Searched with Public | NonPublic | Instance | FlattenHierarchy.
objs
object[]
Optional arguments forwarded to the method.
go.BroadcastMessage("OnHit", damageAmount);

SendMessage

Same as BroadcastMessage but limited to components on this object only — does not recurse into children.
public void SendMessage(string methodName, params object[] objs)

CompareTag

Compares this object’s tag against a string, case-insensitively, using the current tag registry.
public bool CompareTag(string otherTag)
returns
bool
true if the tags match (case-insensitive).
if (other.CompareTag("Enemy"))
    TakeDamage(10);

Static Factory / Search Methods

Instantiate (GameObject overloads)

Deep-clones an existing GameObject. The no-parent overload explicitly adds the clone to the active scene. The parent and position/rotation overloads call SetParent to place the clone in the hierarchy (which routes it to the correct scene through the parent), but do not call SceneManager.Scene.Add directly.
public static GameObject Instantiate(GameObject original)
public static GameObject Instantiate(GameObject original, GameObject? parent)
public static GameObject Instantiate(GameObject original, Vector3 position, Quaternion rotation, GameObject? parent)
original
GameObject
required
The template object. Must not be destroyed.
parent
GameObject?
Optional parent to attach the new instance to.
position
Vector3
World-space position override applied after cloning.
rotation
Quaternion
World-space rotation override applied after cloning.
returns
GameObject
The cloned GameObject.

Instantiate (Prefab overloads)

Instantiates from an AssetRef<Prefab>. Returns null if the reference is unavailable. The no-parent and with-parent overloads add the clone to the active scene explicitly; the position/rotation overload uses SetParent to place the clone.
public static GameObject Instantiate(AssetRef<Prefab> original)
public static GameObject Instantiate(AssetRef<Prefab> original, GameObject? parent)
public static GameObject Instantiate(AssetRef<Prefab> original, GameObject? parent, Vector3 position, Quaternion rotation)
// Spawn a prefab at a world position
GameObject bullet = GameObject.Instantiate(bulletPrefab, null,
    firePoint.position, firePoint.rotation);

Find

Searches all objects in the active scene by name. Returns the first match, or null.
public static GameObject Find(string otherName, bool ignoreCase = false)
otherName
string
required
The name to search for.
ignoreCase
bool
When true, uses OrdinalIgnoreCase matching. Default is false (exact case).
GameObject hud = GameObject.Find("HUD Root");
Find iterates the entire scene graph. Do not call it in Update; cache the result in Awake or Start.

FindGameObjectWithTag

Returns the first GameObject in the scene whose tag matches otherTag (case-insensitive).
public static GameObject FindGameObjectWithTag(string otherTag)

FindGameObjectsWithTag

Returns an array of all GameObjects in the scene with the given tag.
public static GameObject[] FindGameObjectsWithTag(string otherTag)
GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
foreach (var e in enemies)
    e.enabled = false;

Cloning

public new GameObject Clone()
public void CopyTo(GameObject target)
Clone() performs a deep copy via Prowl’s cloning infrastructure, producing a new GameObject with new InstanceID and component instances. CopyTo copies data into an existing target (used by the prefab apply system).

Serialization

GameObject implements ISerializable and stores the full hierarchy (children, components, transform) into Prowl’s EchoObject format. Normally you interact with this indirectly through SceneManager and the asset pipeline.
public void Serialize(ref EchoObject compoundTag, SerializationContext ctx)
public void Deserialize(EchoObject value, SerializationContext ctx)

Build docs developers (and LLMs) love