If the player can choose the PC's gender between male and female, an easy way to include the player's gender pronouns in text is set to variables. For example:
Code: Select all
public void SetPlayerGender(bool male)
{
DialogueLua.SetVariable("PlayerHeShe", male ? "he" : "she");
DialogueLua.SetVariable("PlayerHimHer", male ? "him" : "her");
}
- Dialogue Text: "Dominic, can you believe [var=PlayerHimHer]? The gall to think [var=PlayerHeShe] can walk in here and demand to talk to the boss."
However, you may also need to modify the text to handle gendered pronouns or words in gendered languages.
Take for example the sentence: "I am a dancer." In French, this is:
- (m): "Je suis danseur."
- (f): "Je suis danseuse."
"Je suis {{danseur/danseuse}}."
Then add an OnConversationLine method to a custom script on the Dialogue Manager GameObject. In that method, replace the "{{danseur/danseuse}}" with one version or the other based on the PC's gender. Example:
Code: Select all
void OnConversationLine(Subtitle subtitle)
{
Regex regex = new Regex(@"{{[^}]*}}");
subtitle.formattedText.text = regex.Replace(subtitle.formattedText.text, delegate (Match match)
{
var strings = match.Value.Substring(2, match.Value.Length - 4).Split('/');
return isPlayerMale ? strings[0] : strings[1];
});
}
You could also do this with a Lua function, which would result in a simpler C# method but more verbose dialogue text:
"Je suis [lua(Gender("danseur/danseuse"))]."
where the C# method registered with Lua might look something like:
Code: Select all
public string Gender(string s)
{
var strings = s.Split('/');
return isPlayerMale ? strings[0] : strings[1];
}
See also: How To: Localize Variable Text in Alerts