Пример #1
0
 public void Process(ProcessMetadata metadata, ProcessDictionary result)
 {
     result.Add(
         ReplaceWords[0],
         this
         );
 }
        public void Process(ProcessMetadata metadata, ProcessDictionary result)
        {
            var typeNameList    = new List <string[]>();
            var elementNameList = new List <string[]>();
            var nameList        = new HashSet <string>();
            var targetNameList  = new List <string>();

            foreach (var target in _targets)
            {
                if (target == null)
                {
                    continue;
                }

                GetNames(target.CloneTree().Children(), nameList);
                var tab = new string(' ', 8);
                typeNameList.Add(new[] { target.name, string.Join(",\n" + tab, nameList.Select(StringBuilderExtension.ConvertEnumName).ToArray()) });
                elementNameList.Add(new[] { target.name, string.Join(",\n" + tab, nameList.Select(n => "\"" + n + "\"").ToArray()) });
                nameList.Clear();

                targetNameList.Add(target.name);
            }

            result.Add(ReplaceWords[0], TemplateUtility.GetFilePathFromFileName(ScriptName + ".cs") ?? "Assets");
            result.Add(ReplaceWords[1], ScriptName);
            result.Add(ReplaceWords[2], typeNameList);
            result.Add(ReplaceWords[3], elementNameList);
            result.Add(ReplaceWords[4], targetNameList);
        }
        public static void ExecuteProcessChain(object obj, ProcessMetadata metadata, ProcessDictionary result)
        {
            var processChain = ConvertProcessChianInstanceFromObject(obj);

            if (processChain != null)
            {
                processChain.Process(metadata, result);
            }
        }
        public void Process(ProcessMetadata metadata, ProcessDictionary result)
        {
            var createPath = TemplateUtility.GetFilePathFromFileName(AssetsMenuItemScriptName + ".cs") ?? "Assets/TemplateEditorTool/Editor";

            result.Add(ReplaceWords[(int)ReplaceWordType.Settings], BuildMenuItemList <TemplateSetting>());
            result.Add(ReplaceWords[(int)ReplaceWordType.GroupSettings], BuildMenuItemList <TemplateGroupSetting>());
            result.Add(ReplaceWords[(int)ReplaceWordType.CreatePath], createPath);
            result.Add(ReplaceWords[(int)ReplaceWordType.ScriptName], AssetsMenuItemScriptName);
        }
Пример #5
0
        public static void ExecuteChain(TemplateSettingStatus status, ProcessDictionary result)
        {
            var metadata = new ProcessMetadata(status.TargetTemplateSetting);
            var property = status.GetProperty(TemplateSettingStatus.Property.Chain);

            for (int i = 0; i < property.arraySize; ++i)
            {
                TemplateUtility.ExecuteProcessChain(property.GetArrayElementAtIndex(i).objectReferenceValue, metadata, result);
            }
        }
        public override void Process(ProcessMetadata metadata, ProcessDictionary result)
        {
            var code = ReplaceCode(result);

            if (string.IsNullOrEmpty(code))
            {
                return;
            }

            result.Add(RepalceWords[0], code.Split('\n'));
        }
        public void Process(ProcessMetadata metadata, ProcessDictionary result)
        {
            // ファイルパス取得
            var removeWord       = "Resources/";
            var removeWordLength = removeWord.Length;

            // Assets内にあるResourcesフォルダの全てのパスを取得
            var resourcesPaths = Directory.GetDirectories("Assets", "Resources", SearchOption.AllDirectories);

            // Resourcesフォルダ内のファイルパスを取得
            // TODO : 最適化?
            var ignorePatterns = _ignorePathPatterns.Select(pattern => new Regex(pattern, RegexOptions.Compiled));
            var filePaths      = ResourcesLoaderUtility.GetFilePaths(resourcesPaths, new string[] { ".meta" })
                                 .Where(path => _ignoreFileNames.Contains(Path.GetFileNameWithoutExtension(path)) == false)
                                 .Where(path => ignorePatterns.Any(pattern => pattern.IsMatch(path)) == false)
                                 .OrderBy(path => Path.GetFileNameWithoutExtension(path));

            var filePathsList = new List <string[]>();
            var fileNamesList = new List <string[]>();
            var methodsList   = new List <string[]>();
            var enumValues    = Enum.GetValues(typeof(ResourcesLoaderUtility.LoadType)).Cast <int>().ToArray();

            foreach (var parameter in _parameters)
            {
                // 指定した拡張子のファイルパスを取得
                var paths = ResourcesLoaderUtility.FindByExtension(filePaths, parameter.TargetExtensions).Select(path =>
                {
                    var startIndex = path.IndexOf(removeWord) + removeWordLength;
                    var length     = path.Length - startIndex - Path.GetExtension(path).Length;
                    return(path.Substring(startIndex, length));
                });

                if (paths.Any() == false)
                {
                    continue;
                }

                // スペースは8文字に
                var tab = new string(' ', 8);
                filePathsList.Add(new string[] { parameter.TypeName, string.Join(",\n" + tab, paths.Select(path => "\"" + path + "\"").ToArray()) });

                // ファイルパスからファイル名を取得
                // TODO : StringBuilderExtension.ConvertEnumName
                var fileNames = paths.Select(Path.GetFileNameWithoutExtension).Select(StringBuilderExtension.ConvertEnumName);
                fileNamesList.Add(new string[] { parameter.TypeName, string.Join(",\n" + tab, fileNames.ToArray()) });

                var intValue = (int)parameter.EditLoadType;
                for (int i = 0; i < enumValues.Length; ++i)
                {
                    if ((intValue & enumValues[i]) == 0)
                    {
                        continue;
                    }

                    methodsList.Add(new string[]
                    {
                        string.Format(ResourcesLoaderUtility.ReturnNamesFormat[i], parameter.TypeName),
                        ResourcesLoaderUtility.LoadNames[i],
                        parameter.TypeName
                    });
                }
            }

            // 生成パス設定
            result.Add(ReplaceWords[(int)ReplaceWordType.CreatePath], TemplateUtility.GetFilePathFromFileName(ScriptName + ".cs") ?? "Assets");

            // スクリプト名設定
            result.Add(ReplaceWords[(int)ReplaceWordType.ScriptName], ScriptName);

            // Usings
            {
                var usingsList = new List <IUsings>(_parameters.Length + 1);
                usingsList.Add(this);
                usingsList.AddRange(_parameters);

                var usingNames = new HashSet <string>();
                foreach (var usings in usingsList)
                {
                    foreach (var names in usings.usings)
                    {
                        usingNames.Add(names);
                    }
                }

                result.Add(
                    ReplaceWords[(int)ReplaceWordType.Usings],
                    usingNames.ToArray()
                    );
            }

            // Enums
            {
                result.Add(
                    ReplaceWords[(int)ReplaceWordType.Enums],
                    fileNamesList
                    );
            }

            // Paths
            {
                result.Add(
                    ReplaceWords[(int)ReplaceWordType.Paths],
                    filePathsList
                    );
            }

            // Methods
            {
                result.Add(
                    ReplaceWords[(int)ReplaceWordType.Methods],
                    methodsList
                    );
            }
        }
 public void Process(ProcessMetadata metadata, ProcessDictionary result)
 {
     result.Add(ReplaceWords[0], Path.Combine(EditorApplication.applicationContentsPath, "Resources/ScriptTemplates"));
     result.Add(ReplaceWords[1], "81-C# Script-NewBehaviourScript.cs.txt");
 }
 public virtual void Process(ProcessMetadata metadata, ProcessDictionary result)
 {
     result.Add(RepalceWords[0], ReplaceCode(result));
 }