|
|
@ -1,4 +1,5 @@ |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine; |
|
|
|
|
|
|
|
using UnityEngine.Serialization; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections; |
|
|
|
|
|
|
|
|
|
|
|
namespace Fungus |
|
|
|
namespace Fungus |
|
|
@ -7,10 +8,14 @@ namespace Fungus |
|
|
|
"Set Language", |
|
|
|
"Set Language", |
|
|
|
"Set the active language for the scene. A Localization object with a localization file must be present in the scene.")] |
|
|
|
"Set the active language for the scene. A Localization object with a localization file must be present in the scene.")] |
|
|
|
[AddComponentMenu("")] |
|
|
|
[AddComponentMenu("")] |
|
|
|
public class SetLanguage : Command |
|
|
|
public class SetLanguage : Command, ISerializationCallbackReceiver |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
#region Obsolete Properties |
|
|
|
|
|
|
|
[HideInInspector] [FormerlySerializedAs("languageCode")] public string languageCodeOLD; |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
[Tooltip("Code of the language to set. e.g. ES, DE, JA")] |
|
|
|
[Tooltip("Code of the language to set. e.g. ES, DE, JA")] |
|
|
|
public string languageCode; |
|
|
|
public StringData _languageCode = new StringData(); |
|
|
|
|
|
|
|
|
|
|
|
public static string mostRecentLanguage = ""; |
|
|
|
public static string mostRecentLanguage = ""; |
|
|
|
|
|
|
|
|
|
|
@ -19,11 +24,11 @@ namespace Fungus |
|
|
|
Localization localization = GameObject.FindObjectOfType<Localization>(); |
|
|
|
Localization localization = GameObject.FindObjectOfType<Localization>(); |
|
|
|
if (localization != null) |
|
|
|
if (localization != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
localization.SetActiveLanguage(languageCode, true); |
|
|
|
localization.SetActiveLanguage(_languageCode.Value, true); |
|
|
|
|
|
|
|
|
|
|
|
// Cache the most recently set language code so we can continue to |
|
|
|
// Cache the most recently set language code so we can continue to |
|
|
|
// use the same language in subsequent scenes. |
|
|
|
// use the same language in subsequent scenes. |
|
|
|
mostRecentLanguage = languageCode; |
|
|
|
mostRecentLanguage = _languageCode.Value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Continue(); |
|
|
|
Continue(); |
|
|
@ -31,12 +36,28 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
public override string GetSummary() |
|
|
|
public override string GetSummary() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return languageCode; |
|
|
|
return _languageCode.Value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override Color GetButtonColor() |
|
|
|
public override Color GetButtonColor() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new Color32(184, 210, 235, 255); |
|
|
|
return new Color32(184, 210, 235, 255); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
// ISerializationCallbackReceiver implementation |
|
|
|
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void OnBeforeSerialize() |
|
|
|
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void OnAfterDeserialize() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (languageCodeOLD != default(string)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_languageCode.Value = languageCodeOLD; |
|
|
|
|
|
|
|
languageCodeOLD = default(string); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |