Skip to content

Getting Started

Adrian Rutkowski edited this page Mar 10, 2023 · 4 revisions

Getting Started'

To use the Joystick Unity package, you need to follow the below steps:

  1. Import the Joystick Unity package into your Unity project.
  2. After importing the package, you can access the Joystick class by using the following namespace: JoystickRemote.
  3. The Joystick class contains the following static methods:
  4. FetchConfigContent(RequestContentConfig definition, Action<bool, string> callback, bool getFreshContent = false)
  5. FetchConfigContent(List configList, Action<bool, string> callback, ExtendedRequestData extendedRequestData = null, bool getFreshContent = false)
  6. FetchCatalogContent(Action<bool, string> callback, bool getFreshContent = false)
  7. To fetch content, call the FetchConfigContent method, passing in the RequestContentConfig or List of ContentConfigData and the callback method. You can also set a boolean value to force updating the content when requesting.
  8. To fetch the catalog content, call the FetchCatalogContent method, passing in the callback method. You can also set a boolean value to force updating the content when requesting.

Example Usage:

Fetching Config Content using RequestContentConfig

using JoystickRemote;
using UnityEngine;

 
public class FetchContent : MonoBehaviour
{
    public RequestContentConfig configDefinition;
    private void Start()
    {
        Joystick.FetchConfigContent(configDefinition, OnContentFetchComplete);
    }

    private void OnContentFetchComplete(bool success, string response)
    {
        if (success)
        {
            Debug.Log("Content Fetch Successful: " + response);
        }
        else
        {
            Debug.LogError("Content Fetch Failed: " + response);
        }
    }
}

Fetching Config Content using List of ContentConfigData

using JoystickRemote;
using UnityEngine;

public class FetchContent : MonoBehaviour
{
    public List<ContentConfigData> configList;
    private void Start()
    {
        Joystick.FetchConfigContent(configList, OnContentFetchComplete);
    }

    private void OnContentFetchComplete(bool success, string response)
    {
        if (success)
        {
            Debug.Log("Content Fetch Successful: " + response);
        }
        else
        {
            Debug.LogError("Content Fetch Failed: " + response);
        }
    }
}

Fetching Catalog Content

using JoystickRemote;
using UnityEngine;

public class FetchContent : MonoBehaviour
{
    private void Start()
    {
        Joystick.FetchCatalogContent(OnCatalogFetchComplete);
    }

    private void OnCatalogFetchComplete(bool success, string response)
    {
        if (success)
        {
            Debug.Log("Catalog Fetch Successful: " + response);
        }
        else
        {
            Debug.LogError("Catalog Fetch Failed: " + response);
        }
    }
}

Note: To use the Joystick Unity package, you need to have a Joystick account and have configured the remote content on the Joystick server. Also, make sure to check the "Request Data at Start" option in the Joystick editor window to trigger the OnAutoStartFetchContentCompleted event when the data fetching is complete.

ToDo

Clone this wiki locally