Game Development Reference
In-Depth Information
public string LocalizationID = string.Empty;
//Constructor
public LocalizationTextAttribute(string ID)
{
LocalizationID = ID;
}
}
With the
LocalizationTextAttribute
attribute now created, we can apply it to
string members in code, which associates them with a specific ID, as shown in the
following code sample 8-12:
//----------------------------------------------
using UnityEngine;
using System.Collections;
//----------------------------------------------
public class SampleGameMenu : MonoBehaviour
{
[LocalizationTextAttribute("text_01")]
public string NewGameText = string.Empty;
[LocalizationTextAttribute("text_02")]
public string LoadGameText = string.Empty;
[LocalizationTextAttribute("text_03")]
public string SaveGameText = string.Empty;
[LocalizationTextAttribute("text_04")]
public string ExitGameText = string.Empty;
}
//----------------------------------------------
The
SampleGameMenu
class appears as a regular class in the Object Inspector, as
shown in the following screenshot. Later, through our
Editor
class, we'll develop
the ability to automatically change all string members to the selected language.