# GraphMotion

> Animation system for elements displayed in the graph canvas of a visualization Context.

## Definition

* **Type:** Class
* **Namespace:** [Unity.GraphToolkit.Editor.GraphVisualization](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization.md)
* **Assembly:** UnityEditor

```csharp
public sealed class GraphMotion
```

## Remarks

Obtain an instance from [Context.Motion](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/motion.md). Each method targets a graph element identified by a reference produced by the same [Context](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context.md). The owning context scopes animations: stopping or pausing through one [GraphMotion](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/graphmotion.md) instance only affects the graph elements referenced by that instance. Call [GraphMotion.Play](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/graphmotion/play.md) after [GraphMotion.Pause](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/graphmotion/pause.md) to resume the looped animation.

Additional Resources: [Context.Motion](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/context/motion.md)

## Examples

```csharp
NodeReference nodeRef = context.GetNodeReference(nodeID);

// Start a looping animation on the node.
context.Motion.Play(nodeRef);

// Pause it without hiding the accent bar.
context.Motion.Pause(nodeRef);

// Resume the animation at a faster speed.
context.Motion.Play(nodeRef, animationSpeed: 2f);

// Stop the animation. If a FillAmount was set, the bar remains visible at that fill.
context.Motion.Stop(nodeRef);
```

## Methods

| Method                                                                                                     | Description                                                                     |
| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| [Pause](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/graphmotion/pause.md) | Pauses the looping animation on the referenced node's accent without hiding it. |
| [Play](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/graphmotion/play.md)   | Starts a looping animation on the referenced node's accent.                     |
| [Stop](/engine/6000.6/script-reference/unity/graphtoolkit/editor/graphvisualization/graphmotion/stop.md)   | Stops the looping animation on the referenced node's accent and hides it.       |
