ObjectBatch

csharp
public sealed class ObjectBatch : Object

Namespace NodeWorld.Flux.

Many objects of the world handled in one go, a crossing of the boundary per frame instead of one per object and per value. The batch holds arrays in the memory of the world, one value per object (index i: GetObject(i)):

  • the fields given as read ([Read]) are filled by the client before Update, every frame;
  • the fields given as write ([Write]) and the material properties are applied by the client after LateUpdate, every frame, all at once (positions, rotations and scales by a Burst job that reads the memory of the world).

The script reads and writes the arrays in between, from any thread (Parallel.For). The objects are those of the list, the children of an object or the objects with a tag, as they are when the batch is made. Client only. Dispose (or Object.Destroy) stops it; it stops with its world.

Properties

count

csharp
public int count { get; }

The count of objects.

space

csharp
public BatchSpace space { get; }

The space of positions, rotations and scales.

read

csharp
public BatchFields read { get; }

The fields the client fills before Update.

write

csharp
public BatchFields write { get; }

The fields the client applies after LateUpdate.

positions

csharp
public Vector3[] positions { get; }

A position per object (null if the batch has no Position field).

rotations

csharp
public Quaternion[] rotations { get; }

A rotation per object (null if the batch has no Rotation field).

scales

csharp
public Vector3[] scales { get; }

A scale per object (null if the batch has no Scale field); in World space, the scale in the world.

active

csharp
public bool[] active { get; }

Whether each object is active (null if the batch has no Active field).

Methods

Create

csharp
public static ObjectBatch Create(GameObject[] objects, BatchFields read, BatchFields write, BatchSpace space = BatchSpace.World)

A batch of these objects (of the world).

FromChildren

csharp
public static ObjectBatch FromChildren(Transform parent, BatchFields read, BatchFields write, BatchSpace space = BatchSpace.Local)

A batch of the children of parent (not their own children), in their order.

WithTag

csharp
public static ObjectBatch WithTag(string tag, BatchFields read, BatchFields write, BatchSpace space = BatchSpace.World)

A batch of the active objects of the world with this tag.

GetObject

csharp
public GameObject GetObject(int index)

The object at index i of the arrays.

AddColorProperty

csharp
public Color[] AddColorProperty(string property, int materialIndex = 0)

A color property of the material (material index of each object's renderer) per object, applied after LateUpdate to that renderer alone (as Renderer.SetColor: the shared material does not change).

AddFloatProperty

csharp
public float[] AddFloatProperty(string property, int materialIndex = 0)

A float property of the material per object (as Renderer.SetFloat).

AddVectorProperty

csharp
public Vector4[] AddVectorProperty(string property, int materialIndex = 0)

A vector property of the material per object (as Renderer.SetVector).

Dispose

csharp
public void Dispose()

The batch stops: its arrays are no longer read nor applied.