/UniAndroidPermission

Android Runtime Permission for Unity

Primary LanguageC#MIT LicenseMIT

UniAndroidPremission

Plugin for use runtime permission at unity. It works only Android Devices AndroidSS

Installation

Use unitypackage under Distribution

Usage

1 Add uses-permission to AndroidManifest

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

2 Add Custom Activity and SkipPermissionsDialog to Android Manifest

<activity android:name=“net.sanukin.OverrideUnityActivity"
         android:label="@string/app_name"
         android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />

3 Add UniAndroidPermission.prefab at boot scene ※ Don't rename object name!!

4 Call method before function which need permissions

Check if permission permitted.

UniAndroidPermission.IsPermitted (AndroidPermission.WRITE_EXTERNAL_STORAGE)

Request Permission by runtime permission

UniAndroidPermission.RequestPremission (AndroidPermission.WRITE_EXTERNAL_STORAGE, () => {
    // add permit action
}, () => {
    // add not permit action
});

License

Copyright (c) 2015 wataru.sanuki

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.