PortReference
Identifies a port inside a visualization PortReference.Context so visualization changes can be applied to it.
Read time 1 minuteLast updated 6 days ago
Definition
- Type: Struct
- Namespace: Unity.GraphToolkit.Editor.GraphVisualization
- Assembly: UnityEditor
- Implements: IEquatable<PortReference>
public readonly struct PortReference : IEquatable<PortReference>
Remarks
Obtain a PortReference from Context.GetPortReference, providing the unique identifier of the port. The reference is only meaningful for the PortReference.Context that produced it. You can use its methods to set, retrieve, or clear the port preview for that specific port in the graph canvas. Port preview is a visualization feature that displays a label next to a port in the graph canvas. This label provides additional information about the port's value or state. Two PortReference values are equal when they share the same PortReference.PortID and refer to the same PortReference.Context instance.
Additional Resources: PortReference.Context, Context.GetPortReference
Examples
using var context = Registry.CreateVisualizationContext(graph.ID);context.GetPortReference(portID).SetPreview("42.0");if (context.GetPortReference(portID).TryGetPreview(out var displayValue)) Debug.Log(displayValue);context.GetPortReference(portID).ClearPreview();
Properties
Property | Description |
|---|---|
| Context | Visualization context that produced the current port reference. |
| PortID | Unique identifier of the port the reference points to. |
Methods
Method | Description |
|---|---|
| ClearPreview | Clears the port preview for the specified port. |
| Equals | Indicates whether the current PortReference is equal to another object. |
| GetHashCode | Returns a hash code for the current PortReference. |
| SetPreview | Sets the string value to display in a port preview for a given port. |
| TryGetPreview | Retrieves the current string value assigned to the port preview for a given port. |
Operators
Operator | Description |
|---|---|
| operator == | Compares two PortReference values for equality. |
| operator != | Compares two PortReference values for inequality. |