# CreateInstance

> Creates an instance of a scriptable object.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.6/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## CreateInstance(string)

Creates an instance of a scriptable object.

```csharp
public static ScriptableObject CreateInstance(string className)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The type of the ScriptableObject to create, as the name of the type.

### Returns

| Type                                                                                | Description                   |
| ----------------------------------------------------------------------------------- | ----------------------------- |
| [ScriptableObject](/engine/6000.6/script-reference/unityengine/scriptableobject.md) | The created ScriptableObject. |

### Remarks

To easily create a ScriptableObject instance that is bound to a .asset file via the Editor user interface, consider using [CreateAssetMenuAttribute](/engine/6000.6/script-reference/unityengine/createassetmenuattribute.md).

### Examples

```csharp
using UnityEngine;

public class MyData : ScriptableObject
{
    public int value;
}

public class CreateInstance : MonoBehaviour
{
    void Start()
    {
        ScriptableObject nonGenericInstance = ScriptableObject.CreateInstance(typeof(MyData));
        ((MyData)nonGenericInstance).value = 20;
        Debug.Log("Non-generic instance value: " + ((MyData)nonGenericInstance).value);
    }
}
```

## CreateInstance(Type)

Creates an instance of a scriptable object.

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

### Parameters

**** (\[Type]\(https\://learn.microsoft.com/dotnet/api/system.type)): The type of the ScriptableObject to create, as a System.Type instance.

### Returns

| Type                                                                                | Description                   |
| ----------------------------------------------------------------------------------- | ----------------------------- |
| [ScriptableObject](/engine/6000.6/script-reference/unityengine/scriptableobject.md) | The created ScriptableObject. |

### Remarks

To easily create a ScriptableObject instance that is bound to a .asset file via the Editor user interface, consider using [CreateAssetMenuAttribute](/engine/6000.6/script-reference/unityengine/createassetmenuattribute.md).

### Examples

```csharp
using UnityEngine;

public class MyData : ScriptableObject
{
    public int value;
}

public class CreateInstance : MonoBehaviour
{
    void Start()
    {
        ScriptableObject nonGenericInstance = ScriptableObject.CreateInstance(typeof(MyData));
        ((MyData)nonGenericInstance).value = 20;
        Debug.Log("Non-generic instance value: " + ((MyData)nonGenericInstance).value);
    }
}
```

## CreateInstance\<T>()

Creates an instance of a scriptable object.

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

### Returns

| Type | Description                   |
| ---- | ----------------------------- |
| T    | The created ScriptableObject. |

### Remarks

To easily create a ScriptableObject instance that is bound to a .asset file via the Editor user interface, consider using [CreateAssetMenuAttribute](/engine/6000.6/script-reference/unityengine/createassetmenuattribute.md).

### Examples

```csharp
using UnityEngine;

public class MyData : ScriptableObject
{
    public int value;
}

public class CreateInstanceGeneric : MonoBehaviour
{
    void Start()
    {
        MyData genericInstance = ScriptableObject.CreateInstance<MyData>();
        genericInstance.value = 10;
        Debug.Log("Generic instance value: " + genericInstance.value);
    }
}
```
