# GenerateTexture

> Generates Texture2D and Sprite Assets based on the settings provided.

## Definition

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

## GenerateTexture(TextureGenerationSettings, NativeArray\<Color32>)

Generates [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md) Assets based on the settings provided.

```csharp
public static TextureGenerationOutput GenerateTexture(TextureGenerationSettings settings, NativeArray<Color32> colorBuffer)
```

### Parameters

**** (\[TextureGenerationSettings]\(/engine/6000.7/script-reference/unityeditor/assetimporters/texturegenerationsettings)): Settings use for generating [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md).**** (\[NativeArray\<Color32>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): Color buffer for generating [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md).

### Returns

| Type                                                                                                             | Description               |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------- |
| [TextureGenerationOutput](/engine/6000.7/script-reference/unityeditor/assetimporters/texturegenerationoutput.md) | Result of the generation. |

### Remarks

As Unity may perform in-place processing of `colorBuffer`, it is recommended that you make a copy of its original data if you need it after this method returns.

The `System.Span<T>` overloads accept any writable contiguous block of memory, such as a managed array or a [NativeArray](/engine/6000.7/script-reference/unity/collections/nativearray1.md).

## GenerateTexture(TextureGenerationSettings, NativeArray\<Color>)

Generates [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md) Assets based on the settings provided.

```csharp
public static TextureGenerationOutput GenerateTexture(TextureGenerationSettings settings, NativeArray<Color> colorBuffer)
```

### Parameters

**** (\[TextureGenerationSettings]\(/engine/6000.7/script-reference/unityeditor/assetimporters/texturegenerationsettings)): Settings use for generating [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md).**** (\[NativeArray\<Color>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): Color buffer for generating [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md).

### Returns

| Type                                                                                                             | Description               |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------- |
| [TextureGenerationOutput](/engine/6000.7/script-reference/unityeditor/assetimporters/texturegenerationoutput.md) | Result of the generation. |

### Remarks

As Unity may perform in-place processing of `colorBuffer`, it is recommended that you make a copy of its original data if you need it after this method returns.

The `System.Span<T>` overloads accept any writable contiguous block of memory, such as a managed array or a [NativeArray](/engine/6000.7/script-reference/unity/collections/nativearray1.md).

## GenerateTexture(TextureGenerationSettings, Span\<Color32>)

Generates [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md) Assets based on the settings provided.

```csharp
public static TextureGenerationOutput GenerateTexture(TextureGenerationSettings settings, Span<Color32> colorBuffer)
```

### Parameters

**** (\[TextureGenerationSettings]\(/engine/6000.7/script-reference/unityeditor/assetimporters/texturegenerationsettings)): Settings use for generating [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md).**** (\[Span\<Color32>]\(https\://learn.microsoft.com/dotnet/api/system.span-1)): Color buffer for generating [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md).

### Returns

| Type                                                                                                             | Description               |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------- |
| [TextureGenerationOutput](/engine/6000.7/script-reference/unityeditor/assetimporters/texturegenerationoutput.md) | Result of the generation. |

### Remarks

As Unity may perform in-place processing of `colorBuffer`, it is recommended that you make a copy of its original data if you need it after this method returns.

The `System.Span<T>` overloads accept any writable contiguous block of memory, such as a managed array or a [NativeArray](/engine/6000.7/script-reference/unity/collections/nativearray1.md).

## GenerateTexture(TextureGenerationSettings, Span\<Color>)

Generates [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md) Assets based on the settings provided.

```csharp
public static TextureGenerationOutput GenerateTexture(TextureGenerationSettings settings, Span<Color> colorBuffer)
```

### Parameters

**** (\[TextureGenerationSettings]\(/engine/6000.7/script-reference/unityeditor/assetimporters/texturegenerationsettings)): Settings use for generating [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md).**** (\[Span\<Color>]\(https\://learn.microsoft.com/dotnet/api/system.span-1)): Color buffer for generating [Texture2D](/engine/6000.7/script-reference/unityengine/texture2d.md) and [Sprite](/engine/6000.7/script-reference/unityengine/sprite.md).

### Returns

| Type                                                                                                             | Description               |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------- |
| [TextureGenerationOutput](/engine/6000.7/script-reference/unityeditor/assetimporters/texturegenerationoutput.md) | Result of the generation. |

### Remarks

As Unity may perform in-place processing of `colorBuffer`, it is recommended that you make a copy of its original data if you need it after this method returns.

The `System.Span<T>` overloads accept any writable contiguous block of memory, such as a managed array or a [NativeArray](/engine/6000.7/script-reference/unity/collections/nativearray1.md).
