Introducing Generators

We added generators to version 1.2 of Extensions. A generator, in our terminology, is an object that can give you new instances of a type on demand.

(This is similar to random number generators, which gives you a new number whenever you ask it).

We provide a few classes that make generators more powerful:

BatchGenerator: This returns batches of objects. Each batch is a copy of a list of objects, called the batch template. The main purpose of this generator is to plug it into a ShuffledBatchGenerator.

ShuffledBatchGenerator: This generator returns elements from batches, but with each batch shuffled. It takes a batch generator as input. If your batch template is ABC, then the following is an example of a sequence of elements returned by the ShuffledBatchGenerator: ACBBCACAB… Note that successive groups of three elements contains ABC exactly once.

Buffer: This generator returns the same elements as a given generator, but buffers a fixed number of elements that can be “peeked”. This makes it easier to implement mechanics where the player is shown upcoming objects (such as in tile match games, where the player is shown a number of tiles coming up).

[button url=”https://gamelogic.co.za/2015/02/18/gamelogic-extensions-for-unity-1-2-is-now-available/”]Find out more about Extensions 1.2[/button] [button url=”https://www.assetstore.unity3d.com/en/#!/content/19323″]Download Extensions from the Asset Store[/button]

Scroll to Top