Launch the Skillz UI
Overview​
Once the Skillz SDK is added to your project (Link to Install SDK page), it is time to start setting up the core of your game loop, launching the Skillz UI. Standard user flow is App Launch -> Landing Page -> Launching the Skillz UI and from within the UI your players will have a variety of different interface to interact with. To understand more about the Skillz UI, please refer to this documentation.
The below steps will walk you through setting up some core elements of the Skillz SDK, helping you to accomplish your first steps of your Skillz integration.
Important Note for Unity Integrations​
To better understand how the Skillz SDK works with Unity please refer to our guidance on Unity Script Execution
Implement the SkillzManager or SkillzDelegate​
Control of your application is given to Skillz when you launch the Skillz UI. Because of this, you'll need to add the Skillz Manager
(Unity) or implement the Skillz Delegate interface (Other), which contains callbacks that will be invoked for key events. There are three events that are essential for interacting with Skillz:
- When a match is starting.
- When the user is exiting the Skillz UI (via the sidebar menu).
- When trying to enter the Progression Room
- Unity/C#
- Legacy Unity/C#
- iOS/Swift
- iOS/Objective-C
- Android
First, a Skillz Manager
needs to be added to your start menu scene.
Right click in the
Heirarchy
and selectCreate Empty
. In the inspector, clickAdd Component
then add theSkillz Manager
component.Open the Skillz Manager in the Inspector.
Choose a
Game Scene
,Start Menu Scene
, and optionally aProgression Room Scene
for the scene fields.
NOTE: If your project does not use multiple scenes, or scenes need to be loaded manually, the scene fields can be left blank. The logic for these events can then be included in the extra logic script (see below).
NOTE: If your project uses unsupported Unity version 2019 or lower the Skillz Manager
will not display correctly. Solution Here.
- For additional logic you may add a script to the
Skillz Manager
by selectingAdd Component
in the inspector, then selecting a custom script. The script must be on the same gameObject as theSkillz Manager
.
Methods from this script can then be called by pressing the +
button under the On Match Will Begin
, On Skillz Will Exit
, and On Progression Room Enter
, then selecting public methods from the added script.
An example extra logic script:
// ...
public class SkillzExampleManagerLogic : MonoBehaviour
{
public void OnMatchWillBeginLogic(SkillzSDK.Match match)
{
Debug.Log("Loading Game Scene");
}
public void OnSkillzWillExitLogic()
{
Debug.Log("Loading Start Menu Scene");
}
public void OnProgressionRoomEnterLogic()
{
Debug.Log("Loading Progression Room Scene");
}
}
// ...
For Unity, you need to implement the SkillzMatchDelegate
interface as a regular C# class. This will be instantiated when launching Skillz later.
using SkillzSDK;
public sealed class SkillzGameController : SkillzMatchDelegate
{
// Called when a player chooses a tournament and the match countdown expires
public void OnMatchWillBegin(Match matchInfo) {
}
// Called when a player clicks the Progression entry point or side menu. Explained in later steps
public void OnProgressionRoomEnter() {
}
// Called when a player chooses Exit Skillz from the side menu
public void OnSkillzWillExit() {
}
}
Full implementation of these methods is covered later
For iOS, the Skillz Delegate is available as a protocol named SkillzDelegate
. It is common to conform to this protocol in the interface that conforms to UIApplicationDelegate
.
#import <UIKit/UIKit.h>
#import <Skillz/Skillz.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, SkillzDelegate>
@end
#import "AppDelegate.h"
#import <Skillz/SkillzInstance.h>
@implementation AppDelegate
// Called when a player chooses a tournament and the match countdown expires
- (void)tournamentWillBegin:(NSDictionary *)gameParameters
withMatchInfo:(SKZMatchInfo *)matchInfo {
}
// Called when a player clicks the Progression entry point or side menu. Explained in later steps
- (void)onProgressionRoomEnter {
}
// Called when a player chooses Exit Skillz from the side menu
- (void)skillzWillExit {
}
@end
Full implementation of these methods is covered later
For iOS, the Skillz Delegate is available as an interface named SkillzDelegate
. It is common to adhere to this in the class that adheres to UIApplicationDelegate
.
import UIKit
import Skillz
@UIApplicationMain
class AppDelegate : UIResponder, UIApplicationDelegate, SkillzDelegate {
var window: UIWindow?
// Called when a player chooses a tournament and the match countdown expires
func tournamentWillBegin(_ gameParameters: [AnyHashable : Any], with matchInfo: SKZMatchInfo) {
}
// Called when a player clicks the Progression entry point or side menu. Explained in later steps
func onProgressionRoomEnter() {
}
// Called when a player chooses Exit Skillz from the side menu
func skillzWillExit() {
}
}
Full implementation of these methods is covered later
For Android, the Skillz Delegate takes the form of special <meta-data>
tags that are added inside the <application>
element of your app's AndroidManifest.xml
.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="<your_package_name>" xmlns:tools="http://schemas.android.com/tools">
<application>
<meta-data android:name="skillz_game_activity" android:value="<your_game_activity>" />
<meta-data android:name="skillz_exit_activity" android:value="<your_activity_on_skillz_exit>" />
</application>
</manifest>
The skillz_game_activity
tag tells the Skillz SDK which activity to launch when a match starts. skillz_exit_activity
tells the Skillz SDK which activity to launch if the user exits the Skillz UI.
Initialize Skillz​
Once you have at least stubbed in the delegate functions, you are not able to initialize Skillz. This is usually right after your game's process has finished launching or in your game's start screen (if there is one).
You must initialize Skillz before you can launch it.
- Unity/C#
- iOS/Swift
- iOS/Objective-C
- Android
#import <UIKit/UIKit.h>
#import <Skillz/Skillz.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, SkillzDelegate>
@end
#import "AppDelegate.h"
#import <Skillz/SkillzInstance.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
AppDelegate *delegate = self;
[[Skillz skillzInstance] initWithGameId:@"156"
forDelegate:delegate
withEnvironment:SkillzSandbox];
return YES;
}
@end
Here, we've initialized Skillz inside the application:didFinishLaunchingWithOptions
callback of UIApplicationDelegate. You must provide three arguments: your game's ID from the Developer Console, an instance of the SkillzDelegate
protocol, and which Skillz environment to run. Use SkillzSandbox
while developing your game, and SkillzProduction
when it's ready to go live on Skillz and the Apple App Store.
Note that the Skillz
protocol is a singleton. You should always invoke the methods from [Skillz skillzInstance]
.
import UIKit
import Skillz
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, SkillzDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Skillz.skillzInstance().initWithGameId("156", for: self, with: SkillzEnvironment.sandbox, allowExit: true)
return true
}
}
Here, we've initialized Skillz inside the application:didFinishLaunchingWithOptions
callback of UIApplicationDelegate. You must provide three arguments: your game's ID from the Developer Console, an instance of the SkillzDelegate
protocol, and which Skillz environment to run. Use SkillzEnvironment.sandbox
while developing your game, and SkillzEnvironment.production
when it's ready to go live on Skillz and the Apple App Store.
Note that the Skillz protocol is a singleton. You should always invoke the methods from Skillz.skillzInstance()
.
Initializing Skillz requires the following meta-data tags in your game's AndroidManifest.xml
file:
<meta-data android:name="skillz_game_id" android:value="156" />
<meta-data android:name="skillz_production" android:value="false" />
skillz_game_id
needs your game's ID from the Developer Console. Set skillz_production
to false
while developing your game; set it to true
when you are ready to go live on Skillz and the appropriate app store.
Skillz is initialized when your game starts up. Make sure you have configured your game appropriately.
Launch Skillz​
With Skillz initialized, you can now launch it to take over control of your interface. Typically, Skillz is launched from your game's start screen. Specifically, we recommend that your game's start screen has a button to launch Skillz when it is clicked. The examples below all follow that pattern.
- Unity/C#
- Legacy Unity/C#
- iOS/Swift
- iOS/Objective-C
- Android
#import <Skillz/Skillz.h>
// ...
-(void)launchSkillzButtonPressed:(id)sender {
[[Skillz skillzInstance] launchSkillz];
}
// ...
import Skillz
// ...
func launchSkillzButtonPressed(_ sender: Any?) {
Skillz.skillzInstance().launch()
}
// ///
import android.os.Bundle;
import com.skillz.Skillz;
import com.skillz.SkillzActivity;
public class TitleScreenActivity extends SkillzActivity {
public void TitleScreenActivity() {
mSkillzButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Skillz.launch(this);
}
}
}
}
public sealed class TitleScreenController : MonoBehaviour
{
public void PressPlayButton() {
SkillzCrossPlatform.LaunchSkillz();
}
}
Note: Skillz Unity Lifecycle​
The Skillz SDK does not change scenes. The Skillz Unity UI is a native iOS/Android Activity. So you'll only detect an OnApplicationPause when it loads or unloads.
To prevent problems with residual game-state, our suggestion is to create a simple "Loading" scene. Whenever you invoke either of the Skillz functions
SkillzCrossPlatform.LaunchSkillz()
, orSkillzCrossPlatform.ReportFinalScore(score)
- your code should also load your "Loading" scene viaSceneManager.LoadScene
. This will force your current scene to unload, so that way every match will start with totally fresh assets.If your game is not making use of loading separate scenes - then instead of calling
SceneManager.LoadScene
- your code is instead responsible for cleaning up all of the variables and game-state in the current scene.
public sealed class TitleScreenController : MonoBehaviour
{
public void PressPlayButton() {
SkillzCrossPlatform.LaunchSkillz(new SkillzGameController());
}
}
To launch Skillz, you must pass in an object that implements the Skillz Delegate.
Note: Skillz Unity Lifecycle​
The Skillz SDK does not change scenes. The Skillz Unity UI is a native iOS/Android Activity. So you'll only detect an OnApplicationPause when it loads or unloads.
To prevent problems with residual game-state, our suggestion is to create a simple "Loading" scene. Whenever you invoke either of the Skillz functions
SkillzCrossPlatform.LaunchSkillz(new SkillzGameController())
, orSkillzCrossPlatform.ReportFinalScore(score)
- your code should also load your "Loading" scene viaSceneManager.LoadScene
. This will force your current scene to unload, so that way every match will start with totally fresh assets.If your game is not making use of loading separate scenes - then instead of calling
SceneManager.LoadScene
- your code is instead responsible for cleaning up all of the variables and game-state in the current scene.
Exit Skillz​
Users can exit Skillz via a sidebar menu item. When this happens, a callback in your Skillz Manager
or Skillz Delegate implementation is invoked. You'll want to handle this callback to load an appropriate game screen. This typically will be the main menu/start screen.
- Unity/C#
- Legacy Unity/C#
- iOS/Swift
- iOS/Objective-C
- Android
#import <UIKit/UIKit.h>
#import <Skillz/Skillz.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate, SkillzDelegate>
@end
#import "AppDelegate.h"
#import <Skillz/SkillzInstance.h>
@implementation AppDelegate
- (void)skillzWillExit
{
// The user is exiting Skillz, load a view, such as the main menu.
}
@end
import UIKit
import Skillz
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, SkillzDelegate {
func skillzWillExit() {
// The user is exiting Skillz, load a view, such as the main menu.
}
}
Add these meta-data tags in your game's AndroidManifest.xml
file:
<meta-data android:name="skillz_allow_exit" android:value="false" />
<meta-data android:name="skillz_exit_activity" android:value="<fully_qualified_activity_name>" />
Set skillz_allow_exit
to false
to disable users from exiting Skillz. If set to true
, set the skillz_exit_activity
with the fully qualified name of an activity to load when Skillz exits. This is commonly your game's main menu/start screen.
Set the Start Menu Scene
in the Skillz Manager
.
// ...
public void OnSkillzWillExit() {
SceneManager.LoadScene("StartMenu");
}
// ...
Test​
The completed Skillz Manager
(Unity) or Skillz Delegate (Other) should resemble this:
- Unity/C#
- Legacy Unity/C#
- iOS/Swift
- iOS/Objective-C
- Android
SIDEkick​
If your game is made with Unity, you can simulate launching Skillz from the editor by using the Skillz SIDEkick before exporting and building for iOS or Android. If you are having issues, more insight can be gained by turning on debug logging in the Skillz settings.
using SkillzSDK;
using UnityEngine.SceneManagement;
public sealed class SkillzGameController : SkillzMatchDelegate
{
private const string GameScene = "Level1"; // Your game scene name
private const string ProgressionRoomScene = "ProgressionRoom"; // Your player progression room
private const string StartMenuScene = "StartMenu"; // Your menu scene exiting Skillz will return to (optional)
// Called when a player chooses a tournament and the match countdown expires
public void OnMatchWillBegin(Match matchInfo) {
// This is where you launch into your competitive gameplay
SceneManager.LoadScene(GameScene);
}
// Called when a player clicks the Progression entry point or side menu. Explained in later steps
public void OnProgressionRoomEnter() {
SceneManager.LoadScene(ProgressionRoomScene);
}
// Called when a player chooses Exit Skillz from the side menu
public void OnSkillzWillExit() {
SceneManager.LoadScene(StartMenuScene);
}
}
SIDEkick​
If your game is made with Unity, you can simulate launching Skillz from the editor by using the Skillz SIDEkick before exporting and building for iOS or Android. If you are having issues, more insight can be gained by turning on debug logging in the Skillz settings.
import UIKit
import Skillz
@UIApplicationMain
class AppDelegate : UIResponder, UIApplicationDelegate, SkillzDelegate {
var window: UIWindow?
// Called when a player chooses a tournament and the match countdown expires
func tournamentWillBegin(_ gameParameters: [AnyHashable : Any], with matchInfo: SKZMatchInfo) {
let viewController = self.window?.rootViewController as! M2ViewController
viewController.startNewGame()
}
// Called when a player clicks the Progression entry point or side menu. Explained in later steps
func onProgressionRoomEnter() {
let viewController = self.window?.rootViewController as! M2ViewController
viewController.showProgressionRoom()
}
// Called when a player chooses Exit Skillz from the side menu
func skillzWillExit() {
let viewController = self.window?.rootViewController as! M2ViewController
viewController.mainMenu()
}
}
#import "AppDelegate.h"
#import "MyViewController.h"
#import <Skillz/SkillzInstance.h>
@implementation AppDelegate
// Called when a player chooses a tournament and the match countdown expires
- (void)tournamentWillBegin:(NSDictionary *)gameParameters
withMatchInfo:(SKZMatchInfo *)matchInfo {
M2ViewController *viewController = (M2ViewController*)self.window.rootViewController;
[viewController startNewGame];
}
// Called when a player clicks the Progression entry point or side menu. Explained in later steps
- (void)onProgressionRoomEnter {
M2ViewController *viewController = (M2ViewController*)self.window.rootViewController;
[viewController showProgressionRoom];
}
// Called when a player chooses Exit Skillz from the side menu
- (void)skillzWillExit {
M2ViewController *viewController = (M2ViewController*)self.window.rootViewController;
[viewController mainMenu];
}
@end
<application>
<meta-data android:name="skillz_game_id" android:value="12345" />
<meta-data android:name="skillz_production" android:value="false" />
<meta-data android:name="skillz_game_activity" android:value="com.skillzinc.matchplay" />
<meta-data android:name="skillz_allow_exit" android:value="true" />
<meta-data android:name="skillz_exit_activity" android:value="com.skillzinc.mainmenu" />
<meta-data android:name="skillz_progression_activity" android:value="com.skillzinc.progressionroom" />
</application>
You should now be able to launch the Skillz UI from your game. You can build your game and verify that Skillz can launch from a mobile device in order to get your first checkmark in the Developer Console.
Next Steps​
In this article, you learned how to launch the Skillz UI from your game. The next article will describe how to start matches.