hiyorin / PermissionPlugin-for-Unity

A set of tools for Unity to allow handling Permission for Android and iOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PermissionPlugin

A set of tools for Unity to allow handling Permission for Android and iOS.

Install

PermissionPlugin.unitypackage

Usage

using Permission;

Example: Check permissions.

public IEnumerator Example()
{
  yield return PermissionPlugin.Check(PermissionType.Camera, result =
  {
    Debug.Log(result);
  });
}

Example: Request permission.

public IEnumerator Example()
{
  yield return PermissionPlugin.Request(PermissionType.Camera, result =>
  {
    Debug.Log(result);
  });
}

Example: Open permission setting screen.

public void Example()
{
  PermissionPlugin.Open(PermissionType.Camera);
}

AndroidManifest.xml

Replace main Activity.

<!--
<activity android:name="com.unity3d.player.UnityPlayerActivity" ...
-->
<activity android:name="com.hiyorin.permission.CustomUnityPlayerActivity" ...

When using your own UnityPlayerActivity

Please pass the value of OnRequestPermissionsResult of your Activity

public void Exapmle(int requestCode, string[] permissions, int[] grantResults)
{
  PermissionPlugin.AndroidRequestPermissionsResult(requestCode, permissions, grantResults);
}

About

A set of tools for Unity to allow handling Permission for Android and iOS.

License:MIT License


Languages

Language:C# 72.8%Language:Java 17.5%Language:Objective-C++ 9.7%