71 lines
2.4 KiB
C#
71 lines
2.4 KiB
C#
using UnityEngine.UI;
|
||
using ZXKFramework;
|
||
using UnityEditor;
|
||
using UnityEngine;
|
||
using System.IO;
|
||
using System.Diagnostics;
|
||
using Debug = UnityEngine.Debug;
|
||
namespace DongWuYiXue.Main
|
||
{
|
||
public class HomePanel : UIBase
|
||
{
|
||
Button shutBtn;
|
||
Button homeBtn;
|
||
public override string GroupName => "HomePanel";
|
||
public override string Name => "HomePanel";
|
||
public override void Init(IUIManager uictrl)
|
||
{
|
||
base.Init(uictrl);
|
||
shutBtn = transform.FindFirst<Button>("ShutBtn");
|
||
if (Game.Instance.platformType == PlatformType.WebGL)
|
||
{
|
||
shutBtn.gameObject.SetActive(false);
|
||
}
|
||
homeBtn = transform.FindFirst<Button>("BackBtn");
|
||
shutBtn.onClick.AddListener(() => {
|
||
#if UNITY_EDITOR //在编辑器模式下
|
||
EditorApplication.isPlaying = false;
|
||
#else
|
||
Application.Quit();
|
||
#endif
|
||
});
|
||
homeBtn.onClick.AddListener(() =>
|
||
{
|
||
|
||
#if UNITY_EDITOR //在编辑器模式下
|
||
EditorApplication.isPlaying = false;
|
||
#else
|
||
try
|
||
{
|
||
// 获取当前b程序的运行路径(在打包后,Application.dataPath指向a_Data目录)
|
||
string dataPath = Application.dataPath;
|
||
//Debug.Log(dataPath);
|
||
// 构建从b所在目录到a.exe的路径
|
||
// 导航逻辑:a_Data -> 上一级(a.exe所在目录)
|
||
string aExePath = Path.Combine(dataPath, @"../../../..", "静脉输液四合一.exe");
|
||
|
||
// 转换为绝对路径,处理相对路径符号".."
|
||
aExePath = Path.GetFullPath(aExePath);
|
||
|
||
// 检查文件是否存在
|
||
if (File.Exists(aExePath))
|
||
{
|
||
// 启动a.exe
|
||
Process.Start(new ProcessStartInfo(aExePath));
|
||
Debug.Log($"成功启动静脉输液四合一.exe,路径:{aExePath}");
|
||
}
|
||
else
|
||
{
|
||
Debug.LogError($"未找到静脉输液四合一.exe,查找路径:{aExePath}");
|
||
}
|
||
}
|
||
catch (System.Exception ex)
|
||
{
|
||
Debug.LogError($"启动静脉输液四合一.exe失败:{ex.Message}");
|
||
}
|
||
Application.Quit();
|
||
#endif
|
||
});
|
||
}
|
||
}
|
||
} |