Getting Started

Structure

READYgg SDK is divided into multiple modules. Every module has its own functionality. All modules depend on the RGNCore module. In the current version, the modules are distributed by using packages for Unity Package Manager.

Obligatory modules/packages

  • RGNCore

  • RGNImplFirebase

  • RGNSignInEmail

  • RGNSignInGuest

We plan to add more tests in the future to identify the minimum set of modules that may be integrated, however at this time, we do extensive testing only for the complete list of modules and Firebase dependencies. For now, having the complete list of modules installed into your project is recommended.

READYgg Unity Initializer

We created an initialization script to automatically setup every module. This script can manage automatically the guest signIn and the modules initialization. To use it, simply create an empty GameObject in your starting scene and attach RGNUnityInitilizer.cs to it. With this script, you don't need to manually build the RGNCore and modules.

Access modules

In the recent versions of READYgg SDK, we added a new way to access the module's functionality.

To access modules you can use the "I" instance provider property:

var result = await [module_name].I.GetSomeResultAsync();

For example:

var purchaseResult = await StoreModule.I.BuyVirtualItemsAsync(itemIds);

Important!

If you are not using the RGNUnityInitializer, you will need to do the following :

The module is initialized during the first invocation of the "I" instance provider property. There is some initialization code in the SignIn modules. If you want to initialize the modules in advance, you can add:

RGNCoreBuilder.AddModule(new [module_name]());

code before calling the RGNCoreBuilder.BuildAsync() method.

Modules namespaces

The modules are located in the RGN.Modules.[module_name] namespaces. Here you can find a full list of modules with the namespaces:

Modules List

RGN.Modules.Achievement.AchievementsModule

RGN.Modules.Currency.CurrencyModule

RGN.Modules.GameProgress.GameProgressModule

RGN.Modules.Inventory.InventoryModule

RGN.Modules.Messaging.MessagingModule

RGN.Modules.Store.StoreModule

RGN.Modules.UserProfile.UserProfileModule

RGN.Modules.VirtualItems.VirtualItemsModule

RGN.Modules.Wallets.WalletsModule

RGN.Modules.SignIn.EmailSignInModule

RGN.Modules.SignIn.GuestSignInModule

You can use ready to use monobeh to initialize RGNCore. It is located in the GetReady.RGN.Impl.Firebase.Runtime assembly in RGN.Impl.Firebase namespace. The name of the class is "RGNUnityInitializer". Simply add it to the scene, the RGNCore will be initialized then in the Awake() method.

In case you want to initialize READYgg SDK yourself, then you need to make this call once when the app starts:

using RGN;
using UnityEngine;

namespace Ready.Documentation.Snippets
{
    public class InitializeSDKExample : MonoBehaviour
    {
        public async System.Threading.Tasks.Task InitializeRGNAsync()
        {
            var rgnCore = await RGN.RGNCoreBuilder.CreateAndBuildAsync(
                new RGN.Impl.Firebase.Dependencies(),
                OnAuthenticationChanged);
        }
        private void OnAuthenticationChanged(AuthState authState)
        {
            if (authState.LoginState == RGN.EnumLoginState.NotLoggedIn)
            {
                Debug.Log("Automatically logging in as a guest");
                RGN.Modules.SignIn.GuestSignInModule.I.TryToSignInAsync();
            }
        }
    }
}

When you access the module by using the I for the first time it is initialized and registered in the RGNCore. In case you want to initialize all modules in advance, you can use following snippet:

using System;
using UnityEngine;

namespace Ready.Documentation.Snippets
{
    public class InitializeAllModulesExample : MonoBehaviour
    {
        private async void Start()
        {
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.SignIn.EmailSignInModule());
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.SignIn.GuestSignInModule());
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.UserProfile.UserProfileModule());
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.Currency.CurrencyModule());
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.GameProgress.GameProgressModule());
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.Inventory.InventoryModule());
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.Store.StoreModule());
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.VirtualItems.VirtualItemsModule());
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.Creator.CreatorModule());
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.Achievement.AchievementsModule());
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.Wallets.WalletsModule());
            RGN.RGNCoreBuilder.AddModule(new RGN.Modules.Messaging.MessagingModule());

            var rgnCore = await RGN.RGNCoreBuilder.CreateAndBuildAsync(
                    new RGN.Impl.Firebase.Dependencies(),
                    OnAuthenticationChanged);
        }
        private void OnAuthenticationChanged(RGN.AuthState authState) => throw new NotImplementedException();
    }
}

Disposing and cleaning out

When the application is exiting, or you want to initialize a new instance of RGNCore SDK, you need to call the Dispose() method first:

// Monobehaviour Unity class
private void OnApplicationQuit()
{
    RGN.RGNCoreBuilder.Dispose();
}

Last updated