• Studio

  • Studio API

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Object

    The 'Object' class serves as the foundational layer for all elements in Unity scenes. Whether building intricate environments with GameObjects, infusing functionality through Components, or enhancing realism with Unity's pre-built assets such as textures and meshes, everything stems from the root 'Object' class.

    Moreover, the 'Object' class provides an interactive gateway to Unity's lifecycle events. This includes initialization of objects upon creation, updates occurring in tandem with the game's frame rate, and the clean-up processes when objects are destroyed. This understanding of the object lifecycle is pivotal in managing memory usage, performance optimisation, and orchestrating smooth gameplay sequences.

    To grasp the full extent of how the 'Object' class shapes the world of Unity, head over to the official Unity documentation for detailed insights.

    Properties

    name

    string

    The name property represents the name of the Object. This could be the name you gave an asset in Unity, or the default name of a created GameObject, like 'GameObject1'. Find out more.

    Methods

    Immediately destroys the specified Object. You are strongly recommended to use Destroy instead. This function should only be used when writing editor code because it completely bypasses Unity's normal life-cycle events. More details here.

    Parameters

    The Object to destroy.

    Returns

    void

    Does not return anything.

    Destroys the specified Object after all frame updates have finished processing. Learn more.

    Parameters

    The Object to destroy.

    Returns

    void

    Does not return anything.

    The 'Instantiate' method clones the object original and returns the clone. This can be immensely useful in various gameplay mechanics like respawning, shooting projectiles, etc. Learn more about Instantiate here.

    Parameters

    A reference to the object to be cloned.

    Returns

    Object

    The newly cloned object.

    The 'GetInstanceID' method provides a unique identifer for the object instance. More details about Instance IDs can be found here.

    Returns

    number

    The unique identifier for the object instance.

    Makes the object target not be destroyed automatically when loading a new scene, which is the default behavior. Learn more here.

    Parameters

    target
    Object

    The Object that should not be destroyed.

    Returns

    void

    This method does not return a value.

    This method returns the first active loaded object of the given type. It is a generic method with return type of the generic parameter. It returns null if no GameObject is active in the hierarchy. More details can be obtained here.

    Parameters

    type
    Type

    The type of the Object to find.

    Returns

    Object

    The object found or null.

    This method returns the first object to match the specified type, including inactive objects. It is slower than FindObjectByType, as it searches all objects in the scene, not just the active ones. Learn more here.

    Parameters

    type
    Type

    The type of Object to find.

    Returns

    Object

    The discovered object.

    The 'FindAnyObjectByType' method finds all objects in the scene of the specified type, including active and inactive ones. As the method must search every single object in the scene, this operation can be performance-intensive. Details here.

    Parameters

    type
    Type

    Type of Object to find.

    Returns

    Object

    All objects found.

    Updated about 1 month ago

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.