Files
PrinceOfGlory/Assets/Scripts/Help/PermissionRequest.cs
kridoo ac041525cc 1
2026-01-12 09:39:28 +08:00

37 lines
873 B
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 System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Android;
public class PermissionRequest : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
requestPermission();
}
private void requestPermission()
{
if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead))
Permission.RequestUserPermission(Permission.ExternalStorageRead);
}
private void OnApplicationFocus(bool hasFocus)
{
if (hasFocus)
{
//Debug.Log("应用程序获得焦点OnApplicationFocus" + hasFocus);
}
else
{
//Debug.Log("应用程序失去焦点OnApplicationFocus" + hasFocus);
}
if (hasFocus)
{
requestPermission();
}
}
}