| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.IO; |
| | 5 | | using System.Text; |
| | 6 | | using UnityEngine; |
| | 7 | |
|
| | 8 | | public static class ProtobufEditorHelper |
| | 9 | | { |
| | 10 | | public static void CloneDirectory(string root, string dest) |
| | 11 | | { |
| 0 | 12 | | foreach (var directory in Directory.GetDirectories(root)) |
| | 13 | | { |
| 0 | 14 | | string dirName = Path.GetFileName(directory); |
| 0 | 15 | | if (!Directory.Exists(Path.Combine(dest, dirName))) |
| | 16 | | { |
| 0 | 17 | | Directory.CreateDirectory(Path.Combine(dest, dirName)); |
| | 18 | | } |
| 0 | 19 | | CloneDirectory(directory, Path.Combine(dest, dirName)); |
| | 20 | | } |
| | 21 | |
|
| 0 | 22 | | foreach (var file in Directory.GetFiles(root)) |
| | 23 | | { |
| 0 | 24 | | File.Copy(file, Path.Combine(dest, Path.GetFileName(file))); |
| | 25 | | } |
| 0 | 26 | | } |
| | 27 | |
|
| | 28 | | public static string ToSnakeCase(this string text) |
| | 29 | | { |
| 0 | 30 | | if(text == null) { |
| 0 | 31 | | throw new ArgumentNullException(nameof(text)); |
| | 32 | | } |
| 0 | 33 | | if(text.Length < 2) { |
| 0 | 34 | | return text; |
| | 35 | | } |
| 0 | 36 | | var sb = new StringBuilder(); |
| 0 | 37 | | sb.Append(char.ToLowerInvariant(text[0])); |
| 0 | 38 | | for(int i = 1; i < text.Length; ++i) { |
| 0 | 39 | | char c = text[i]; |
| 0 | 40 | | if(char.IsUpper(c)) { |
| 0 | 41 | | sb.Append('_'); |
| 0 | 42 | | sb.Append(char.ToLowerInvariant(c)); |
| 0 | 43 | | } else { |
| 0 | 44 | | sb.Append(c); |
| | 45 | | } |
| | 46 | | } |
| 0 | 47 | | return sb.ToString(); |
| | 48 | | } |
| | 49 | | } |