public static bool OpenAsset(string file, int line) { if (string.IsNullOrEmpty(file) || file == "None") { return(false); } if (file.StartsWith("Assets/")) { var obj = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(file); if (obj) { AssetDatabase.OpenAsset(obj, line); } return(false); } string fileFullPath = Path.GetFullPath(file.Replace('/', '\\')); #if UNITY_2018_1_OR_NEWER var packageInfos = Packages.GetAll(); foreach (var packageInfo in packageInfos) { if (fileFullPath.StartsWith(packageInfo.resolvedPath, StringComparison.Ordinal)) { InternalEditorUtility.OpenFileAtLineExternal(fileFullPath, line); return(true); } } #elif UNITY_2017_1_OR_NEWER // TODO #endif LoadScriptAssetOpener(); if (!sao.initialized) { return(false); } string dirPath = fileFullPath; do { dirPath = Path.GetDirectoryName(dirPath); if (!string.IsNullOrEmpty(dirPath) && Directory.Exists(dirPath)) { var files = Directory.GetFiles(dirPath, "*.sln", SearchOption.TopDirectoryOnly); if (files.Length > 0) { sao.OpenEditor(files[0], fileFullPath, line); return(true); } } else { break; } } while (true); return(false); }
static public async Task fillPackage(ComboBox combo) { packages = await package.GetAll(); combo.ItemsSource = packages.Where(x => x.isActive == 1); combo.SelectedValuePath = "packageId"; combo.DisplayMemberPath = "packageName"; combo.SelectedIndex = -1; }
private static void OpenVisualStudioFile(string projectPath, string file, int line) { #if UNITY_2017_1_OR_NEWER string vsPath = ScriptEditorUtility.GetExternalScriptEditor(); #else string vsPath = InternalEditorUtility.GetExternalScriptEditor(); #endif if (IsNotWindowsEditor()) { Process.Start("open", "-a " + QuotePathIfNeeded(vsPath) + " " + QuotePathIfNeeded(file)); return; } if (string.IsNullOrEmpty(vsPath) || !File.Exists(vsPath)) { return; } string exePath = String.Empty; #if UNITY_2018_1_OR_NEWER var packageInfos = Packages.GetAll(); foreach (var packageInfo in packageInfos) { if (packageInfo.name == "com.wuhuan.consoletiny") { exePath = packageInfo.resolvedPath; // https://github.com/akof1314/VisualStudioFileOpenTool exePath = exePath + "\\Editor\\VisualStudioFileOpenTool.exe"; break; } } #elif UNITY_2017_1_OR_NEWER // TODO exePath = "../../PackagesCustom/com.wuhuan.consoletiny"; #endif if (string.IsNullOrEmpty(exePath)) { exePath = "Assets/Editor/VisualStudioFileOpenTool.exe"; } if (!string.IsNullOrEmpty(exePath)) { if (!File.Exists(exePath)) { return; } ThreadPool.QueueUserWorkItem(_ => { OpenVisualStudioFileInter(exePath, vsPath, projectPath, file, line); }); } }
public void OpenEditor(string projectPath, string file, int line) { m_SolutionFile = projectPath; if (m_ScriptOpenerType != null) { ThreadPool.QueueUserWorkItem(_ => { OpenEditorInter(projectPath, file, line); }); } else { #if UNITY_2017_1_OR_NEWER string vsPath = ScriptEditorUtility.GetExternalScriptEditor(); #else string vsPath = InternalEditorUtility.GetExternalScriptEditor(); #endif if (string.IsNullOrEmpty(vsPath) || !File.Exists(vsPath)) { return; } string exePath = String.Empty; #if UNITY_2018_1_OR_NEWER var packageInfos = Packages.GetAll(); foreach (var packageInfo in packageInfos) { if (packageInfo.name == "com.wuhuan.consoletiny") { exePath = packageInfo.resolvedPath; break; } } #elif UNITY_2017_1_OR_NEWER // TODO exePath = "../../PackagesCustom/com.wuhuan.consoletiny"; #endif if (!string.IsNullOrEmpty(exePath)) { exePath = exePath + "\\Editor\\VisualStudioFileOpenTool.exe"; ThreadPool.QueueUserWorkItem(_ => { OpenEditorInter2(exePath, vsPath, projectPath, file, line); }); } } }
public static async Task <bool> isCodeExist(string randomNum, string type, string _class, int id) { bool iscodeExist = false; try { if (_class.Equals("Users")) { List <Users> users = await userModel.GetAll(); if (users.Any(u => u.code == randomNum && u.userId != id && u.type == type)) { iscodeExist = true; } else { iscodeExist = false; } } else if (_class.Equals("Customers")) { List <Customers> customers = await customerModel.GetAll(); if (customers.Any(b => b.custCode == randomNum && b.custId != id)) { iscodeExist = true; } else { iscodeExist = false; } } else if (_class.Equals("Packages")) { List <Packages> packages = await packageModel.GetAll(); if (packages.Any(b => b.packageCode == randomNum && b.packageId != id)) { iscodeExist = true; } else { iscodeExist = false; } } } catch { } return(iscodeExist); }
/// <summary> /// Returns visibles packages, it excludes modules and non-root dependencies (used in project browser) /// <returns>an array of package information ordererd by display name.</returns> /// </summary> public static PackageManager.PackageInfo[] GetAllVisiblePackages() { return(Packages.GetAll().Where(info => info.isRootDependency && info.type != "module"). OrderBy(info => string.IsNullOrEmpty(info.displayName) ? info.name : info.displayName, StringComparer.InvariantCultureIgnoreCase).ToArray()); }
public static bool OpenAsset(string file, int line) { if (string.IsNullOrEmpty(file) || file == "None") { return(false); } if (file.StartsWith("Assets/")) { var ext = Path.GetExtension(file).ToLower(); if (ext == ".lua" && TryOpenLuaFile(file, line)) { return(true); } var obj = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(file); if (obj) { AssetDatabase.OpenAsset(obj, line); return(true); } return(false); } char separatorChar = '\\'; string fileFullPath; if (IsNotWindowsEditor()) { separatorChar = '/'; fileFullPath = Path.GetFullPath(file); } else { fileFullPath = Path.GetFullPath(file.Replace('/', separatorChar)); } #if UNITY_2018_1_OR_NEWER var packageInfos = Packages.GetAll(); foreach (var packageInfo in packageInfos) { if (fileFullPath.StartsWith(packageInfo.resolvedPath, StringComparison.Ordinal)) { InternalEditorUtility.OpenFileAtLineExternal(fileFullPath, line); return(true); } } #elif UNITY_2017_1_OR_NEWER // TODO #endif // 别人编译的DLL,不存在文件路径,那么就以工程路径拼接组装来尝试获取本地路径 if (!File.Exists(fileFullPath)) { string directoryName = Directory.GetCurrentDirectory(); while (true) { if (string.IsNullOrEmpty(directoryName) || !Directory.Exists(directoryName)) { return(false); } int pos = fileFullPath.IndexOf(separatorChar); while (pos != -1) { string testFullPath = Path.Combine(directoryName, fileFullPath.Substring(pos + 1)); if (File.Exists(testFullPath) && TryOpenVisualStudioFile(testFullPath, line)) { return(true); } pos = fileFullPath.IndexOf(separatorChar, pos + 1); } directoryName = Path.GetDirectoryName(directoryName); } } return(TryOpenVisualStudioFile(fileFullPath, line)); }
async Task <IEnumerable <Packages> > RefreshPackagesList() { packages = await package.GetAll(); return(packages); }