Introduction

The Inbox System helps you create a mail/notification system similar to famous simulation games. It is simple to use and easy to adapt to your game and design. In this documentation, we will present all important details you need to know about the Inbox System.

Contact

After reading this documentation and you persist with any doubts, you should contact us. For suggestions, implementation of new features or if you want to report a bug, please send us an email at contact@mekanysmos.com.

Future Updates

You can expect from MekanYsmos Games that we will continue working on this asset to provide you the best possible version of Inbox System.

Dependencies

Inbox System depends on TextMeshPro to generate its text content, so after importing the package, a window will appear asking you to import TMP Essentials to your project. You need to import, otherwise all text from the demo scenes won't appear.

How to Use

The purpose of the system is to send messages from the game to the player. Just like an email system, you can have many email categories as you want to group similar messages. Without further ado, let's dive in the package explanation.

Demo Scenes

The idea behind Inbox System is simple. When you click a button in the left sidebar, the respective category page of that button is active, while the others stay inactive. In the figure below, the top buttons activate the pages in the bottom, e.g., Social - Button opens Social page and closes other pages.

Note

The buttons and pages in hierarchy only appear in Play mode, because they are created dinamically based on the MailCategoryEnum.cs script.

Buttons and pages selected in Unity Hierarchy. Buttons and pages selected in Unity Hierarchy.

With exception to Generate Mail Notification script, you must have the following scripts attached to the Main Camera: Notification Controller, Mail Controller and Page Controller. The scripts in the inspector can be seen in the figure below.

Scripts in inspector.

Scripts

A general view on the scripts of the Inbox System can be seen in the figure below. The scripts of this package can be divided in three categories: essential, auxiliary and expansion base.

In sum, essential files are the ones that Inbox System can't run without. At this moment, they are all MonoBehaviour scripts attached to the Main Camera. Their task is to connect GameObjects from the scene with the script.

Auxiliary files will rarely be changed by you. They serve as the basis for other scripts, such as the case of interfaces like IMail and MailSender.

Finally, expansion base ones will serve as examples for you to adapt and create new files for your own game.

Tip

In each category you can have multiple mail examples, in order for it to adapt to your game. Let's say you want to have a Social category that receives messages from 3 different newspapers or social medias. You would need to have 3 files for that category, e.g., NewspaperOneMail, NewspaperTwoMail and NewspaperThreeMail. They all would be part of the Social category.

Altough GenerateMailNotification.cs script was marked as auxiliary, its objective is to help send mail and notification to the demo scenes for demonstration purposes only. In your own game, the mail sending logic will vary, but the methods necessary to send them are shown in this test script.

Directory tree of the scripts of Inbox System.

Adapting to Your Game

Warning

First of all, you need to modify the MailCategoryEnum script and add the categories you are working with. These will be the categories that will be visible inside your game in the inbox menu.

In order to adapt the package to your game, you need to modify scripts from the Mail/Category folder.

Let's take for example the SocialExampleMail.cs, which is inside Mail/Category. It presents the following properties:

  • PartialTitle:Partial part of the title that will be visible in the inbox.
  • PartialText:Partial part of the text that will be visible in the inbox.
  • Title:Complete title of the mail.
  • Text:Complete text of the mail.

The variable randomVariableInt (also present in the script) represents a parameter that will be part of the mail. Let's say that you want to create a mail that always informs the user about a new football player available in the market. You would need to add variables like playerName, playerAge or maybe an object player of type Player inside the four string properties mentioned above with some related text in the CreateStructure method.

public string playerName;
public string playerCurrentTeam;
public int playerAge;

public void CreateStructure(){
    //ID assignment
    //MailcategoryEnum assignment

    PartialTitle = playerName + " is available in the market";
    PartialText = "Our scouts just found out that " + playerName + " (" + playerAge.ToString() + " years old)" + 
                  "wants to be transferred to another team this season.";
    
    Title = playerName + " is available in the market and is looking for another team";
    Text = "Our scouts just found out that " + playerName + " (" + playerAge.ToString() + " years old) wants to" + 
           "be transferred to another team this season. He is not satisfied with his current position in " + 
           playerCurrentTeam + " and wants more chances to play. We can make an offer right now. What do yout think?";
}

Now that you know how to structure a Mail, we will show you how to send it. You just need to create a new object of type SocialExampleMail and assign values for the variables you created (as shown in the code below). As in this example there was only one, we assigned a random value to it. In each mail there is also a Notification property that is responsible for sending notifications. But this depends if you want to send them or not. In this example, we gave a 30% chance to send notifications of SocialExampleMail. You can put another condition or allow all notifications from this mail type. You can also cancel notification by change the parameter to false. If we used the football player example, we would need to assign here the variables playerName, playerAge and playerCurrentTeam.

SocialExampleMail dae = new SocialExampleMail();
dae.randomVariableInt = Random.Range(10, 1000);
if (Random.Range(1, 10) >4 && !NotificationController.disableNotificationPage) {
    dae.Notification = new Notification(true);
}

If you don't wish to see notifications at all in your game, you can disable them in the Notification Controller component in the main camera.