Table of Contents

Class SerializedSwiftArray2D<T>

Unity-serializable adapter for persisted authoring data that is consumed as a SwiftArray2D<T>.

[Serializable]
public sealed class SerializedSwiftArray2D<T> : ISerializationCallbackReceiver

Type Parameters

T

A Unity-serializable item type.

Inheritance
SerializedSwiftArray2D<T>
Implements
ISerializationCallbackReceiver
Inherited Members

Properties

Height

Gets the serialized height.

public int Height { get; }

Property Value

int

this[int, int]

Gets or sets the item at the specified coordinates.

public T this[int x, int y] { get; set; }

Parameters

x int

The zero-based horizontal coordinate.

y int

The zero-based vertical coordinate.

Property Value

T

The item at the specified coordinates.

Length

Gets the total serialized item count.

public int Length { get; }

Property Value

int

Runtime

Gets the live runtime 2D array rebuilt from Unity serialized data.

public SwiftArray2D<T> Runtime { get; }

Property Value

SwiftArray2D<T>

Remarks

Direct runtime mutations are copied into serialized backing data before Unity serialization.

Width

Gets the serialized width.

public int Width { get; }

Property Value

int

Methods

Clear()

Clears all serialized values without changing dimensions.

public void Clear()

OnAfterDeserialize()

Rebuilds runtime contents after Unity deserialization.

public void OnAfterDeserialize()

Exceptions

ArgumentOutOfRangeException

A serialized dimension is invalid.

ArgumentException

The serialized item count does not match the dimensions.

OnBeforeSerialize()

Copies live runtime contents into Unity's serialized backing data.

public void OnBeforeSerialize()

Resize(int, int)

Resizes the runtime array and updates the serialized backing data.

public void Resize(int width, int height)

Parameters

width int

The new width.

height int

The new height.

Exceptions

ArgumentOutOfRangeException

A dimension is negative or the resulting array is too large.

SetItems(int, int, params T[])

Replaces the serialized contents with the supplied dimensions and flat item data.

public void SetItems(int width, int height, params T[] items)

Parameters

width int

The array width.

height int

The array height.

items T[]

Flat item data in SwiftArray2D index order.

Exceptions

ArgumentNullException

items is null.

ArgumentOutOfRangeException

A dimension is negative or the resulting array is too large.

ArgumentException

The item count does not equal width multiplied by height.

ToFlatArray()

Returns a copy of the flattened serialized data.

public T[] ToFlatArray()

Returns

T[]

A new flat array in SwiftArray2D index order.

ToSwiftArray2D()

Returns a copy as a standalone SwiftArray2D<T>.

public SwiftArray2D<T> ToSwiftArray2D()

Returns

SwiftArray2D<T>

A new 2D array containing the current values.