学了用unity3d开发了一个小游戏,然后要求我们画出项目中的详细类图并说明每个类的功能,但是又给我们分两部分:C#的架构设计、C#类的功能设计
到底是什么意思啊理解不了,怎么分为架构设计和功能设计
以及,游戏架构到底是什么我还是理解不了,怎么才算我开发的这个游戏用到了游戏架构这个知识点
没啥本质区别,但是通常来说,架构设计是那种颗粒度比较大的图,比如说,一般只画主要的类,类中主要的成员甚至不画出成员,以及类的关系。
而类图一般会详细画出所有的成员。类似《中国地图》和《xx公园平面图》的区别。
入参arguments: 控制台需要输入的命令行
文件名FileName : 传入exe绝对路径,关于unity路径问题最好规范点,统一使用'/'
private void CallCmd(string arguments)
{
Encoding GBK = Encoding.GetEncoding(936);
try
{
Process process = new Process();
process.StartInfo.FileName = m_StreamingAssertExePath;
process.StartInfo.Arguments = arguments;
process.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
process.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
process.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
process.StartInfo.RedirectStandardError = true;//重定向标准错误输出
process.StartInfo.StandardOutputEncoding = GBK;
process.StartInfo.CreateNoWindow = true;//不显示程序窗口
process.Start();//启动程序
process.OutputDataReceived += (s, _e) =>
{
UnityEngine.Debug.Log(GBK2UTF8(_e.Data));
};
process.ErrorDataReceived += (s, _e) =>
{
UnityEngine.Debug.Log(GBK2UTF8(_e.Data));
};
process.EnableRaisingEvents = true;
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
}
catch (Exception e)
{
UnityEngine.Debug.LogError(e.Message);
}
}
public static string GBK2UTF8(string value)
{
Encoding GBK = Encoding.GetEncoding(936);
byte[] bytes = Encoding.Convert(GBK, Encoding.UTF8, GBK.GetBytes(value));
return Encoding.UTF8.GetString(bytes);
}
直接调用CallCmd的话,会发现还是会阻塞主线程, 把process执行完才会执行主线程.
所以要把此函数放到子线程里去执行,*.exe没有做死循环或者阻碍线程运行的操作,所以在子线程调用结束会等待自动回收的.所以没必要Abort().
这里是自己写的保存一张照片命令行
public void Send_GetPicture()
{
if (!HasCmdExe) return;
Thread thread = new Thread(new ThreadStart(exe_Picture));
thread.Start();
}
private void exe_Picture()
{
string instructions = string.Format("{0},{1},{2}", (int)CmdSelect.Capture, 0, m_URL);
CallCmd(instructions);
}