Table of Contents

Struct VisualRef<T>

Used to store references to long-lived visuals that may need to be manually deleted in the future.
Since visual data can be deleted or recycled automatically, this includes checks to ensure that the reference is still valid.

public readonly struct VisualRef<T> where T : unmanaged, IVisual

Type Parameters

T

Methods

Delete()

Deletes the referenced visual if it is still valid.
Does nothing otherwise.

public void Delete()

Deref()

Returns the referenced visual data. If this reference is no longer valid a dummy value is returned.

public ref T Deref()

Returns

T

DerefFast()

Assumes this ref is valid and returns the referenced visual data.
May through an out of range exception, or return a reference to inactive visual data, so generally use this if only you know the reference is valid or by doing a validity check beforehand.

VisualRef<Line> r = Draw.Line(p1, p2).Ref();
// ...
if (r) {
    // DerefFast is safe to use here wrapped in the validity check.
    ref Line line = r.DerefFast();
}
public ref T DerefFast()

Returns

T

Operators

implicit operator bool(VisualRef<T>)

public static implicit operator bool(VisualRef<T> @this)

Parameters

this VisualRef<T>

Returns

bool