# GetValueFromBag<T>(IUxmlAttributes, CreationContext, Func<string, T, T>, T)

> Get the attribute value from the attribute bag.

## Definition

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

> **Warning:**
>
> **Deprecated.** UxmlTraits system is deprecated and will be removed. Use UxmlElementAttribute instead.

```csharp
protected T GetValueFromBag<T>(IUxmlAttributes bag, CreationContext cc, Func<string, T, T> converterFunc, T defaultValue)
```

### Parameters

**** (\[IUxmlAttributes]\(/engine/6000.5/script-reference/unityengine/uielements/iuxmlattributes)): A bag containing attributes and their values as strings.**** (\[CreationContext]\(/engine/6000.5/script-reference/unityengine/uielements/creationcontext)): The context in which the values are retrieved.**** (\[Func\<string, T, T>]\(https\://learn.microsoft.com/dotnet/api/system.func-1)): A function to convert a string value to type T.**** (T): The value to return if the attribute is not found in the bag.

### Returns

| Type | Description                                                                      |
| ---- | -------------------------------------------------------------------------------- |
| T    | The attribute value from the bag, or defaultValue if the attribute is not found. |

### Remarks

The attribute is looked up using [\_name](/engine/6000.5/script-reference/unityengine/uielements/uxmlattributedescription/name.md). If it is not found, each [\_obsoleteNames](/engine/6000.5/script-reference/unityengine/uielements/uxmlattributedescription/obsoletenames.md) is tried in turn, from first to last.
