I’ll try to be as clear as possible
I am making Localization Manager and try to keep it as auto-sufficient as possible as it will be used in various different project at the same time
The localization part is working great but I am trying to add some sort of “auto completion” system to help when typing localization key
(Here at the bottom of the script component)
To display the auto completion, I’m looping trough a list of string all generated from a .csv file, along with some “LocalizerKey” that are used for other things, in a script called “LocalizerBank” that is unique to the project, like this :
// THIS FILE IS GENERATED AUTOMATICALY IN LocalizerManager
namespace Polonium
{
public static partial class LocalizerBank
{
public static LocalizerKey MainMenuPlay = new LocalizerKey("MainMenuPlay");
public static LocalizerKey MainMenuOptions = new LocalizerKey("MainMenuOptions");
public static LocalizerKey MainMenuCredits = new LocalizerKey("MainMenuCredits");
public static LocalizerKey MainMenuQuit = new LocalizerKey("MainMenuQuit");
public static string[] allKey = {"MainMenuPlay","MainMenuOptions","MainMenuCredits","MainMenuQuit"};
}
}
The list “allKey” is used in the LocalizerAuto as such :
string previsual = "";
foreach (string key in LocalizerBank.allKey)
{
if (key.StartsWith(myTarget.locKey.key))
{
previsual = key;
break;
}
}
GUILayout.Label(previsual, EditorStyles.centeredGreyMiniLabel);
The thing is, when I’m importing this code in a new project, where the LocalizerBank was never generated, of course it bugs because allKey does not exist as well
So is there a way to fix this ? Like using a #define in LocalizerBank that could be global to the project and putting the problematic code between #if #end (if that’s possible) or something else ?