# CreateGameObjectWithHideFlags(string, HideFlags, params Type[])

> Creates a game object with HideFlags and specified components.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.0/script-reference/unityeditor.md)
* **Assembly:** UnityEditor

## CreateGameObjectWithHideFlags(string, HideFlags, Type\[])

```csharp
public static GameObject CreateGameObjectWithHideFlags(string name, HideFlags flags, params Type[] components)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): **** (\[HideFlags]\(/engine/6000.0/script-reference/unityengine/hideflags)): **** (\[Type\[]]\(https\://learn.microsoft.com/dotnet/api/system.type)):&#x20;

### Returns

| Type                                                                    | Description |
| ----------------------------------------------------------------------- | ----------- |
| [GameObject](/engine/6000.0/script-reference/unityengine/gameobject.md) |             |

### Remarks

This is very similar to creating a [GameObject](/engine/6000.0/script-reference/unityengine/gameobject.md) the usual way, except it sets the specified [HideFlags](/engine/6000.0/script-reference/unityengine/hideflags.md) immediately.

![EditorUtility CreateGameObjectWithHideFlags (CreateGameObjectWithHideFlags(string, HideFlags, params Type\[\]))](</api/media?file=/engine/6000.0/media/images/EditorUtility CreateGameObjectWithHideFlags.png>)

*Editor Window that shows how does the example looks.*

### Examples

```csharp
using UnityEngine;
using UnityEditor;

public class CreateGOHideFlagsExample : EditorWindow
{
    string objName = "GameObject";
    int instanceID = 0;
    bool create = true;
    GameObject go = null;
    bool hideHierarchy = false;

    [MenuItem("Example/GameObject Flags")]
    static void Init()
    {
        // Get existing open window or if none, make a new one:
        CreateGOHideFlagsExample window = (CreateGOHideFlagsExample)EditorWindow.GetWindow(typeof(CreateGOHideFlagsExample));
        window.Show();
    }

    void OnGUI()
    {
        create = EditorGUILayout.Toggle("Create a GO:", create);
        GUI.enabled = create;

        objName = EditorGUILayout.TextField("GameObject Name:", objName);
        if (GUILayout.Button("Create"))
        {
            GameObject created = EditorUtility.CreateGameObjectWithHideFlags(objName,
                hideHierarchy ? HideFlags.HideInHierarchy : 0);

            instanceID = created.GetInstanceID();
            Debug.Log("Created GameObject ID: " + instanceID);
        }

        GUI.enabled = !create;

        EditorGUILayout.BeginHorizontal();

        instanceID = EditorGUILayout.IntField("Instance ID:", instanceID);

        if (GUILayout.Button("Search & Update flags"))
        {
            go = null;
            go = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
            if (go)
                go.hideFlags = hideHierarchy ? HideFlags.HideInHierarchy : 0;
        }

        EditorGUILayout.EndHorizontal();

        if (!go)
            EditorGUILayout.LabelField("Object: ", (go == null) ? "No object was found" : go.name);

        GUI.enabled = true;
        hideHierarchy = EditorGUILayout.Toggle("HideInHierarchy", hideHierarchy);
    }

    void OnInspectorUpdate()
    {
        Repaint();
    }
}
```
