# Context

> Provides access to visualization data and features for a graph.

## Definition

* **Type:** Class
* **Namespace:** [Unity.GraphToolkit.Editor.GraphVisualization](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization.md)
* **Assembly:** UnityEditor
* **Implements:** [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
public sealed class Context : IDisposable
```

## Remarks

Create a [Context](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context.md) through [Registry.CreateVisualizationContext](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/registry/createvisualizationcontext.md). The context remains valid until you call [Context.Dispose](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/dispose.md). While the context is alive, you can apply visualization changes to graph elements (retrieved as references) in the associated graph. Each context has a unique [Context.VisualizationContextID](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/visualizationcontextid.md) assigned at creation, which lets you distinguish ownership when multiple consumers operate on the same graph. Disposing the context unregisters it from the [Registry](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/registry.md) and clears any visualization data added through it.

Additional Resources: [Registry](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/registry.md), [GraphMotion](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/graphmotion.md)

Create a visualization context for a graph, retrieve a port reference from it, and set a port preview value. The using statement ensures the context is disposed when no longer needed.

## Examples

```csharp
using Context context = Registry.CreateVisualizationContext(graphID);
PortReference port = context.GetPortReference(portUID);
port.SetPreview("42.0");
```

## Properties

| Property                                                                                                                                     | Description                                                                                                                                                                                                   |
| -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [IsGraphLoaded](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/isgraphloaded.md)                       | Indicates whether the graph identified by the associated [Graph.ID](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graph/id.md) is currently loaded.                                               |
| [IsValid](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/isvalid.md)                                   | Indicates whether this context can still be used. The value becomes false after [Context.Dispose](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/dispose.md) is called. |
| [Motion](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/motion.md)                                     | The animation system used to drive animations on graph elements in this visualization context.                                                                                                                |
| [NodeCustomizationEnabled](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/nodecustomizationenabled.md) | Whether the node customization feature is enabled for this visualization context. Enabled by default.                                                                                                         |
| [PortPreviewEnabled](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/portpreviewenabled.md)             | Whether the port preview feature is enabled for this visualization context. Enabled by default.                                                                                                               |
| [VisualizationContextID](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/visualizationcontextid.md)     | The unique identifier for this context.                                                                                                                                                                       |
| [WireCustomizationEnabled](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/wirecustomizationenabled.md) | Whether the wire customization feature is enabled for this visualization context. Enabled by default.                                                                                                         |

## Methods

| Method                                                                                                                                 | Description                                                                                                                                                                                            |
| -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [ClearAllVisualization](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/clearallvisualization.md) | Clears all visualization data associated with this context.                                                                                                                                            |
| [Dispose](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/dispose.md)                             | Releases this context and clears all associated visualization data.                                                                                                                                    |
| [GetNodeReference](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/getnodereference.md)           | Returns a [NodeReference](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/nodereference.md) that identifies the node with the given ID within this visualization context. |
| [GetPortReference](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/getportreference.md)           | Retrieves a reference to a port in the graph associated with this context, using the port's unique identifier.                                                                                         |
| [GetWireReference](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/getwirereference.md)           | Returns a [WireReference](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/wirereference.md) that identifies the node with the given ID within this visualization context. |
