Public classes


Scripts/

   SDController
   SegmentDisplay
   SegmentDisplayImage
   SegmentDisplaySprite
   SingleDigit
   SingleSegment

Scripts/Commands/

      AddTextCommand
      CallbackCommand
      ClearCommand
      FillCommand
      PauseCommand
      ScrollTextCommand
      SetTextCommand


Introduction page

SegmentDisplay
Derived from MonoBehaviour


Main class of SegmentDisplay. This class contains majority of all the methods and settings needed to use SegmentDisplay.

There are two other classes derived from this class, SegmentDisplaySprite and SegmentDisplayImage for sprite and image based displays. Sprite based display is used in 2D and 3D worlds, while Image based display is used in UI. Those two classes contains some setting specific for these environments.

Normally SegmentDisplay is set up in Unity Editor inspector. All properties and fields of this class need to be changed by code only in case SegmendDisplay is created from prefab during runtime and it wasn't in scene before. But if SegmendDisplay prefab is already added to scene in Unity Editor, you only need to use methods of this class in your code.

Note when setting or adding text to display that is using colons. Make sure that text you are setting is matching display digits, so that colon in your text will match the location of colon in display. If display is for example "##:##" (5 digits where third one is colon") and you try to add text "2:15", that may cause display to show for example "2 15". In this case solution is to add text " 2:15" instead (notice space before number 2) or add text "2:15" as right aligned.


Fields

public bool Mod_S14S16_OneDraw number 1 without extra diagonal segment.
public bool Mod_S14S16_SevenDraw number 7 with diagonal line instead vertical.
public bool Mod_S14S16_ZeroDraw number 0 with slash going through the number.
public bool Mod_S7S14_SixNineDraw numbers 6 and 9 without having last horizontal segment.
public bool Mod_S7_SevenDraw number 7 with extra vertical line on top left.
public bool[] ColonAtIndexArray of boolean values that defines in which indexes there will be colon instead of normal digit.
public bool[] SmallerDigitAtIndexArray of boolean values that defines in which indexes there will be smaller digits instead of normal size digit.

Enums

public enum AlignmentsText alignments.
public enum DisplayTypesDifferent display types, telling how many segments there are in each digit.
public enum FourteenSegmentStylesDifferent styles for fourteen segment display.
public enum SevenSegmentStylesDifferent styles for seven segment display.
public enum SixteenSegmentStylesDifferent styles for sixteen segment display.

Indexer

public SingleDigit this [int digitIndex]Gets reference to certain digit of this display.

Properties

public bool ApostrophesEnabledInclude extra apostrophe segment after each digit.
public float ColonRelativeSpacingSpacing around colons, relative to digit spacing.
public bool ColonsEnabledEnable or disable colons.
public bool DecimalPointsEnabledInclude extra decimal point segment after each digit.
public Alignments DefaultAlignmentDefault alignment of text if not specified when calling SetText() or AddText() methods.
public int DigitCountSets or gets number of digits (numbers and/or characters) in this display.
public float DigitSpacingSpacing between digits.
public DisplayTypes DisplayTypeType of the display, number of segments in each digit.
public FourteenSegmentStyles FourteenSegmentStyleSet or get fourteen segment display style.
public string InitialTextInitial text that is added to display when display starts.
public Color OffColorColor of segment when it is not lit.
public Color OnColorColor of segment when it is lit.
public float SegmentSpreadSpread out segments or bring them closer inside one digit.
public SevenSegmentStyles SevenSegmentStyleSet or get seven segment display style.
public SixteenSegmentStyles SixteenSegmentStyleSet or get sixteen segment display style.
public bool SmallerDigitsEnabledEnable or disable some digits being smaller than another.
public float SmallerDigitsSizePercentSet the size of smaller digits compared to normal size digits.
public float SmallerDigitsVerticalPositionSet the vertical position of smaller digits compared to normal size digits.

Methods

public void AddText (string text)Add text to this display using default text alignment.
public void AddText (string text, Alignments alignment)Add text to this display using specified text alignment.
public void AddText (string text, Alignments alignment, int offset)Add text to this display using specified text alignment and possible offset.
public void Clear ()Clear the display.
public void Clear (int startIndex, int count)Clear part of the display.
public void Fill ()Fill the display.
public void Fill (int startIndex, int count)Fill part of the display.
public SDController GetSDController ()Gets the SegmentDisplay Controller instance for this display.
public bool IsEmpty ()Check whatever display is completely empty.
public bool IsFull ()Check whatever display is completely filled.
public void MoveLeft ()Move all the content in display to one digit left.
public void MoveRight ()Move all the content in display to one digit right.
public void SetText (string text)Set text to this display using default text alignment.
public void SetText (string text, Alignments alignment)Set text to this display using specified text alignment.
public void SetText (string text, Alignments alignment, int offset)Set text to this display using specified text alignment and possible offset.

Fields

public bool Mod_S14S16_One

Draw number 1 without extra diagonal segment. Have effect on 14 and 16 segment displays. This can be changed during runtime, but it doesn't affect texts that is already on display.


public bool Mod_S14S16_Seven

Draw number 7 with diagonal line instead vertical. Have effect on 14 and 16 segment displays. This can be changed during runtime, but it doesn't affect texts that is already on display.


public bool Mod_S14S16_Zero

Draw number 0 with slash going through the number. Have effect on 14 and 16 segment displays. This can be changed during runtime, but it doesn't affect texts that is already on display.


public bool Mod_S7S14_SixNine

Draw numbers 6 and 9 without having last horizontal segment. Have effect on 7 and 14 segment displays. This can be changed during runtime, but it doesn't affect texts that is already on display.


public bool Mod_S7_Seven

Draw number 7 with extra vertical line on top left. Have effect on 7 segment display. This can be changed during runtime, but it doesn't affect texts that is already on display.


public bool[] ColonAtIndex

Array of boolean values that defines in which indexes there will be colon instead of normal digit.

This array is automatically created and set to correct length when ColonsEnabled is set to true, or when DigitCount is changed while colons are enabled. Before that, this array may be null or have invalid length.

Changing values in this array have no effect after display is created to the scene.


public bool[] SmallerDigitAtIndex

Array of boolean values that defines in which indexes there will be smaller digits instead of normal size digit.

This array is automatically created and set to correct length when SmallerDigitsEnabled is set to true, or when DigitCount is changed while smaller digits are enabled. Before that, this array may be null or have invalid length.

Changing values in this array have no effect after display is created to the scene.


Enums

public enum Alignments

Text alignments.

ItemsLeftAlign text to left side of display. First character of text will be in leftmost digit. If text is longer than display, end of the text will be cut out.
 CenterAlign text to center of display. If text is longer than display, text may be cut out both in start and end. Note that center aligned text may not work correctly in displays that have colons enabled.
 RightAlign text to right side of display. Last character of text will be in rightmost digit. If text is longer than display, start of the text will be cut out.


public enum DisplayTypes

Different display types, telling how many segments there are in each digit.

ItemsSevenSegmentClassic seven segment display. This type of display typically shows just numbers. Best choice for simple clocks, timers or scoreboards.

This type display support also letters, but some of them may require imagination to read and some are more like symbolic, like M and W. This is sufficient for showing short, one word messages such "Start", "End", "Play", "Stop", "Pause", "Open", "Close". But due limitation of segments, these texts may have upper and lower case letters mixed and "start" looks more like "StArt".
 FourteenSegmentFourteen segment display is good choice if your display also needs to show text. Only upper case letters are supported but text is very readable. Multiple symbols are also supported.
 SixteenSegmentVery much like fourteen segment display but can also show lower case letters and few extra symbols such curly brackets.


public enum FourteenSegmentStyles

Different styles for fourteen segment display.

ItemsBasicBasic style.
 CheapCheap electronics style. Practically just 7 segment display turned to 14 segment as easily as possible.


public enum SevenSegmentStyles

Different styles for seven segment display.

ItemsBasicBasic all-around style.
 ClassicClassic style where each of seven segments are completely identical.
 SharpVery sharp corners and square decimal points and colons.
 RoundRound style where each segment is different and they make smooth shapes.


public enum SixteenSegmentStyles

Different styles for sixteen segment display.

ItemsBasicBasic style.
 MiniLedsStyle where each segment is generated by rows of small, round lights. Very common in modern CD/DVD/BluRay players or stereos.


Indexer

public SingleDigit this [int digitIndex]

Gets reference to certain digit of this display. Useful if you want to control some digit separately.

ParametersdigitIndexDigit index, 0 is leftmost digit.


Properties

public bool ApostrophesEnabled

Include extra apostrophe segment after each digit.

Note that this cause that in some case display may hold longer texts than number of digits. If display size is for example 4 digits and apostrophes are enabled, display pattern will be "#'#'#'#'" meaning that even text "1'2'3'4'" (8 characters) will fit to this 4 digit display. But on the other hand, "'''12" (5 characters) will not fit.

ValueTrue to enable apostrophes, false to have digits without apostrophe segment.


public float ColonRelativeSpacing

Spacing around colons, relative to digit spacing. 1.0 means no change to normal digit spacing, colon will take same amount of space as any other digit. 0.0 means no space for colons, digits around colon are as close each other as they would be without any colon between them.

ValuePercentage value defining how much space is between colons compared to normal spacing between digits.


public bool ColonsEnabled

Enable or disable colons.

ValueTrue to enable colons, false to keep all digits normal.


public bool DecimalPointsEnabled

Include extra decimal point segment after each digit.

Note that this cause that in some case display may hold longer texts than number of digits. If display size is for example 4 digits and decimal points are enabled, display pattern will be "#.#.#.#." meaning that even text "1.2.3.4." (8 characters) will fit to this 4 digit display. But on the other hand, "...12" (5 characters) will not fit.

ValueTrue to enable decimal points, false to have digits without decimal point segment.


public Alignments DefaultAlignment

Default alignment of text if not specified when calling SetText() or AddText() methods. This is also used in editor as test text alignment.

ValueOne of the choices from enum Alignments.


public int DigitCount

Sets or gets number of digits (numbers and/or characters) in this display.

ValueNumber of digits in display.


public float DigitSpacing

Spacing between digits. 1.0 is default spacing, smaller value brings digits closer to each other and larger pushes digits away from each other.

ValuePercentage value defining how close or far away digits are from each other.


public DisplayTypes DisplayType

Type of the display, number of segments in each digit.

ValueOne of the choices from enum DisplayTypes.


public FourteenSegmentStyles FourteenSegmentStyle

Set or get fourteen segment display style.

ValueOne of the choices from enum FourteenSegmentStyles.


public string InitialText

Initial text that is added to display when display starts. Can be also empty string in which case display will be empty at start.

ValueText to show when scene and display starts.


public Color OffColor

Color of segment when it is not lit. Note that color can be also partially or fully transparent. This color can be changed at any time also after display is created to scene. Colors will be updated in this or next update loop.

ValueColor to be used for segments that are turned off.


public Color OnColor

Color of segment when it is lit. Note that color can be also transparency. This color can be changed at any time also after display is created to scene. Colors will be updated in this or next update loop.

ValueColor to be used for segments that are turned on.


public float SegmentSpread

Spread out segments or bring them closer inside one digit. 1.0 is default, positive value spreads segments away from each other, negative brings them closer to each other.

ValuePercentage value defining how close or far away single digit segments are from each other.


public SevenSegmentStyles SevenSegmentStyle

Set or get seven segment display style.

ValueOne of the choices from enum SevenSegmentStyles.


public SixteenSegmentStyles SixteenSegmentStyle

Set or get sixteen segment display style.

ValueOne of the choices from enum SixteenSegmentStyles.


public bool SmallerDigitsEnabled

Enable or disable some digits being smaller than another.

ValueTrue to enable digits that are smaller than rest, false to keep all digits in same size.


public float SmallerDigitsSizePercent

Set the size of smaller digits compared to normal size digits. Any value between 0.0 and 1.0 (exclusive) is accepted. For example, 1.0 would make smaller digits same size as normal, and 0.0 would make them invisibly small.

ValuePercentage value defining size of smaller digits compared to normal size digits.


public float SmallerDigitsVerticalPosition

Set the vertical position of smaller digits compared to normal size digits. Any value between 0.0 and 1.0 (inclusive) is accepted.

ValueValue defining vertical position of smaller digits compared to normal size digits, 0 being in bottom and 1 being in top.


Methods

public void AddText (string text)

Add text to this display using default text alignment.

All the digits in display that this text is not using are not changed. Meaning previous content will stay on display if this new text is not written over it.

ParameterstextText to add.


public void AddText (string text, Alignments alignment)

Add text to this display using specified text alignment.

All the digits in display that this text is not using are not changed. Meaning previous content will stay on display if this new text is not written over it.

ParameterstextText to add.
 alignmentAlignment of new text.


public void AddText (string text, Alignments alignment, int offset)

Add text to this display using specified text alignment and possible offset.

All the digits in display that this text is not using are not changed. Meaning previous content will stay on display if this new text is not written over it.

ParameterstextText to add.
 alignmentAlignment of new text.
 offsetOffset of new text. This will move text certain amount of digits to wanted direction. For example, when using left alignment and offset 2, text will start from third digit, leaving two first digits empty. If using left alignment and offset -1, first character of text will be ignored (it would be outside the display) and second character of text will be in first digit of display.


public void Clear ()

Clear the display. This will turn all segments of all digits to off state.


public void Clear (int startIndex, int count)

Clear part of the display. This will turn all segments of selected digits to off state.

ParametersstartIndexIndex of first digit to clear.
 countHow many digits to clear.


public void Fill ()

Fill the display. This will turn all segments of all digits to on state.


public void Fill (int startIndex, int count)

Fill part of the display. This will turn all segments of selected digits to on state.

ParametersstartIndexIndex of first digit to fill.
 countHow many digits to fill.


public SDController GetSDController ()

Gets the SegmentDisplay Controller instance for this display. Note that you do not necessarily need this. If you just want to add text to display, you can use SetText() methods in this class. SDController is useful if you wish to run series of text changes or for example scroll text on display.

ReturnsSDController instance. Each display have only one controller instance, same one is returned every time this method is called.


public bool IsEmpty ()

Check whatever display is completely empty.

ReturnsTrue if all segments are not lit, false otherwise.


public bool IsFull ()

Check whatever display is completely filled.

ReturnsTrue if all segments are lit, false otherwise.


public void MoveLeft ()

Move all the content in display to one digit left. Content of leftmost digit will be lost and rightmost digit is set empty. Note that this will not work correctly in display that have colons enabled since content can't be copied between normal digit and colon.


public void MoveRight ()

Move all the content in display to one digit right. Content of rightmost digit will be lost and lefttmost digit is set empty. Note that this will not work correctly in display that have colons enabled since content can't be copied between normal digit and colon.


public void SetText (string text)

Set text to this display using default text alignment.

All the digits in display that this text is not using, are set to off state. Meaning that display will be cleared from all previous content it may had.

ParameterstextText to set.


public void SetText (string text, Alignments alignment)

Set text to this display using specified text alignment.

All the digits in display that this text is not using, are set to off state. Meaning that display will be cleared from all previous content it may had.

ParameterstextText to set.
 alignmentAlignment of the text.


public void SetText (string text, Alignments alignment, int offset)

Set text to this display using specified text alignment and possible offset.

All the digits in display that this text is not using, are set to off state. Meaning that display will be cleared from all previous content it may had.

ParameterstextText to set.
 alignmentAlignment of the text.
 offsetOffset of the text. This will move text certain amount of digits to wanted direction. For example, when using left alignment and offset 2, text will start from third digit, leaving two first digits empty. If using left alignment and offset -1, first character of text will be ignored (it would be outside the display) and second character of text will be in first digit of display.