Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

It is not necessary to use the SUGARManager to control UI, this is to help your custom UI work with the existing UI templates. If you intend to use only your own UI, then yes, it is perfectly fine to not use the manager, just use SUGARManager.Client in your code to use SUGAR features. This will help to manage requests and callbacks

Thanks

Nice! Hopefully, I'll be able to customize the UIs.

However, now that I'm directly trying to instantiate the SUGARClient, I'm getting some errors in the following (simple) code:

        _sugarClient = new SUGARClient("http://gamejam.sugarengine.org/");
        GameClient gc = _sugarClient.Game;
        var game = gc.Get();

If I execute the code above, I'll get an error on the third line, when calling gc.Get(). The log I get is:


I'm not able to get any usefull information from that Log. Do you have any idea of what is going on? 

Thanks in advance.

(2 edits)

Are you using the SUGAR prefab in your scene, regardless of if you intend to use the default UI or not, this will make integration simpler and will allow you to use the SUGARManager.Client for API calls, make sure that you are logged in before making calls to the API.

To give an example of how you would do this, see below:

SUGARManager.Client.Session.LoginAsync(Id, new AccountRequest { Name = "[x]", Password = "[y]", SourceToken = "SUGAR" },
success => {
var example = SUGARManager.Client.Game.Get().First();
Debug.Log(example.Name);
}, exception => {
Debug.LogError(exception);
});

where Id is known from the admin panel, x and y are the login details provided.

In the Success callback we are just checking a game is returned in Game.Get(), this code is merely an example and probably not be very useful :)

If you want to use SUGARClient directly, it may be wise to host your own version of SUGAR locally so that you can debug it easily. We have provided details of how to setup its docker container here

Thanks

Hello again,
Thank you very much.  I missed the login part, namely in the same example you gave. I thought to retrieve details about the game, such as the game's id, a login wasn't necessary.
Still, I don't think I'm going to host my server. The one you provided for the game jam suits my needs.
Thanks again!

Hi ratuspro,

Just to reiterate some of the getting started with SUGAR steps (to make sure its clear), you should know the game token (name of the game) and id, through the game creation in the admin panel. This information is then set in the SUGAR prefab, to be used for API calls, you should not have to retrieve these through code. See Getting Started  (see step 4. Configure It!)

Thanks