Browse Source

Inactive localizeable game objects are now cached #322

master
chrisgregan 9 years ago
parent
commit
4fbf516a18
  1. 6
      Assets/Fungus/Narrative/Editor/LocalizationEditor.cs
  2. 19
      Assets/Fungus/Narrative/Scripts/Localization.cs

6
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);

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