当前上下文中不存在名称“ Permission”

时间:2019-09-12 14:38:34

标签: c# unity3d

Assets \ Wikitude \ Samples \ Scripts \ MenuController.cs(26,46):错误CS0103:名称'Permission'在当前上下文中不存在

#if UNITY_2018_3_OR_NEWER && UNITY_ANDROID

    if (!Permission.HasUserAuthorizedPermission(Permission.Camera)) {
        Permission.RequestUserPermission(Permission.Camera);
    }

1 个答案:

答案 0 :(得分:0)

PermissionUnityEngine.Android命名空间中,因此,如果要简单地将其引用为using UnityEngine.Android,则需要在脚本中包含Permission

using UnityEngine;
using UnityEngine.Android;

...

#if UNITY_2018_3_OR_NEWER && UNITY_ANDROID

    if (!Permission.HasUserAuthorizedPermission(Permission.Camera)) {
        Permission.RequestUserPermission(Permission.Camera);
    }