docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Method Instantiate

    Instantiate(GameObject, Transform, bool)

    Clones the GameObject, original, and returns the clone. This method also calls GameObjectInstantiated.

    Declaration
    public static GameObject Instantiate(GameObject original, Transform parent = null, bool worldPositionStays = true)
    Parameters
    Type Name Description
    GameObject original

    An existing GameObject that you want to make a copy of.

    Transform parent

    Parent Transform to assign to the new object.

    bool worldPositionStays

    Set true to instantiate the new object in world space, which places it in the same position as the cloned GameObject, or to offset the new object from parent.

    Returns
    Type Description
    GameObject

    The instantiated clone.

    See Also
    Instantiate(Object, Transform, bool)

    Instantiate(GameObject, Vector3, Quaternion)

    Clones the GameObject, original, and returns the clone. This method also calls GameObjectInstantiated.

    Declaration
    public static GameObject Instantiate(GameObject original, Vector3 position, Quaternion rotation)
    Parameters
    Type Name Description
    GameObject original

    An existing GameObject that you want to make a copy of.

    Vector3 position

    Position for the new object.

    Quaternion rotation

    Orientation of the new object.

    Returns
    Type Description
    GameObject

    The instantiated clone.

    See Also
    Instantiate(Object, Vector3, Quaternion)

    Instantiate(GameObject, Transform, Vector3, Quaternion)

    Clones the GameObject, original, and returns the clone. This method also calls GameObjectInstantiated.

    Declaration
    public static GameObject Instantiate(GameObject original, Transform parent, Vector3 position, Quaternion rotation)
    Parameters
    Type Name Description
    GameObject original

    An existing GameObject that you want to make a copy of

    Transform parent

    Parent that will be assigned to the new object

    Vector3 position

    Position for the new object.

    Quaternion rotation

    Orientation of the new object.

    Returns
    Type Description
    GameObject

    The instantiated clone

    See Also
    Instantiate(Object, Vector3, Quaternion, Transform)
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)