-
Notifications
You must be signed in to change notification settings - Fork 2
Home
- Create a new project in Unity Editor version 2019.4.40 (you'll need to get it from the Unity download archive)
- Right click on Packages and select "View in Package Manager" - select Unity Registry and under the Advanced dropdown, enable Preview Packages. Find TextMeshPro from the list and update to 2.2.0-preview.3.
- Download and unzip the editor package. In your unity project, right click Assets in the project window and select Import > Custom Package
- In the new Number Manager menu, click Create New Workspace. Select your skin textures and workspace name.
- It will create a new scene and select the preview square. Scroll to the Number Config Editor script in the Inspector.
- You need to add at least one font and at least one attach point. Click the Source Font button to bring up a list of system fonts to choose from. Make sure to change the font colors, they might start out as fully transparent. The default Format for fonts is "{0:D1}" which is simply the number itself, see also https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings for more help (argument 0 is the car's number).
- When done, click Export Config and choose the destination (skin folder) for your generated files.
When trying to apply numbers to a skin, NumberManager looks for two new files in the skin folder (for example, Skins/loco_steam_H/MySkin):
- num.png - This texture will be the source of the fonts you define. The width and height must be powers of 2, but the texture needn't be square
- numbering.xml - Where you will define your fonts and the locations where numbers will be applied to your skin.
Your num.png file should have a transparent background, and you can make the numbers any color. The numbers can be located anywhere in the file, and we will be indicating their locations in the XML config. Here is an example num.png:
Now for the fun part, the XML config. The file will always contain a single NumberConfig root node, and the available children and attributes are shown below. The X and Y coordinates are zero-based and start from the top-left corner to match the convention of image editors.
- <NumberConfig>
- Attributes:
- TargetTexture="<string>" - The name (without extension) of the diffuse texture the numbers will be applied to
- BlendMode="Normal|Add|Subtract|Multiply|Divide|Colorize" - (optional, default Normal) Overlay mode for the number shader, recommend Normal or Colorize
- ColorizeWhiteLevel="<float>" - (only needed for Colorize blending) The highest brightness value of the target texture under the numbers, needed to properly blend base texture with font color
- MinNumber="<int>" - The minimum number for random numbering
- MaxNumber="<int>" - The maximum for random numbering
- ForceRandom="true|false" - (optional, default false) override the "use car ID" setting for this skin and use random numbers
- Offset="<int>" - The number to add to the car ID when generating numbers in "use car ID" mode
- <Fonts> (array of NumberFont elements)
- <NumberFont>
- Attributes:
- Height="<int>" - (ignored if CharHeight is set) Height of this font's digits in pixels (relative to the digits, so if orientation is vertical, this is the x dimension)
- Orientation="Horizontal|Vertical" - whether the font runs left->right or bottom->top, default is Horizontal
- ReverseDigits="true|false" - whether to reverse the order of the digits in numbers (used to change the orientation to right->left or top->bottom)
- Emission="<string>" - comma-separated list of float (0.0-1.0) RGB values (should have 3 elements, or can be omitted for no emissivity)
- Specular="<string>" - list of float (0.0-1.0) RGBA values; R is metallic and A is roughness (should have 4 elements, or can be omitted to use skin's specular map values)
- Kerning="<int>" - additional width (in pixels) to add between digits (optional)
- Format="<string>" - (optional, default {0:D1}) Format string to apply to the number before sending to shader (Arg 0 is the number)
- CharX="<string>" - comma-separated list of the X coordinate of the bottom left of each digit in the font (should have 10 elements)
- CharY="<string>" - list of Y coordinates of the bottom left of each digit
- CharWidth="<string>" - list of the widths of each digit (if orientation is vertical, this is the y dimension)
- CharHeight="<string>" - (overrides Height) list of the heights of each digit (if orientation is vertical, this is the x dimension)
- Attributes:
- <NumberFont>
- <AttachPoints> (array of NumAttachPoint elements)
- <NumAttachPoint>
- Attributes:
- FontIdx="<int>" - zero-based index corresponding to a font defined above
- X="<int>" - X coordinate in pixels of the middle of where the number should appear on the target texture
- Y="<int>" - Y coordinate where the number should appear
- Attributes:
- <NumAttachPoint>
- Attributes:
Here's an example configuration file on the house. It corresponds to the font texture shown above and targets the steam engine texture, SH_exterior_d.png
<NumberConfig TargetTexture="SH_exterior_d" MinNumber="1000" MaxNumber="9999">
<Fonts>
<NumberFont Height="44"
CharX= " 0, 32, 55, 88,120, 0, 32, 64, 94,126"
CharY= " 45, 45, 45, 45, 45, 97, 97, 97, 97, 97"
CharWidth=" 32, 23, 33, 32, 31, 32, 32, 30, 32, 32"/>
<!-- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 -->
<NumberFont Height="23" Orientation="Vertical"
CharX= "160,160,160,160,160,190,190,190,190,190"
CharY= " 80, 64, 53, 36, 20, 80, 64, 48, 33, 17"
CharWidth=" 16, 11, 17, 16, 15, 16, 16, 15, 16, 16"/>
<!-- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 -->
</Fonts>
<AttachPoints>
<NumAttachPoint FontIdx="0" X="1259" Y="2654"/>
<NumAttachPoint FontIdx="0" X="170" Y="2654"/>
<NumAttachPoint FontIdx="1" X="1379" Y="994"/>
</AttachPoints>
</NumberConfig>
Here is a config for the DE6 demonstrating the emission attribute for the number boards:
<NumberConfig TargetTexture="LocoDiesel_exterior_d" BlendMode="Colorize" MinNumber="10" MaxNumber="99">
<Fonts>
<!-- Cab side numbers -->
<NumberFont Height="36"
CharX= " 0, 37, 57, 94,131, 0, 37, 75,112,151"
CharY= " 36, 36, 36, 36, 36, 75, 75, 75, 75, 75"
CharWidth=" 37, 20, 37, 37, 38, 37, 38, 37, 39, 39"/>
<!-- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9-->
<!-- Number boards -->
<NumberFont Height="15" Orientation="Vertical" Emission="1,1,0.9"
CharX= "200,200,200,200,200,200,200,200,200,200"
CharY= "110, 99, 88, 77, 66, 55, 44, 33, 22, 11"
CharWidth=" 11, 11, 11, 11, 11, 11, 11, 11, 11, 11"/>
<!-- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9-->
</Fonts>
<AttachPoints>
<NumAttachPoint FontIdx="0" X="1166" Y="865"/>
<NumAttachPoint FontIdx="0" X="1432" Y="865"/>
<NumAttachPoint FontIdx="1" X="1359" Y="1108"/>
<NumAttachPoint FontIdx="1" X="992" Y="569"/>
</AttachPoints>
</NumberConfig>