RandomGFGoStop/Assets/Scripts/UI/Popup/ADSRemovePopup.cs

45 lines
1.5 KiB
C#
Raw Normal View History

2025-08-27 21:08:17 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ADSRemovePopup : PopupBase
{
public void ClickClose()
{
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
GameManager.UI.HideTopPopup();
}
public void ClickGameClose()
{
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
RestartApplication();
//GameManager.BGDatabase.ReleaseHuntingUnlockImage();
//GameManager.Scene.LoadScene(ESceneType.Title);
}
public void RestartApplication()
{
#if UNITY_ANDROID && !UNITY_EDITOR
using (var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
const int kIntent_FLAG_ACTIVITY_CLEAR_TASK = 0x00008000;
const int kIntent_FLAG_ACTIVITY_NEW_TASK = 0x10000000;
var currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
var pm = currentActivity.Call<AndroidJavaObject>("getPackageManager");
var intent = pm.Call<AndroidJavaObject>("getLaunchIntentForPackage", Application.identifier);
intent.Call<AndroidJavaObject>("setFlags", kIntent_FLAG_ACTIVITY_NEW_TASK | kIntent_FLAG_ACTIVITY_CLEAR_TASK);
currentActivity.Call("startActivity", intent);
currentActivity.Call("finish");
var process = new AndroidJavaClass("android.os.Process");
int pid = process.CallStatic<int>("myPid");
process.CallStatic("killProcess", pid);
}
#endif
}
}