66 lines
1.6 KiB
C#
66 lines
1.6 KiB
C#
![]() |
// ***********************************************************************
|
||
|
// Assembly : Unity
|
||
|
// Author : Kimch
|
||
|
// Created :
|
||
|
//
|
||
|
// Last Modified By : Kimch
|
||
|
// Last Modified On :
|
||
|
// ***********************************************************************
|
||
|
// <copyright file= "BuildProtocol" company=""></copyright>
|
||
|
// <summary></summary>
|
||
|
// ***********************************************************************
|
||
|
using System;
|
||
|
using System.Diagnostics;
|
||
|
using System.IO;
|
||
|
|
||
|
using UnityEditor;
|
||
|
|
||
|
public class BuildProtocol
|
||
|
{
|
||
|
#region Const
|
||
|
|
||
|
private const string BAT_FILE = @"../../common/protocol/clientprotogen.bat";
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
[MenuItem("Game/生成协议类")]
|
||
|
public static void BuildAndCopy()
|
||
|
{
|
||
|
Build();
|
||
|
Copy();
|
||
|
}
|
||
|
|
||
|
private static void Build()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
var batFile = new FileInfo(BAT_FILE);
|
||
|
|
||
|
var process = new Process();
|
||
|
process.StartInfo.CreateNoWindow = false;
|
||
|
process.StartInfo.FileName = batFile.FullName;
|
||
|
process.StartInfo.WorkingDirectory = batFile.Directory.FullName;
|
||
|
|
||
|
process.Start();
|
||
|
process.WaitForExit();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
UnityEngine.Debug.Log(string.Format("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString()));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static void Copy()
|
||
|
{
|
||
|
var batFile = new FileInfo(BAT_FILE);
|
||
|
var src = Path.Combine(batFile.Directory.FullName, "csproto");
|
||
|
var dst = "Assets/Ryff/Scripts/Protocol";
|
||
|
var srcFiles = Directory.GetFiles(src, "*.cs");
|
||
|
|
||
|
foreach (var srcFile in srcFiles)
|
||
|
{
|
||
|
var fileName = Path.GetFileName(srcFile);
|
||
|
File.Copy(srcFile, Path.Combine(dst, fileName), true);
|
||
|
}
|
||
|
}
|
||
|
}
|