public void Create(string rootFolderPath, string rootFolderRelativePath, TextPattern[] textPatterns, int from, int count) { for (int i = from; i < from + count; i++) { var item = items[i]; if (item.Modify == false || item.FileExist) { continue; } FileFromTemplate.Create(item.Template, rootFolderPath, textPatterns); AssetDatabase.ImportAsset($"{rootFolderRelativePath}/{item.Template.GetPathToFile()}"); } }
protected void DrawModifyOption(int index, string rootFolderRelativePath, TextPattern[] textPatterns) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(items[index].FileExist ? "Delete" : "Create", GUILayout.MaxWidth(60)); var dependeceIndex = items[index].DependenceIndex; var enabled = GUI.enabled; var toggleEnabled = items[index].Dependence == false || items[dependeceIndex].Modify; GUI.enabled = toggleEnabled; //Disable toggle if var modify = items[index].Dependence && items[dependeceIndex].FileExist && items[index].FileExist || //Check if both this and class it's dependes on exist items[index].Required || // Always check if this class is required items[index].Modify || // Check if user set modify to true items[index].FileExist; // Check if file exist //Set modify to false if the file its dependce on doesn't exist and is uncheck if (modify && items[index].Dependence && items[dependeceIndex].FileExist == false && items[dependeceIndex].Modify == false) { modify = false; } items[index].Modify = EditorGUILayout.ToggleLeft(items[index].Template.fileName, modify); GUI.enabled = enabled; //Update preview content if (GUILayout.Button("Preview", GUILayout.MaxWidth(70), GUILayout.MaxWidth(70))) { PreviewTemplateContent = FileFromTemplate.GetFileContentPreview(items[index].Template.templatePath, textPatterns); } //Display option to remove file, for unrequired class files if (items[index].Required == false && items[index].FileExist && GUILayout.Button("Delete", GUILayout.MaxWidth(70), GUILayout.MaxWidth(70))) { DeleteWithDependecies(rootFolderRelativePath, index); } EditorGUILayout.EndHorizontal(); }