private static string GetUnityPath()
{
#region 通过注册便获取Unity安装路径
var regKey = @"Unity package file\DefaultIcon";
RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(regKey);
string pathName = (string)registryKey.GetValue(null); // "(Default)"
if (string.IsNullOrEmpty(pathName))
{
return null;
}
int index = pathName.LastIndexOf(",");
if (index != -1)
{
var exepath = pathName.Substring(0, index).Replace("\"", string.Empty);
var binpath = Path.GetDirectoryName(exepath);
var di = new DirectoryInfo(binpath);
if (di.Parent != null)
{
return di.Parent.FullName;
}
}
return null;
#endregion
}
static void StartPeocess(string applicationPath)
{
Process po = new Process();
po.StartInfo.FileName = applicationPath;
po.Start();
}
string[] args = unityPath.Split('\\');
Process[] pro = Process.GetProcessesByName(args[args.Length - 1].Split('.')[0]);//Unity
foreach (var item in pro)
{
UnityEngine.Debug.Log(item.MainModule);
item.Kill();
}
using Microsoft.Win32;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using UnityEditor;
using UnityEngine;
public class ReStartUnityTools : MonoBehaviour
{
public static string UnityExePath = "E:\\Unity 5.5.2\\Unity\\Editor\\Unity.exe";
[MenuItem("Tools/ReStartUnity(重启Unity)")]
public static void ReStartUnity()
{
string unityPath = UnityExePath;// GetUnityPath();公司电脑通过注册表是可以的,家里电脑不行,你们可以用这个函数试下,实在不行先写上Unity安装路径吧
StartPeocess(unityPath);
string[] args = unityPath.Split('\\');
Process[] pro = Process.GetProcessesByName(args[args.Length - 1].Split('.')[0]);//Unity
foreach (var item in pro)
{
UnityEngine.Debug.Log(item.MainModule);
item.Kill();
}
}
private static string GetUnityPath()
{
#region 通过注册便获取Unity安装路径
var regKey = @"Unity package file\DefaultIcon";
RegistryKey registryKey = Registry.ClassesRoot.OpenSubKey(regKey);
string pathName = (string)registryKey.GetValue(null); // "(Default)"
if (string.IsNullOrEmpty(pathName))
{
return null;
}
int index = pathName.LastIndexOf(",");
if (index != -1)
{
var exepath = pathName.Substring(0, index).Replace("\"", string.Empty);
var binpath = Path.GetDirectoryName(exepath); //
var di = new DirectoryInfo(binpath);
if (di.Parent != null)
{
return di.Parent.FullName;
}
}
return null;
#endregion
}
static void StartPeocess(string applicationPath)
{
Process po = new Process();
po.StartInfo.FileName = applicationPath;
po.Start();
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有