2023-01-06 17:55:47 +08:00
|
|
|
|
#if UNITY_EDITOR
|
2022-12-29 18:20:40 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>
|
|
|
|
|
public class ProjectTool
|
|
|
|
|
{
|
|
|
|
|
///<summary>
|
|
|
|
|
/// <20>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɲ<EFBFBD>ͬ<EFBFBD>̲߳<DFB3><CCB2><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4>ڵ<EFBFBD><DAB5><EFBFBD>ʾ״̬
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="hWnd"><3E><><EFBFBD>ھ<EFBFBD><DABE><EFBFBD></param>
|
|
|
|
|
/// <param name="cmdShow">ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>鿴<EFBFBD><E9BFB4><EFBFBD><EFBFBD>ֵ<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ShowWlndow<6F><77><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ<D6B5><CEAA><EFBFBD>㣻<EFBFBD><E3A3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD>ֵΪ<D6B5><CEAA></returns>
|
|
|
|
|
[DllImport("User32.dll")]
|
|
|
|
|
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5>߳<EFBFBD><DFB3><EFBFBD><EFBFBD>õ<EFBFBD>ǰ̨<C7B0><CCA8><EFBFBD><EFBFBD><EFBFBD>Ҽ<EFBFBD><D2BC><EFBFBD><EFBFBD>ô<EFBFBD><C3B4>ڡ<EFBFBD><DAA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ô<EFBFBD><C3B4>ڣ<EFBFBD><DAA3><EFBFBD>Ϊ<EFBFBD>û<EFBFBD><C3BB>ĸ<EFBFBD><C4B8>ֿ<EFBFBD><D6BF>ӵļǺš<C7BA>
|
|
|
|
|
/// ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ̨<C7B0><CCA8><EFBFBD>ڵ<EFBFBD><DAB5>̷߳<DFB3><CCB7><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̡߳<DFB3>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="hWnd"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB2A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ̨<C7B0>Ĵ<EFBFBD><C4B4>ھ<EFBFBD><DABE><EFBFBD></param>
|
|
|
|
|
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ̨<C7B0><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ<D6B5><CEAA><EFBFBD>㣻<EFBFBD><E3A3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ̨<C7B0><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ<D6B5><CEAA></returns>
|
|
|
|
|
[DllImport("User32.dll")]
|
|
|
|
|
private static extern bool SetForegroundWindow(IntPtr hWnd);
|
|
|
|
|
|
|
|
|
|
static string ProjectPath => System.Environment.CurrentDirectory;
|
|
|
|
|
static string AssetsPath => ProjectPath + "\\Assets\\";
|
|
|
|
|
static string LubanToolsPath => ProjectPath + "\\LubanTools\\";
|
|
|
|
|
static string GameAssetsPath => AssetsPath + "GameAssets\\";
|
|
|
|
|
static string LubanToolsDesignerConfigsPath => LubanToolsPath + "DesignerConfigs\\";
|
|
|
|
|
|
2022-12-30 13:34:14 +08:00
|
|
|
|
[MenuItem("<22><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD>")]
|
2022-12-29 18:20:40 +08:00
|
|
|
|
static void CopyBuildCfg()
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Process proc = new System.Diagnostics.Process();
|
|
|
|
|
proc.StartInfo.FileName = LubanToolsPath + "gen_code_bin.bat";
|
|
|
|
|
//proc.StartInfo.Arguments = string.Format("10");//this is argument
|
|
|
|
|
//proc.StartInfo.UseShellExecute = false;//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>dos<6F><73><EFBFBD><EFBFBD>
|
|
|
|
|
//proc.StartInfo.CreateNoWindow = false;//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>dos<6F><73><EFBFBD><EFBFBD>
|
|
|
|
|
proc.StartInfo.WorkingDirectory = LubanToolsPath;
|
|
|
|
|
//proc.StartInfo.Verb = "runas";//<2F><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Թ<EFBFBD><D4B9><EFBFBD>ԱȨ<D4B1><C8A8><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD>
|
|
|
|
|
proc.Start();
|
|
|
|
|
//proc.WaitForExit();
|
|
|
|
|
HandleRunningInstance(proc);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-30 13:34:14 +08:00
|
|
|
|
[MenuItem("<22><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>)")]
|
2022-12-29 18:20:40 +08:00
|
|
|
|
static void CopyBuildCfg_Test()
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Process proc = new System.Diagnostics.Process();
|
|
|
|
|
proc.StartInfo.FileName = LubanToolsPath + "gen_code_bin - <20><><EFBFBD><EFBFBD>.bat";
|
|
|
|
|
//proc.StartInfo.Arguments = string.Format("10");//this is argument
|
|
|
|
|
//proc.StartInfo.UseShellExecute = false;//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>dos<6F><73><EFBFBD><EFBFBD>
|
|
|
|
|
//proc.StartInfo.CreateNoWindow = false;//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>dos<6F><73><EFBFBD><EFBFBD>
|
|
|
|
|
proc.StartInfo.WorkingDirectory = LubanToolsPath;
|
|
|
|
|
//proc.StartInfo.Verb = "runas";//<2F><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Թ<EFBFBD><D4B9><EFBFBD>ԱȨ<D4B1><C8A8><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD>
|
|
|
|
|
proc.Start();
|
|
|
|
|
//proc.WaitForExit();
|
|
|
|
|
HandleRunningInstance(proc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MenuItem("<22><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD>Ŀ¼/Assets")]
|
|
|
|
|
static void OpenAssetsDir()
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Process p = new System.Diagnostics.Process();
|
|
|
|
|
p.StartInfo.FileName = "explorer.exe";
|
|
|
|
|
p.StartInfo.Arguments = @" /select, "+ GameAssetsPath;
|
|
|
|
|
p.Start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MenuItem("<22><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD>Ŀ¼/Luban")]
|
|
|
|
|
static void OpenLubanDir()
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Process p = new System.Diagnostics.Process();
|
|
|
|
|
p.StartInfo.FileName = "explorer.exe";
|
|
|
|
|
p.StartInfo.Arguments = @" /select, " + LubanToolsDesignerConfigsPath;
|
|
|
|
|
p.Start();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 17:55:47 +08:00
|
|
|
|
[MenuItem("<22><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>/Git/Git-Bash<73><68><EFBFBD><EFBFBD>Assets")]
|
|
|
|
|
static void GitBashAssets()
|
|
|
|
|
{
|
|
|
|
|
string exepath = LubanToolsPath;
|
|
|
|
|
if (!File.Exists(exepath + "/copy_Path.txt"))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("copy_Path <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string GitBashDir = "";
|
|
|
|
|
string[] pathcfg = File.ReadAllText(exepath + "/copy_Path.txt").Split('\n'); ;
|
|
|
|
|
foreach (var pc in pathcfg)
|
|
|
|
|
{
|
|
|
|
|
var parr = pc.Split('=');
|
|
|
|
|
if (parr[0].Trim() == "GitBashDir") GitBashDir = parr[1].Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(GitBashDir))
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("<22><><EFBFBD><EFBFBD>lubanĿ¼copy_Path.txt<78><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SVN<56><4E>װĿ¼bin<69>ļ<EFBFBD><C4BC><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>GitBashDir=C:\\Program Files\\Git");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.Diagnostics.Process p = new System.Diagnostics.Process();
|
|
|
|
|
p.StartInfo.FileName = GitBashDir + "//git-bash.exe";
|
|
|
|
|
p.StartInfo.Arguments = " --cd=" + AssetsPath;
|
|
|
|
|
p.Start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MenuItem("<22><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>/Git/Git-Bash<73><68><EFBFBD><EFBFBD>Luban")]
|
|
|
|
|
static void GitBashLuban()
|
|
|
|
|
{
|
|
|
|
|
string exepath = LubanToolsPath;
|
|
|
|
|
if (!File.Exists(exepath + "/copy_Path.txt"))
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("copy_Path <20><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string GitBashDir = "";
|
|
|
|
|
string[] pathcfg = File.ReadAllText(exepath + "/copy_Path.txt").Split('\n'); ;
|
|
|
|
|
foreach (var pc in pathcfg)
|
|
|
|
|
{
|
|
|
|
|
var parr = pc.Split('=');
|
|
|
|
|
if (parr[0].Trim() == "GitBashDir") GitBashDir = parr[1].Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(GitBashDir))
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError("<22><><EFBFBD><EFBFBD>lubanĿ¼copy_Path.txt<78><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SVN<56><4E>װĿ¼bin<69>ļ<EFBFBD><C4BC><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>GitBashDir=C:\\Program Files\\Git");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.Diagnostics.Process p = new System.Diagnostics.Process();
|
|
|
|
|
p.StartInfo.FileName = GitBashDir + "//git-bash.exe";
|
|
|
|
|
p.StartInfo.Arguments = " --cd=" + LubanToolsPath;
|
|
|
|
|
p.Start();
|
|
|
|
|
}
|
2022-12-29 18:20:40 +08:00
|
|
|
|
|
|
|
|
|
private const int SW_SHOWNOMAL = 1;
|
|
|
|
|
private static void HandleRunningInstance(System.Diagnostics.Process instance)
|
|
|
|
|
{
|
|
|
|
|
ShowWindowAsync(instance.MainWindowHandle, SW_SHOWNOMAL);//<2F><>ʾ
|
|
|
|
|
SetForegroundWindow(instance.MainWindowHandle);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-01-06 17:55:47 +08:00
|
|
|
|
#region <EFBFBD>Ҽ<EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>˵<EFBFBD>
|
|
|
|
|
|
|
|
|
|
[MenuItem("Assets/<2F><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ļ<EFBFBD>", false)]
|
|
|
|
|
public static void FindAssetsFileDir()
|
|
|
|
|
{
|
|
|
|
|
string path = ProjectPath + "\\" + AssetDatabase.GetAssetPath(Selection.activeInstanceID);
|
|
|
|
|
path = path.Replace('/', '\\');
|
|
|
|
|
System.Diagnostics.Process p = new System.Diagnostics.Process();
|
|
|
|
|
p.StartInfo.FileName = "explorer.exe";
|
|
|
|
|
p.StartInfo.Arguments = @" /select, " + path;
|
|
|
|
|
p.Start();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2022-12-29 18:20:40 +08:00
|
|
|
|
}
|
2023-01-06 17:55:47 +08:00
|
|
|
|
|
|
|
|
|
#endif
|