7-segment-display game asset

I am “new” in Unity and I am using it to develop something for HTC Vive.

I wanted to create a 7-segment-display and control what it displays through code.
Somethink like this
99709-280px-seven-segment-02-pengo.jpg

I was looking for info about how to create game assets with behaviour, but I couldn’t find a lot.

I was wondering if you can give me some advice or info here. Modelling is not the problem, since I know blender, but the question is how to “control the display” through code.

I hope this question isn’t offtopic here…

Thanks in advance

Well, it depends what you actually want to use that display for. The one in the image is literally just a 7-seg display where you can control all 8 LEDs indepenently (7 segments + 1 dot). So there are 256 combinations possible. However if you only want to display number you only need 10 (or 11) different states. If you want to display a hex number you only need 16 (or 17) different combinations. (keep in mind that you have to use a lower case “b” and “d” since “B” and “8” as well as “D” and “0” would be the same).

In most trivial cases it would be the easiest when you just use a single quad for the surface and use a sprite sheet with the actual 7-seg image in those different states you want to support. This would be the best for performance.

Of course it’s possible to create seperate triangles for each segment and recolor each segment depending on if you want it to be lit or not. This can be done either by using vertex colors or by changing the UV mapping of each segment.

It’s also possible to create a mask texture and fill the area of each segment with a unique color to identify the segment. A special shader can be used that uses the vertex color of a single quad texture to determine which segments should be “enabled”.

In all cases where you control the segments “manually” you of course need to “decode” whatever you want to display into which segments need to be enabled.

It’s unclear for what you want to use those so it’s difficult to determine which would be the better approach. Though in most cases the first solution it the better one since it’s unlikely that you actually want to control the segments indepently.