# TrySetValue<T>(T)

> Sets a new value to the port's UI field.

## Definition

* **Type:** Method
* **Namespace:** [Unity.GraphToolkit.Editor](/engine/6000.7/script-reference/unity/graphtoolkit/editor.md)
* **Assembly:** UnityEditor

```csharp
bool TrySetValue<T>(T value)
```

### Parameters

**** (T): The value to assign to the port’s UI field.

### Returns

| Type                                                          | Description                                                   |
| ------------------------------------------------------------- | ------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the value was successfully set; otherwise, `false`. |

### Remarks

This method is intended for editor-time edition of an input port’s value, configured through a field displayed in the UI. If the port is connected, the field is hidden and no value is available, so the method returns `false`. It also performs a type check and conversion internally. If the value cannot be cast to [IPort.DataType](/engine/6000.7/script-reference/unity/graphtoolkit/editor/iport/datatype.md), the method returns `false`.
