Class SerializedSwiftArray2D<T>
- Namespace
- SwiftCollections.Unity
Unity-serializable adapter for persisted authoring data that is consumed as a SwiftArray2D<T>.
[Serializable]
public sealed class SerializedSwiftArray2D<T> : ISerializationCallbackReceiver
Type Parameters
TA Unity-serializable item type.
- Inheritance
-
SerializedSwiftArray2D<T>
- Implements
-
ISerializationCallbackReceiver
- Inherited Members
Properties
Height
Gets the serialized height.
public int Height { get; }
Property Value
this[int, int]
Gets or sets the item at the specified coordinates.
public T this[int x, int y] { get; set; }
Parameters
Property Value
- T
The item at the specified coordinates.
Length
Gets the total serialized item count.
public int Length { get; }
Property Value
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
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
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
widthintThe array width.
heightintThe array height.
itemsT[]Flat item data in SwiftArray2D index order.
Exceptions
- ArgumentNullException
itemsis null.- ArgumentOutOfRangeException
A dimension is negative or the resulting array is too large.
- ArgumentException
The item count does not equal
widthmultiplied byheight.
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.