# GetPreferredWidth(string, TextGenerationSettings)

> Given a string and settings, returns the preferred width for a container that would hold this text.

## Definition

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

```csharp
public float GetPreferredWidth(string str, TextGenerationSettings settings)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Generation text.**** (\[TextGenerationSettings]\(/engine/6000.5/script-reference/unityengine/textgenerationsettings)): Settings for generation.

### Returns

| Type                                                          | Description      |
| ------------------------------------------------------------- | ---------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | Preferred width. |
