GetCurrentDirectory
How do I use Get Current Directory
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PhotonConverter.cs
Copy
120 public static void PickFolderAndConvertScripts()
121 {
122 string folderPath = EditorUtility.OpenFolderPanel("Pick source folder to convert", Directory.GetCurrentDirectory(), "");
123 if (string.IsNullOrEmpty(folderPath))
124 {
125 EditorUtility.DisplayDialog("Script Conversion", "No folder was selected. No files were changed. Please start over.", "Ok.");
126 return;
127 }
128
129 bool result = EditorUtility.DisplayDialog("Script Conversion", "Scripts in this folder will be modified:\n\n" + folderPath + "\n\nMake sure you have backups of these scripts.\nConversion is not guaranteed to work!", "Backup done. Go!", "Abort");
130 if (!result)
131 {
132 return;
133 }
134
135 List
136 ConvertScripts(scripts);
137
138 EditorUtility.DisplayDialog("Script Conversion", "Scripts are now converted to PUN.\n\nYou will need to update\n- scenes\n- components\n- prefabs and\n- add \"PhotonNetwork.ConnectWithDefaultSettings();\"", "Ok");
139 }
File name: VSCode.cs
Copy
357 public static void UpdateSolution()
358 {
359 // No need to process if we are not enabled
360 if (!VSCode.Enabled)
361 {
362 return;
363 }
364
365 if (VSCode.Debug)
366 {
367 UnityEngine.Debug.Log("[VSCode] Updating Solution & Project Files");
368 }
369
370 var currentDirectory = Directory.GetCurrentDirectory();
371 var solutionFiles = Directory.GetFiles(currentDirectory, "*.sln");
372 var projectFiles = Directory.GetFiles(currentDirectory, "*.csproj");
373
374 foreach (var filePath in solutionFiles)
375 {
376 string content = File.ReadAllText(filePath);
377 content = ScrubSolutionContent(content);
378
379 File.WriteAllText(filePath, content);
380
381 ScrubFile(filePath);
382 }
383
384 foreach (var filePath in projectFiles)
385 {
386 string content = File.ReadAllText(filePath);
387 content = ScrubProjectContent(content);
388
389 File.WriteAllText(filePath, content);
390
391 ScrubFile(filePath);
392 }
393
394 }
GetCurrentDirectory 111 lượt xem
Gõ tìm kiếm nhanh...