71 lines
2.4 KiB
C#
Raw Normal View History

2025-09-08 14:51:28 +08:00
using UnityEngine.UI;
using ZXKFramework;
using UnityEditor;
using UnityEngine;
using System.IO;
using System.Diagnostics;
using Debug = UnityEngine.Debug;
2025-09-08 17:37:12 +08:00
namespace DongWuYiXue.Main
2025-09-08 14:51:28 +08:00
{
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 //<2F>ڱ༭<DAB1><E0BCAD>ģʽ<C4A3><CABD>
EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
});
homeBtn.onClick.AddListener(() =>
{
#if UNITY_EDITOR //<2F>ڱ༭<DAB1><E0BCAD>ģʽ<C4A3><CABD>
EditorApplication.isPlaying = false;
#else
try
{
// <20><>ȡ<EFBFBD><C8A1>ǰb<C7B0><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Application.dataPathָ<68><D6B8>a_DataĿ¼<C4BF><C2BC>
string dataPath = Application.dataPath;
//Debug.Log(dataPath);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>b<EFBFBD><62><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC>a.exe<78><65>·<EFBFBD><C2B7>
// <20><><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD>a_Data -> <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>a.exe<78><65><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC>
string aExePath = Path.Combine(dataPath, @"../../../..", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һ<EFBFBD>ĺ<EFBFBD>һ.exe");
// ת<><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>".."
aExePath = Path.GetFullPath(aExePath);
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
if (File.Exists(aExePath))
{
// <20><><EFBFBD><EFBFBD>a.exe
Process.Start(new ProcessStartInfo(aExePath));
Debug.Log($"<22>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һ<EFBFBD>ĺ<EFBFBD>һ.exe<78><65>·<EFBFBD><C2B7><EFBFBD><EFBFBD>{aExePath}");
}
else
{
Debug.LogError($"δ<>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һ<EFBFBD>ĺ<EFBFBD>һ.exe<78><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>{aExePath}");
}
}
catch (System.Exception ex)
{
Debug.LogError($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һ<EFBFBD>ĺ<EFBFBD>һ.exeʧ<65>ܣ<EFBFBD>{ex.Message}");
}
Application.Quit();
#endif
});
}
}
}