private void RunInternal(string filePath)
        {
            var settings = UPaletteProjectSettings.instance;

            // Delete the old file if needed.
            if (settings.NameEnumsFile != null)
            {
                var oldFilePath = AssetDatabase.GetAssetPath(settings.NameEnumsFile);
                if (oldFilePath != filePath)
                {
                    var lp = new TextLocalPersistence(oldFilePath);
                    if (lp.Exists())
                    {
                        lp.Delete();
                    }
                }
            }

            var template         = new NameEnumsTemplate(CreateTemplateInput(_store));
            var text             = template.TransformText();
            var localPersistence = new TextLocalPersistence(filePath);

            localPersistence.Save(text);

            settings.NameEnumsFile = AssetDatabase.LoadAssetAtPath <MonoScript>(filePath);
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            var input = new NameEnumsTemplateInput();

            // Color
            var colorPaletteData = new NameEnumsTemplateInput.PaletteData("Color");

            colorPaletteData.AddThemeInfo("Theme1", "123");
            colorPaletteData.AddThemeInfo("Theme2", "456");
            colorPaletteData.AddEntryInfo("KeyColor", "789");
            colorPaletteData.AddEntryInfo("KeyColor", "123");
            colorPaletteData.AddEntryInfo("KeyColor_2", "123");
            input.PaletteDataList.Add(colorPaletteData);

            // Character Style
            var characterStylePaletteData = new NameEnumsTemplateInput.PaletteData("CharacterStyle");

            characterStylePaletteData.AddThemeInfo("Theme1", "789");
            input.PaletteDataList.Add(characterStylePaletteData);

            var template = new NameEnumsTemplate(input);

            Console.WriteLine(template.TransformText());
        }