docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Method CreateGameObject

    CreateGameObject(GameObject, string, params Type[])

    Create a game object

    Declaration
    public static GameObject CreateGameObject(GameObject parent, string name, params Type[] types)
    Parameters
    Type Name Description
    GameObject parent

    The parent

    string name

    The wanted name (can be updated with a number if a sibling with same name exist

    Type[] types

    Required component on this object in addition to Transform

    Returns
    Type Description
    GameObject

    The created object

    CreateGameObject(string, Object)

    Creates a new GameObject and set it's position to the current view

    Declaration
    public static GameObject CreateGameObject(string name, Object context)
    Parameters
    Type Name Description
    string name

    the name of the new gameobject

    Object context

    the parent of the gameobject

    Returns
    Type Description
    GameObject

    the created GameObject

    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)