Unity
This article will walk you through installing the Skillz SDK in your Unity project.
1. Download Skillz SDKβ
The latest version of the Skillz SDK for Unity can be found at the Downloads section of the Skillz Developer Console.
Decompress the file after it has finished downloading. Everything will be decompressed into a folder named sdk_unity_<SDK_VERSION>
. Relative to that folder will be /unity/skillz_unity-<SDK_VERSION>.unitypackage
where SDK_VERSION
is the version of the Skillz SDK that was downloaded.
2. Import Unity Packageβ
With your project open in Unity, click the Assets > Import Package > Custom Package...
menu item. Select the skillz_unity-<SDK_VERSION>.unitypackage
file from the previous step.
A dialog will pop up where you can choose the assets from the package to import. Click the All
button to select all. Next, click the Import
button.
Overwrite Android Build Filesβ
A dialog will pop up asking permission to overwrite Android build files. Select Yes
.
Enable Android Auto-Resolutionβ
A dialog may pop up asking to enable Android Auto-Resolution. If prompted, click Enable
. Enabling this feature is also done in a later step, so it is not critical at this point.
Disable Registry Additionβ
Skillz bundles a plugin by Google called the External Dependency Manager (EDM), which is used to resolve Android dependencies. On import of the Skillz SDK, EDM will display a dialog, similar to the screenshot below, to ask if you would like to add additional Unity Package Manager registries. Click the Disable Registry Addition
button to dismiss the dialog.
The Skillz SDK is now installed in your Unity project. You should see an Assets/Skillz/
folder in your project tab.
3. Resolve Dependenciesβ
- iOS
- Android
Configure External Dependency Managerβ
Skillz for Unity is bundled with the External Dependency Manager plugin. This plugin will resolve transitive dependencies between multiple libraries for iOS. Preliminary configuration is needed:
- Select the
Assets > External Dependency Manager > iOS Resolver > Settings
menu item. - Click the
Reset to Defaults
button as a precaution. - Click the
OK
button to save your changes.
Install CocoaPodsβ
The External Dependency Manager can install CocoaPods for you, if it is not already installed:
- Select
Assets > External Dependency Manager > iOS Resolver > Install Cocoapods
- Click
OK
in the pop-up confirming installation was successful.
Configure External Dependency Managerβ
Skillz for Unity is bundled with the External Dependency Manager plugin. This plugin will resolve transitive dependencies between multiple libraries (that support it) for Android, such as Skillz and Firebase. However, preliminary configuration is needed:
- Select the
Assets > External Dependency Manager > Android Resolver > Settings
menu item. - Click the
Reset to Defaults
button as a precaution. - Uncheck the
Enable Auto-Resolution
option. - Make sure the "Patch mainTemplate.gradle" option is checked.
- By selecting this option, the External Dependency Manager will modify
Assets/Plugins/Android/mainTemplate.gradle
with the list of resolved of resolved dependencies. - The final
build.gradle
file in an exported Android Studio project will list these dependencies. - This approach is recommended by Google. Otherwise, the plugin will download the resolved dependencies as JARs/AARs.
- By selecting this option, the External Dependency Manager will modify
- Check the
Use Jetifier
option. Skillz requires the new AndroidX Support Libraries, instead of the original Android Support Libraries. Checking the Jetifier option ensures that all libraries that depend on the original Android Support Libraries are migrated to the equivalent AndroidX ones. - Click the
OK
button to save your changes.
Resolve Android Dependenciesβ
With the External Dependency Manager configured, it's time to resolve your Unity project's Android dependencies. Select Assets > External Dependency Manager > Android Resolver > Resolve
. A message box will display after resolution has completed.
Afterwards, verify that mainTemplate.gradle
was modified to ensure that all resolved dependencies are listed.
The dependencies section should look similar to this snippet before modification:
dependencies {
implementation ("com.skillz.sdk:skillz-sdk-android:<sdk_version_string>")
{
transitive = false
}
**DEPS**
}
And it should look similar to this snippet after modification:
dependencies {
implementation ("com.skillz.sdk:skillz-sdk-android:<sdk_version_string>")
{
transitive = false
}
// Android Resolver Dependencies Start
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.airbnb.android:lottie-react-native-skillz:2.6.2'
// Etc...
If the file did not appear to be changed, you may have to save your project, reopen it, and select the Assets > External Dependency Manager > Android Resolver > Force Resolve
menu item.
4. Configure Game for Skillzβ
Select the Skillz > Settings
menu item to bring up the Skillz Settings window:
Set your Game ID
, the environment (Sandbox
or Production
), and the orientation for your game.
Select environment Sandbox
for development and testing. Come back here and switch to Production
when readying the build for publishing to the app stores.
Please ensure to select the correct orientation if you plan to distribute your game on Android. This setting is important for ensuring your game renders in the correct orientation for gameplay. For instance, if the scene for your main menu is designed for Portrait mode, but your game scene is designed for Landscape, the orientation setting should be set to Landscape.
Additionally, you can choose if users are allowed to exit the Skillz UI via its sidebar menu.
5. Build and Runβ
Unity Player Configurationβ
- iOS
- Android
Optimal Resolution Scalingβ
- In Unity select
File > Build Settings...
- In the lower left click
Player Settings...
- Select
Player
from the sidebar and click on theiOS
tab. - Under
Settings for iOS
, expandResolution and Presentation
:- Select
Resolution Scaling Mode: Fixed DPI
- Set
Target DPI
to328
- Select
5. Close the window. It will automatically save your new settings
Metal Write-Only Backbufferβ
- In Unity select
File > Build Settings...
- In the lower left click
Player Settings...
- Select
Player
from the sidebar and click on theiOS
tab. - Under
Settings for iOS
, expandOther Settings
:- Deselect
Metal Write-Only Backbuffer
- Deselect
5. Close the window. It will automatically save your new settings
Disallow Downloads over HTTPβ
- In Unity select
File > Build Settings...
- In the lower left click
Player Settings...
- Select
Player
from the sidebar and click on theiOS
tab. - Under
Settings for iOS
, expandOther Settings
:- Deselect
Allow downloads over HTTP (nonsecure)
- Deselect
5. Close the window. It will automatically save your new settings
Optimal Resolution Scalingβ
- In Unity select
File > Build Settings...
- In the lower left click
Player Settings...
- Select
Player
from the sidebar and click on theAndroid
tab. - Under
Settings for Android
, expandResolution and Presentation
:- Select
Resolution Scaling Mode: Fixed DPI
- Set
Target DPI
to328
- Select
5. Close the window. It will automatically save your new settings
Verify Target Architecturesβ
- In Unity select
File > Build Settings...
- If Platform selection is not
Android
, selectAndroid
and clickSwitch Platform
- Check
Export Project
if you would like to generate an Android Studio project versus Android App Bundle or APK - In the lower left click
Player Settings...
- Select
Player
from the left navigation and expandOther Settings
:- Select
Scripting Backend: IL2CPP
- Under
Target Architectures
checkARMv7
andARM64
to ensure support for 32-bit and 64-bit Android devices
- Select
6. Close the window. It will automatically save your new settings
Initiate Buildβ
- iOS
- Android
Click Build to initiate the build process. Unity will prompt for a destination to save the XCode project. When complete, the project can be opened by double-clicking the *.xcworkspace
file. Do not open the project using the *.xcodeproj
file, as it will not properly initialize the CocoaPod dependencies.
Set the App Orientationβ
After the successful creation of the Xcode project, open the project. In {Project}/Classes/
, locate and open UnityAppController.mm
. Find the method called application:supportedInterfaceOrientationsForWindow
. Currently, this method's body looks similar to:
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
if ([window rootViewController] == nil)
return UIInterfaceOrientationMaskAll;
return [[window rootViewController] supportedInterfaceOrientations] | _forceInterfaceOrientationMask;
}
Since Skillz doesnβt support switching orientations between portrait and landscape, youβll need to modify this function to support only either portrait or landscape:
- Portrait
- Landscape
return (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationPortraitUpsideDown);
return (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationLandscapeLeft);
Click Export to initiate the build process. Unity will prompt for a destination to save the Android Studio project.
It is suggested to build and run the project on the target platforms to resolve any conflicts or issues prior to further Skillz implementation. Once the project has been tested, please move on to implementing the Skillz UI.
Firebaseβ
If you plan on adding Firebase to your Unity project, we recommend you use Unity Firebase 8.9.0, as it has been tested with the Skillz SDK.