public string GetCWD(bool full = false) { string scriptPath = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName().Replace('\\', '/'); string assetPath = Application.dataPath; string path; string[] pathArray; if (full) { path = scriptPath; pathArray = path.Split('/'); } else { path = scriptPath.Replace(assetPath, "Assets"); pathArray = path.Split('/'); } string currentFolderProjectPath = System.String.Join("/", pathArray.Take(pathArray.Length - 1)); return(currentFolderProjectPath); }
private static string GetDefaultIncludeFilename() { string filename; try { filename = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName(); filename = Path.Combine( Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename) + "_Include.txt"); if ((!File.Exists(filename)) || string.IsNullOrEmpty(Application.dataPath)) { return null; } } catch { return null; } filename = filename.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); string dataPath = Application.dataPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); if ((filename.StartsWith(dataPath, StringComparison.OrdinalIgnoreCase))) { filename = filename.Substring(dataPath.Length).TrimStart(Path.DirectorySeparatorChar); } return filename; }