Esempio n. 1
0
 public void UpdateUnityProcessInfos()
 {
     UnityProcessInfos.Clear();
     foreach (var projectInfo in UnityProjectInfos)
     {
         var lockFile = $"{projectInfo.projectPath}/Temp/UnityLockfile";
         if (File.Exists(lockFile))
         {
             var lockers = FileUtil.WhoIsLocking(lockFile);
             if (lockers.Count > 0)
             {
                 foreach (var locker in lockers)
                 {
                     if (locker.ProcessName == "Unity")
                     {
                         var processInfo = new UnityProcessInfo()
                         {
                             project = projectInfo,
                             process = lockers[0]
                         };
                         processInfo.project.projectName += $"(PID:{processInfo.process.Id})";
                         if (processInfo.process.Responding == false)
                         {
                             processInfo.project.projectName += "(未响应)";
                         }
                         UnityProcessInfos.Add(processInfo);
                         break;
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
 public void CloseUnityProcess(UnityProcessInfo unityProcessInfo)
 {
     if (UnityProcessInfos.Remove(unityProcessInfo))
     {
         unityProcessInfo.process.Kill();
     }
 }
Esempio n. 3
0
 public void RestartUnityProcess(UnityProcessInfo unityProcessInfo)
 {
     if (UnityProcessInfos.Remove(unityProcessInfo))
     {
         unityProcessInfo.process.Kill();
         UNITY_PROCESS_START_INFO.FileName  = unityProcessInfo.process.MainModule.FileName;
         UNITY_PROCESS_START_INFO.Arguments = $"-projectPath \"{unityProcessInfo.project.projectPath}\"";
         Process.Start(UNITY_PROCESS_START_INFO);
     }
 }
Esempio n. 4
0
 public void SelectUnityProcess(UnityProcessInfo unityProcessInfo)
 {
     ShowWindow(unityProcessInfo.process.MainWindowHandle, SW_RESTORE);
     ShowWindow(unityProcessInfo.process.MainWindowHandle, SW_MAXIMIZED);
 }