Combu 2.0 is in Release Candidate stage and currently under our testing review process. The 2nd generation of Combu features a complete refactoring of the Unity classes and management, making it much easier to learn for both newbies and expert programmers thanks to the fact that it’s built on top of the Unity ISocialPlatform interface, so most of the current features will work the same or similar way of Unity Social.
First of all we organized all the core classes in our own namespace Combu, mainly for compatibility reasons (we found that some libraries also used “CBManager” class name in their assemblies, for example ChartBoost package).
You will find a new property Dont Destroy On Load of the component CombuManager (formerly known as CBManager) by default set to true, usually you will need only one instance of CombuManager along your app lifetime.
Under CombuManager you will find platform (CombuPlatform inherits from ISocialPlatform and also adds custom methods) and localUser (that is a shortcut to CombuManager.platform.localUser, our new User class inherits from Profile that implements IUserProfile).
Basically most of the documentation is the same/similar to the standard ISocialPlatform, except few custom features and methods overload. Let’s see few examples of the incoming changes.
Login example
Here is the new v2.x code to authenticate a user:
CombuManager.platform.Authenticate ( "username", "password",
(bool success, string error) => {
if (success)
{
Debug.Log(CombuManager.localUser.id);
}
else
{
Debug.LogError("Login failed: " + error);
}
});
Send score to leaderboard
Here is the new v2.x code to send a score to a leaderboard:
CombuManager.platform.ReportScore(100, leaderboardId,
(bool success) => {
if (success)
{
Debug.Log("Score registered");
}
else
{
Debug.LogError("Score failed to register");
}
});
Get online state of a user
With the new API you can now retrieve the UserState of a User by accessing the property state. You know that we’re working in an asynchronous system, so the user state (as all other data) is not automatically refreshed and you may want to check the state inside a callback to Load is you know the data were loaded too much time ago.
CombuManager has two new properties: onlineSeconds (compared to the last action time registered from the user) and playingSeconds (compared to understand if he’s playing, if you want to manage yourself the playing state then you can set this value to zero).
Get server version and time
We created a web service for convenience, it returns some generic data of the server like the Combu version installed, current date/time etc:
CombuManager.instance.GetServerInfo( (bool success, CombuServerInfo info) => {
if (success)
{
Debug.Log("VERSION: " + info.version + " | TIME: " + info.time.ToShortDateString() + " " + info.time.ToShortTimeString());
}
else
{
Debug.LogError("Score failed to register");
}
});
Conclusions
Lesser code easier to read and understand, isn’t it? 🙂
Of course, you can still pass void functions to the methods instead of the inline delegate syntax, it’s up to your coding style.
Other new features will be released when Combu 2.0 will be officially released, but we will talk later in the release notes!
For now you can take a look at the new documentation.