71 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine.UI;
using ZXKFramework;
using UnityEditor;
using UnityEngine;
using System.IO;
using System.Diagnostics;
using Debug = UnityEngine.Debug;
namespace YiLiao.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
});
}
}
}