Unity Example

We have created a public repository that contains a demo integration of the Triumph SDK in a template game.

If you wish to run this demo, be sure to include the following scenes in your build:

The Triumph methods are called in MainMenuUIManager and GameUIManager, with the code that would go in their place contained in a block comment to their left:

using TriumphSDK;

public class MainMenuUIManager : MonoBehaviour
{
    [SerializeField] Button startGameButton;

    void Start()
    {
        // instead of starting the game, the button will now launch the Triumph SDK
        startGameButton.onClick.AddListener(() => /* StartGame() */ Triumph.PresentTriumphViewController());
    }

    // to run the integration, the logic for this method should be moved to TriumphUnityNativeMethods.TriumphGameDidStart()
    private void StartGame()
    {
        SceneManager.LoadScene("Game");
    }
}

Note that when playing the game, you are presented with two buttons, one labeled "Update Score" and one labeled "Report Score". The former increases the score by a random amount, and the latter completes the current game and reports the final score to the Triumph SDK, which will open the Triumph window.

Last updated