Skip to content

rixment/awu-plugin

Repository files navigation

Android Wrapper for Unity (awu)

This is an Android's library that is designed to be used as a plugin within Unity's project. It is created using Android Studio 3.6 and should consist of all projects files required by the IDE if one desires to tweak its functionality to his or hers needs.

The main purpose of this library is to allow the user to retreive platform related information within Unity's project and currently includes:

  • retreiving information regarding the state of the network via isNetworkAvailable
  • determining established connection type via IsConnectedViaCellular and IsConnectedViaWifi
  • determining if a device on which the app is running is of Tv-type via isAndroidTv
  • text based message sharing with the use of Android's Intent mechanism via shareText

How to integrate

  1. Clone awu repository and build the library using Android Studio yourself or download the latest .aar library release from here

  2. Copy the .aar library file into your Unity's project Assets/Plugins/Android directory

  3. (Optional) In Unity select the .aar library file from Project window and mark the option Load on startup from the Inspector

  1. Copy Unity's C# implementation available from here into your Assets/Scripts

Usage

Upon finishing the integration process described above you should be able to take advantage of library's functionality.
In your C# Unity's code you can use it in the following way:

bool isConnected = Awu.IsNetworkAvailable; // Let's check if we're connected to the internet

bool isTv = Awu.IsAndroidTv; // Let's check if the game is running on Android TV enabled device

bool isCellular = Awu.IsConnectedViaCellular; // Is mobile data connection established

bool isWifi = Awu.IsConnectedViaWifi; // Is wifi connection established

// Let's share our game with a friend via text message
Awu.ShareText("Share via", "My Awesome Game", new System.Uri("http://my.awesomegame.com"));

Proguard

Projects utilising proguard obfuscation process should keep -keep class rixment.awu.** { *; } within its proguard definition file.

Copyright and License

Copyright 2005-2020 Rixment. Code released under the MIT license.