Browse Source

Merge pull request #330 from FungusGames/cache-inactive-localizable

Inactive localizeable game objects are now cached #322
master
Chris Gregan 9 years ago
parent
commit
116398373e
  1. 4
      Assets/Fungus/Narrative/Editor/LocalizationEditor.cs
  2. 19
      Assets/Fungus/Narrative/Scripts/Localization.cs

4
Assets/Fungus/Narrative/Editor/LocalizationEditor.cs

@ -87,6 +87,8 @@ 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);

19
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<Component>();
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<Component>();
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();

Loading…
Cancel
Save