public string GetPath(PathReturnType pathType, PathFormat format) { string fullPath = ""; if (pathType.HasFlag(PathReturnType.GetVolume)) { fullPath = Volume + GetVolumeSeparator(format); } switch (format) { case PathFormat.Windows: { if (!m_relative) { fullPath += "\\"; } break; } case PathFormat.Unix: { if (!m_relative) { if (m_dirs.Count == 0 || m_dirs[0] != "~") { fullPath += "/"; } } break; } } if (m_dirs.Count == 0) { return(fullPath); } for (int i = 0; i < m_dirs.Count; i++) { switch (format) { case PathFormat.Windows: case PathFormat.Unix: { fullPath += m_dirs[i]; break; } } if (pathType.HasFlag(PathReturnType.GetSeparator) || i != m_dirs.Count - 1) { fullPath += GetPathSeparator(format); } } return(fullPath); }
public static string[] GetAllFiles(string path, bool includeMetaFile = false, PathReturnType pathReturnType = PathReturnType.AssetsPath) { List <string> result = new List <string>(); GetFilesRecursive(path, result, includeMetaFile, pathReturnType); return(result.ToArray()); }
public string GetFullPath(PathFormat format) { PathReturnType pathType = PathReturnType.GetVolume | PathReturnType.GetSeparator; string fullPath = GetPath(pathType, format); fullPath += FullName; return(fullPath); }
//"Assets/Scenes" public static string[] GetAllFilesInProject(string assetPath, PathReturnType pathReturnType = PathReturnType.AssetsPath) { List <string> result = new List <string>(); string path = Application.dataPath.Replace("Assets", "") + assetPath; GetFilesRecursive(path, result, false, pathReturnType); return(result.ToArray()); }
private static void GetFilesRecursive(string path, List <string> result, bool includeMetaFile, PathReturnType pathReturnType) { DirectoryInfo info = new DirectoryInfo(path); FileInfo[] files = info.GetFiles(); DirectoryInfo[] dirs = info.GetDirectories(); foreach (var v in files) { if (!includeMetaFile && v.Name.EndsWith(".meta")) { continue; } if (pathReturnType == PathReturnType.OnlyName) { result.Add(v.Name); } else if (pathReturnType == PathReturnType.FullPath) { result.Add(v.FullName); } else { string assetPath; #if UNITY_EDITOR_OSX assetPath = v.FullName.Replace(Application.dataPath, "Assets"); #else assetPath = v.FullName.Replace(Application.dataPath.Replace("/", "\\"), "Assets"); #endif result.Add(assetPath); } } foreach (var dir in dirs) { GetFilesRecursive(dir.FullName, result, includeMetaFile, pathReturnType); } }
public string GetPath(PathReturnType pathType) { return(GetPath(pathType, m_format)); }