/// <summary> /// Initialized and setups the L20n System. /// Called during the `Awake` phase. /// </summary> void Awake() { // Make sure that L20n isn't initialized yet. // This can happen as you might have used this component already in a previous scene. // Which might be quite common as this component should be used in all scenes // that you may want to start up from directly during development. if (!L20n.IsInitialized) { if (manifestPath == null) { Debug.LogError("<L20nSettings> requires the manifest to be set", this); return; } if (overrideLocale == "") { overrideLocale = null; } // Initialize L20n L20n.Initialize(uniqueGameID, manifestPath, overrideLocale); // Set the default fonts and global variables (if there are any) L20n.SetFont(L20n.DefaultLocale, defaultFont); foreach (var pair in fonts.GetAllResources()) { L20n.SetFont(pair.Key, pair.Value); } globalVariables.AddValuesToEnvironment(); } if (destroyObject) { Destroy(gameObject); } else { Destroy(this); } }
// It's important that you initialize L20n before you start localizing anything. // Doing the initialization in Awake is a good option, or simply // making sure that your initialization script is ran first is a possibility as well. void Awake() { // Make sure that L20n isn't already initialized if (!L20n.IsInitialized) { // Initialize L20n, setting the Game ID and the Manifest Path // this line is the only required method call to initialize L20n! L20n.Initialize("L20nDemo", "L20n/examples/manifest.json"); // ALL STUFF BELOW IS OPTIONAL! // Optinially you can also set the default fonts to use for Text Components L20n.SetFont("jp", m_JapaneseFont); L20n.SetFont(m_DefaultFont); // Game-Specific Globals can be added as well // These variables are avaiable for all translations L20n.AddStaticGlobal("temperature", m_Temperature); L20n.AddComplexGlobal("user", m_User); } }