您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
31 行
929 B
31 行
929 B
using HuaweiService;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace CloudStorageTest
|
|
{
|
|
public class RequestPermissionButton : MonoBehaviour
|
|
{
|
|
public Button m_button;
|
|
|
|
private string[] permissions =
|
|
{
|
|
"android.permission.READ_EXTERNAL_STORAGE",
|
|
"android.permission.WRITE_EXTERNAL_STORAGE",
|
|
};
|
|
|
|
void Start()
|
|
{
|
|
Button btn = m_button.GetComponent<Button>();
|
|
btn.onClick.AddListener(request);
|
|
}
|
|
|
|
void request()
|
|
{
|
|
AndroidJavaClass javaUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
|
AndroidJavaObject currentActivity = javaUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
|
Activity activity = HmsUtil.GetHmsBase<Activity>(currentActivity);
|
|
ActivityCompat.requestPermissions(activity, permissions, 1);
|
|
}
|
|
}
|
|
}
|