Example #1
0
        public static void Generate(string targetLocalizedText, string generatedPath)
        {
            var lineModels     = CreateLocalizedTextModel(targetLocalizedText);
            var duplicatedKeys = GetDuplicatedKeys(lineModels);

            if (duplicatedKeys.Count >= 1)
            {
                string failedKeys = "{";
                foreach (var key in duplicatedKeys)
                {
                    failedKeys = failedKeys + key + ",";
                }
                failedKeys += "}";
                throw new Exception($"Duplicated Key {failedKeys}");
            }

            var header = new LocalizedTextHeaderModel(lineModels[0].LineText);
            var code   = ScriptGenerator.GenerateEnumScript(lineModels, header, DefaultEnumName);

            GenerateEnumFile(code, generatedPath);
            AssetDatabase.Refresh();
        }