AkiraPixelWind/Assets/Scripts/Editor/ProjectTools/ProjectTool.cs

96 lines
3.6 KiB
C#
Raw Normal View History

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
{
#if UNITY_EDITOR
///<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();
}
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>
}
#endif
}