# CreateInstance

> Creates a new instance of a serialized object of type T.

## Definition

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

## CreateInstance\<T>()

Creates a new instance of a serialized object of type T.

```csharp
public static T CreateInstance<T>() where T : Object
```

### Returns

| Type | Description                  |
| ---- | ---------------------------- |
| T    | The new object, as type `T`. |

### Remarks

Use this method to create any type of serialized object in the Unity Editor. The new instance uses default values. This generic overload returns the object as type `T`, so you don't need to cast it.

## CreateInstance(Type)

Creates a new instance of a serialized object of the specified type.

```csharp
public static Object CreateInstance(Type type)
```

### Parameters

**** (\[Type]\(https\://learn.microsoft.com/dotnet/api/system.type)): The type of object to create.

### Returns

| Type                                                            | Description     |
| --------------------------------------------------------------- | --------------- |
| [Object](/engine/7000.0/script-reference/unityengine/object.md) | The new object. |

### Remarks

Use this method to create any type of serialized object in the Unity Editor. The new instance uses default values.

### Examples

```csharp
using UnityEngine;
using UnityEditor;

public class CreateInstanceExample
{
    [MenuItem("ObjectFactoryExample/Create Material Asset")]
    public void CreateMaterialEditor()
    {
        Material material = ObjectFactory.CreateInstance<Material>();
        material.shader = Shader.Find("Transparent/Diffuse");
        AssetDatabase.CreateAsset(material, "Assets/newMaterial.mat");
    }
}
```
