-
Notifications
You must be signed in to change notification settings - Fork 0
/
Quicklabels.Cs.cs
49 lines (40 loc) · 1.31 KB
/
Quicklabels.Cs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# if false
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System.Diagnostics;
using System.IO;
public static class Programm {
public static void Main(string[] args) {
Console.WriteLine("==== QuickLabels.cs ====\n");
foreach (var l in QuickLabels("/home/benj/idlegame/IdleGame/Assets/LoadGroups/WeeklyEvents/WeeklyEvents.prefab.meta")) {
Console.WriteLine(l);
}
}
public static HashSet<string> QuickLabels(string fileOrMeta) {
var res = new HashSet<string>();
var metaFile = Path.GetExtension(fileOrMeta) == ".meta" ? fileOrMeta : $"{fileOrMeta}.meta";
if (!File.Exists(metaFile)) {
return res;
}
using (var sr = File.OpenText(metaFile)) {
bool insideLabels = false;
var line = sr.ReadLine();
while (line != null) {
if (line == "labels:") {
insideLabels = true;
} else if (insideLabels) {
if (line.IndexOf("- ") == 0) {
res.Add(line.Substring(2));
} else {
break;
}
}
line = sr.ReadLine();
}
}
return res;
}
}
# endif