Open-sourced version of UniLWP.Droid, an Android live wallpaper solution for Unity 2019.3+

Overview

UniLWP.Droid (Free Version) UPM Package

openupm

UniLWP.Droid is an Android live wallpaper framework for Unity. With it, you can create Android Studio projects that compile to live wallpaper apps. This is the free version of it (full version on: Asset Store), which only contains necessary code for live wallpaper service itself. The demo app for UniLWP.Droid (full version) is also on Google Play.
For packaging purposes, the plugin is uploaded as an aar file. The java source can be found on the JavaSource repo.

Screenshots

Editor Activity Service

Requirements

  • Unity 2019.3+
  • Android API: 7.0 and up
  • Works best with OpenGL ES 3.0 (Vulkan is fine, but not that good)

Installation Guide

  • Add this line to your manifest.json
"dependencies": {
    "com.justzht.unilwp.droid.free": "https://github.com/JustinFincher/UniLWP.Droid.Package.Free.git" // this line
}
  • If you are not in Android target, switch to Android target now
  • Modify your build settings
    • Android API to 7.0 and up
    • Disable the Optimized Frame Pacing option
    • Disable Unity Audio (Optional)
    • Graphics API to OpenGL ES 3.0 (Optional)
  • Build an apk and install it to your Android device
  • Now you have one activity on your launcher, and one service if you open the live wallpaper picker

How does UniLWP.Droid work?

This section has a more detailed version on UniLWP.Droid Documentation, check it out if you want to know more.
The UnityPlayer java class has a constructor that accepts a Context instance to init the player itself. It also has a method for switching surfaces:

class UnityPlayer
{
    public UnityPlayer(Context var1) {}
    public boolean displayChanged(int var1, Surface var2) {}
}

As UnityPlayer does not enforce the activity check (it actually did for runOnUiThread reasons, but that is another story), we can pass an application context to the parameter and init a UnityPlayer.
This should be executed as soon as possible, so UniLWP.Droid introduced a ContentProvider subclass solely for early-init purposes.

For why ContentProvider is even inited earlier than the onCreate call in the Application class, please read a post on firebase blog.

Our ContentProvider subclass provides a universal application context that calls Unity at the beginning of the application lifecycle, so any Activity or Service inited after that are free of null reference exceptions.

Each Activity or WallpaperService references a Surface. On Activity, it is a SurfaceView, and on WallpaperService, it is a SurfaceHolder. UniLWP.Droid registers the callback of these surfaces and call displayChanged when a new surface is visible. This is how UniLWP.Droid switch the display target dynamically.

However, Unity's default activity implementation isn't designed for such usages. In order to bypass this, UniLWP provides an Activity class that replaces the default Activity in gradle compiling stages. The magic is in the merging process of AndroidManifest.xml files. For more you can read how to remove activity from manifest.

Feature Comparsion

This is the free & open-sourced version of UniLWP.Droid, and certain features are missing in order for you to buy the full version (obviously). For a comparsion between this free version and a paid version, see the table below:

UniLWP.Droid Free Paid
Live Wallpaper
One-click deploy
Callbacks (Offset, Lock Event, etc)
Touch Events
C# Post-build Scripts For Easy Update
Modular Customization (only if you read the code and extend it yourself)

Have Questions?

Open an issue or write an email to [email protected]

Apps Using UniLWP.Droid

You might also like...
ADB WIFI Android Studio plugin for debug android app over Wi-Fi.
ADB WIFI Android Studio plugin for debug android app over Wi-Fi.

ADB WIFI ADB WIFI Android Studio plugin for debug android app over Wi-Fi. How to install in Android Studio: go to Preferences

Android Studio plug-in for generating ButterKnife injections from selected layout XML.
Android Studio plug-in for generating ButterKnife injections from selected layout XML.

ButterKnifeZelezny Simple plug-in for Android Studio/IDEA that allows one-click creation of Butterknife view injections. How to install in Android Stu

GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.
GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.

Gradle Play Publisher Gradle Play Publisher is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and

IntelliJ Plugin for Android Parcelable boilerplate code generation.
IntelliJ Plugin for Android Parcelable boilerplate code generation.

IntelliJ/Android Studio Plugin for Android Parcelable boilerplate code generation This tool generates an Android Parcelable implementation based on fi

Android Studio plugin which automatically generates drawable selectors from appropriately named resources.
Android Studio plugin which automatically generates drawable selectors from appropriately named resources.

SelectorChapek for Android This Android Studio plugin automatically generates drawable selectors from appropriately named Android resources. How to in

Maven Plugin for Android Application development and more

ANDROID MAVEN PLUGIN A plugin for Android application development with Apache Maven 3.0.5+ and the Android SDK. Please check out our website for furth

 Gradle plugin which downloads and manages your Android SDK.
Gradle plugin which downloads and manages your Android SDK.

DEPRECATED This plugin is deprecated and is no longer being developed. Tools and dependencies are automatically downloaded using version 2.2.0 of the

A Gradle plugin to support the Groovy language for building Android apps

Groovy language support for Android Deprecated: This plugin has been deprecated in favor of Kotlin which has the full support of JetBrains and Google.

Add a different ribbon to each of your Android app variants using this gradle plugin. Of course, configure it as you will

Easylauncher gradle plugin for Android Modify the launcher icon of each of your app-variants using simple gradle rules. Add ribbons of any color, over

Comments
  • Version control

    Version control

    HI @JustinFincher,

    Thanks for making the great upm package free. I'm the creator of OpenUPM platform, an open-source UPM registry, and continuous build service based on Git tags. So far it is hosting more than 200+ UPM packages.

    To make it happens, I would suggest you make GitHub releases (which create Git tags) for version control. It can be achieved either manually or using an automatic approach.

    Then you can submit your package here: https://openupm.com/packages/add/

    opened by favoyang 2
  • Wallpaper not appearing on lock screen.

    Wallpaper not appearing on lock screen.

    Hi @JustinFincher thanks for creating this!

    Before buying the asset store version I decided to try the demo APK. It's working great with one exception that the wallpaper is not being set as my lock screen wallpaper.

    Is this a limitation by design?

    Thanks

    opened by adrenak 4
Owner
JustZht
a.k.a Haotian Zheng. Indie Mobile & Game Dev, WWDC 18/20 Scholar, CMU INI MSMITE 2022'
JustZht
Gradle plugin to use git tags as project version names

Version Name Gradle Plugin This plugin adds a kotlin extension function that provides a version name based on the latest git tag. How to use it ?? App

Doist 3 Mar 9, 2022
Kirill Rakhman 4 Sep 15, 2022
OTH themes for JetBrains. Dark and light themes using Open Template Hub's color palette.

Open Template Hub - IntelliJ Platform Theme v1 OTH themes for JetBrains. Dark and light themes using Open Template Hub's color palette. After installi

Open Template Hub 5 Dec 18, 2022
OTH themes for JetBrains. Dark and light themes using Open Template Hub's color palette.

Open Template Hub - IntelliJ Theme Plugin v1 OTH themes for JetBrains. Dark and light themes using Open Template Hub's color palette. After installing

Open Template Hub 2 Apr 21, 2022
Plugin for the JetBrains Platform, that makes it easier to work while many splits are open by resizing the active editor to be larger

Plugin for the JetBrains Platform, that makes it easier to work while many splits are open by resizing the active editor to be larger. Golden Ratio is inspired by the Emacs and Vim plugins of the same name by Roman Gonzalez.

Chris Cunningham 1 Jun 18, 2022
A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development.

ADB Idea A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development. The following commands are provided: Uninst

Philippe Breault 2k Dec 28, 2022
IntelliJ / Android Studio plugin for Android Holo Colors

This project is not maintained anymore. Holo Colors doesn't make sense since the introduction of Material Design and the ability to set the primary co

Jérôme Van Der Linden 644 Nov 10, 2022
gradle-android-scala-plugin adds scala language support to official gradle android plugin

gradle-android-scala-plugin gradle-android-scala-plugin adds scala language support to official gradle android plugin. See also sample projects at htt

saturday06 345 Dec 10, 2022
[Deprecated] Android Studio IDE support for Android gradle unit tests. Prepared for Robolectric.

#[Deprecated] Google has finally released a proper solution for unit testing. Therefore this plugin will no longer be activlty maintained. android-stu

Evan Tatarka 236 Dec 30, 2022