Class Expander
Expands the size of the input string to show where there may not be enough space for languages that result in longer strings, and either wrap awkwardly or truncate.
Namespace: UnityEngine.Localization.Pseudo
Syntax
[Serializable]
public class Expander : IPseudoLocalizationMethod
Constructors
Expander()
Creates an instance with default padding characters.
Declaration
public Expander()
Expander(Char)
Creates an instance with a single padding character.
Declaration
public Expander(char paddingCharacter)
Parameters
Type | Name | Description |
---|---|---|
Char | paddingCharacter | The character to use for padding. |
Expander(Char, Char)
Creates an instance with a range of padding characters from start to end.
Declaration
public Expander(char start, char end)
Parameters
Type | Name | Description |
---|---|---|
Char | start | The character at the start of the range. |
Char | end | The last character in the range. |
Properties
ExpansionRules
Rules based on string length, that determine the amount to append onto the input string as a ratio of its length. For example, 0.3 would add an extra 30% onto the length. Note: Negative values are ignored. When the newly calculated length is not whole then the next largest whole number will be used. Rules can also be added using SetConstantExpansion(Single) and AddExpansionRule(Int32, Int32, Single).
Declaration
public List<Expander.ExpansionRule> ExpansionRules { get; }
Property Value
Type | Description |
---|---|
List<Expander.ExpansionRule> |
Location
The location where the padding characters will be added to the input string.
Declaration
public Expander.InsertLocation Location { get; set; }
Property Value
Type | Description |
---|---|
Expander.InsertLocation |
MinimumStringLength
The minimum length strings should be before evaluating the ExpansionRules. For example if the value was 10, then all strings under 10 in length would be increased to 10 before the expansion rules were applied. By default this value is 1.
Declaration
public int MinimumStringLength { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
PaddingCharacters
The characters to randomly pick from when padding the length.
Declaration
public List<char> PaddingCharacters { get; }
Property Value
Type | Description |
---|---|
List<Char> |
Methods
AddCharacterRange(Char, Char)
Adds all characters between start and end to the list of padding characters.
Declaration
public void AddCharacterRange(char start, char end)
Parameters
Type | Name | Description |
---|---|---|
Char | start | Character to start with. |
Char | end | Last character to add. |
AddExpansionRule(Int32, Int32, Single)
Adds an expansion rule to ExpansionRules
Declaration
public void AddExpansionRule(int minCharacters, int maxCharacters, float expansion)
Parameters
Type | Name | Description |
---|---|---|
Int32 | minCharacters | The minimum characters. The evaluated string length must be equal or greater than this value. |
Int32 | maxCharacters | The maximum characters. The evaluated string length must be less than this value. |
Single | expansion | The amount to increase the string length by as a ratio where 0 is no expansion and 1.0 is 100%(double length). It varies per language but 0.3 is a good value when using English. |
SetConstantExpansion(Single)
Sets a single expansion rule that will be applied to all strings.
Declaration
public void SetConstantExpansion(float expansion)
Parameters
Type | Name | Description |
---|---|---|
Single | expansion |
Transform(Message)
Pad the string with random characters to increase its length.
Declaration
public void Transform(Message message)
Parameters
Type | Name | Description |
---|---|---|
Message | message |