How voxelbusters/permissions-kit works
Main Components
• Editor Components: These include all the build pipeline scripts, inspectors, and configuration tools found under Assets/Plugins/VoxelBusters/PermissionsKit/Editor. The Editor scripts are responsible for integrating with Unity’s build pipeline (e.g., modifying AndroidManifest.xml, Info.plist updates for iOS) and providing configuration UI.
• Runtime Components: Under Assets/Plugins/VoxelBusters/PermissionsKit/Runtime, you have separate subdirectories like Android, iOS, and Core. These hold the core API, platform-specific implementations (native bridges, interface definitions), and the business logic to manage permissions once the game is running.
• Core API & Public Interface: The primary API (e.g., PermissionsKit.cs, PermissionsKitManager.cs, and wrapper interfaces) allows application code to request, verify, and check permissions. This layer abstracts away all platform differences.
• Native Modules: Inside the Plugins directories (both Android and iOS folders), you see native libraries (like AAR files for Android and header/source files for iOS) that the runtime components call into for native operations.
• Dependency Management: The ExternalDependencyManager in Assets provides integration to ensure that required external dependencies and configurations are correctly set up in the Unity project.
• Example/Demo: The Examples folder contains Scenes and Scripts demonstrating how to use the Permissions Kit, which is useful when illustrating how different modules interact.
• Configuration & Setup: Components found under the Setup and Simulator directories set initial configurations and simulate permission requests during development.
Relationships and Interactions
• Developer Code (in the owning Unity project) will call the unified Permissions Kit API (the Core/Runtime layer) to make permission requests.
• The Permissions Kit API then delegates calls to platform-specific implementations:
• For Android, via the Runtime/Android module and related Editor build pipeline scripts that update the Android manifest.
• For iOS, via the Runtime/iOS module and corresponding Editor scripts that modify Info.plist.
• The Editor tools (inside the Editor folder) ensure that, during builds, the necessary native settings and dependencies are correctly inserted.
• The dependency manager acts as a bridge between the plugin and any external libraries necessary for proper functioning.
Architectural Patterns and Design Principles
• Separation of Concerns: The project is clearly divided between Editor-time configuration and Runtime functionality.
• Abstracted Platform Layer: A unified API abstracts the differences between Android and iOS permission systems.
• Modular Design: Components like build pipeline processors, native bridges, and settings managers are broken into separate modules, enabling easier maintenance and potential extension.
• Automated Configuration: Through Editor scripts and dependency managers, the plugin automates many setup tasks for developers.
Relevant Technologies and Frameworks
• Unity C# Scripting and Assembly Definition Files (.asmdef) for managing modules.
• Platform-specific build scripts for Android (Gradle, manifest generators) and iOS (Info.plist updaters via build pipeline scripts).
• Native libraries for Android (.aar files) and iOS (Objective-C/C++ header and implementation files).