# TryGetValueFromBag<T>(IUxmlAttributes, CreationContext, Func<string, T, T>, T, ref T)

> Tries to get the attribute value from the attribute bag.

## Definition

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

## TryGetValueFromBag\<T>(IUxmlAttributes, CreationContext, Func\<string, T, T>, T, T)

```csharp
protected bool TryGetValueFromBag<T>(IUxmlAttributes bag, CreationContext cc, Func<string, T, T> converterFunc, T defaultValue, ref T value)
```

### Parameters

**** (\[IUxmlAttributes]\(/engine/6000.0/script-reference/unityengine/uielements/iuxmlattributes)): A bag contains attributes and their values as strings.**** (\[CreationContext]\(/engine/6000.0/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.**** (T): If the attribute could be retrieved, the retrieved value converted by the conversion function or the default value if the retrieved value could not de converted.

### Returns

| Type                                                          | Description                                  |
| ------------------------------------------------------------- | -------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | True if the value is found, false otherwise. |
