diff --git a/Assets/Fungus/Narrative/Editor/LocalizationEditor.cs b/Assets/Fungus/Narrative/Editor/LocalizationEditor.cs index 3239c89f..18e4f812 100644 --- a/Assets/Fungus/Narrative/Editor/LocalizationEditor.cs +++ b/Assets/Fungus/Narrative/Editor/LocalizationEditor.cs @@ -86,7 +86,9 @@ namespace Fungus { return; } - + + localization.ClearLocalizeableCache(); + string textData = localization.GetStandardText(); File.WriteAllText(path, textData); AssetDatabase.Refresh(); @@ -102,6 +104,8 @@ namespace Fungus return; } + localization.ClearLocalizeableCache(); + string textData = File.ReadAllText(path); localization.SetStandardText(textData); diff --git a/Assets/Fungus/Narrative/Scripts/Localization.cs b/Assets/Fungus/Narrative/Scripts/Localization.cs index 3700baab..6f1c868b 100644 --- a/Assets/Fungus/Narrative/Scripts/Localization.cs +++ b/Assets/Fungus/Narrative/Scripts/Localization.cs @@ -77,13 +77,18 @@ namespace Fungus } } + public virtual void ClearLocalizeableCache() + { + localizeableObjects.Clear(); + } + // Build a cache of all the localizeable objects in the scene protected virtual void CacheLocalizeableObjects() { - Component[] components = GameObject.FindObjectsOfType(); - foreach (Component component in components) + UnityEngine.Object[] objects = Resources.FindObjectsOfTypeAll(typeof(Component)); + foreach (UnityEngine.Object o in objects) { - ILocalizable localizable = component as ILocalizable; + ILocalizable localizable = o as ILocalizable; if (localizable != null) { localizeableObjects[localizable.GetStringId()] = localizable; @@ -202,11 +207,11 @@ namespace Fungus } } - // Add everything else that's localizable - Component[] components = GameObject.FindObjectsOfType(); - foreach (Component component in components) + // Add everything else that's localizable (including inactive objects) + UnityEngine.Object[] objects = Resources.FindObjectsOfTypeAll(typeof(Component)); + foreach (UnityEngine.Object o in objects) { - ILocalizable localizable = component as ILocalizable; + ILocalizable localizable = o as ILocalizable; if (localizable != null) { string stringId = localizable.GetStringId();