GetDirectories
How do I use Get Directories
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PunStartup.cs
Copy
80 public static void SetPunDemoBuildSettings()
81 {
82 // find path of pun guide
83 string[] tempPaths = Directory.GetDirectories(Application.dataPath + "/Photon Unity Networking", "Demos", SearchOption.AllDirectories);
84 if (tempPaths == null || tempPaths.Length != 1)
85 {
86 return;
87 }
88
89 // find scenes of guide
90 string guidePath = tempPaths[0];
91 tempPaths = Directory.GetFiles(guidePath, "*.unity", SearchOption.AllDirectories);
92
93 if (tempPaths == null || tempPaths.Length == 0)
94 {
95 return;
96 }
97
98 // add found guide scenes to build settings
99 List
100 for (int i = 0; i < tempPaths.Length; i++)
101 {
102 //Debug.Log(tempPaths[i]);
103 string path = tempPaths[i].Substring(Application.dataPath.Length - "Assets".Length);
104 path = path.Replace('\\', '/');
105 //Debug.Log(path);
106
107 if (path.Contains("PUNGuide_M2H"))
108 {
109 continue;
110 }
111
112 if (path.Contains("Hub"))
113 {
114 sceneAr.Insert(0, new EditorBuildSettingsScene(path, true));
115 continue;
116 }
117
118 sceneAr.Add(new EditorBuildSettingsScene(path, true));
119 }
120
121 EditorBuildSettings.scenes = sceneAr.ToArray();
122 EditorApplication.OpenScene(sceneAr[0].path);
123 }
File name: Tiled2UnityMenuItems.cs
Copy
40 private static IEnumerable41 {
42 foreach (string d in Directory.GetDirectories(dir))
43 {
44 foreach (string f in Directory.GetFiles(d))
45 {
46 if (extensions.Any(ext => String.Compare(ext, Path.GetExtension(f), true) == 0))
47 {
48 yield return f;
49 }
50 }
51
52 foreach (string f in EnumerateAssetFilesAt(d, extensions))
53 {
54 yield return f;
55 }
56 }
57 }
GetDirectories 158 lượt xem
Gõ tìm kiếm nhanh...