DotMatrix


Introduction

DotMatrix is low resolution display for example to clocks, elevators, road signs or to show scrolling texts. Each dot in display is object that changes color (or rotation in case of 3D display) to show wanted content. Content can be added to display with simple commands or dot by dot.

This kind of displays typically have very low resolution, like 120*9 dots (for scrolling texts) or maybe even just 5*7 dots (for example 1 digit elevator floor number display). There is no limit on display dot-size, but huge ones obviously may have impact on frame rate. DotMatrix also supports having more than one color in same display.


How to use


Choosing prefab

There is three different kind of prefabs:


Add DotMatrix display to scene

Simply drag wanted prefab to your scene.

Note, if you are using UI-version of prefab: When dragging prefab to hierarchy or scene, prefab should automatically set UI canvas as its parent. If there is no other UI and no UI Canvas in scene yet, one is created automatically. However, it's recommended to first create UI Canvas using normal Unity Editor tools before adding UI-version of DotMatrix to the scene.

At this point display should be already visible on scene, though its size and colors may be totally wrong. Choose created DotMatrix gameobject and check inspector window. It contains multiple settings where you can choose display size, dot prefabs, sizes and colors.

Choose desired parameters and position DotMatrix to your scene/UI.

DotMatrix dots are created from prefabs. There are multiple ready made simple prefabs (different shape of dots). If you wish to have more control on how display looks, you can make your own dot prefabs. After creating your own dot-object prefab, just drag that to "Dot Prefab" field in Unity inspector window.


Accessing DotMatrix

Create new script that will be used to control DotMatrix display. Use any way you prefer to give your script reference to DotMatrix script in gameobject created earlier. Make sure your script is using Leguar.DotMatrix;

You can then get Controller of DotMatrix display using:

Controller controller = myDotMatrix.GetController();

Controller can be used to feed new commands to display. For example:

TextCommand textCommand = new TextCommand("Hello world!");
controller.AddCommand(textCommand);

This will cause text "Hello world!" to appear on display. By default it will be on center of the display.


Controller commands

Commands can be added to controller before previous one is finished. All commands go to queue and they'll run in order they were added, one by one.

Possible commands are following:

For example, following script would scroll text from left to center of display, wait for 2 seconds and then scroll text away.

TextCommand textCommand = new TextCommand("Hello and bye") {
    HorPosition = TextCommand.HorPositions.Center,
    Movement = TextCommand.Movements.MoveLeftAndStop
};
controller.AddCommand(textCommand);
controller.AddCommand(new PauseCommand(2f));
controller.AddCommand(new ClearCommand() {
    Method = ClearCommand.Methods.MoveLeft
});

Some more advanced commands:


Direct access

If you wish to access display directly, you can use DisplayModel:

DisplayModel displayModel = myDotMatrix.GetDisplayModel();
displayModel.SetDot(0,0,1);

That will set upper left corner dot (0,0) to "on state" (1) during this or next Update() loop (depending on script execution order).


Full API docs

Inline c# documents are included to all public classes. They are also available online in html format:

Full API documentation


Where to get

Download from Unity Asset Store