Installation Guide

Prerequisite .NET 4.6

GameRules needs now Unity Editor to run with .NET 4.6 as required by MongoDB driver for cloud database. To setup it in Unity Editor, go to menu Edit > Project Settings > Player, and then choose:

  • Scripting Runtime Version = Experimental (.NET 4.6 Equivalent)
_images/dotnet46settings.png

Once modified, restart Unity Editor.

Unity Team Setting

If you intend to use Unity Team collaboration feature, then you have to exclude internal sqlite database files.

To do that, edit <Your project folder>/.collabignore file and append following lines:

# Game Rules rule repository database
# ===================================
*.sqlite
*.sqlite-journal

Cloud Database Setup

If you want to use Game Rules across different developers in your team, you have to setup a shared rule repository. Game Rules can connect to MongoDB, a no-sql database, which is available for free on the cloud as a database-as-a-service from MongoDB Atlas Cloud.

Sign-up at www.mongodb.com/cloud

Go to www.mongodb.com/cloud and click on Try Free to create an account, or login if you already have one.

_images/mongodbsignup.png

Database creation

Once logged-in, you will have to create a new cluster. Choose the provider and region where free tier is available, then click on Create Cluster.

_images/mongodbcreatenewcluster.png

Once your first cluster is created, a Connect to Atlas wizard is available at the bottom right. Click on Create your first database user and then on SECURITY > Database Access.

_images/mongodbcreatefirstdbuser.png

_images/mongodbcreatefirstdbuser2.png

Click on +ADD NEW USER. Choose a user and password. These credentials will be used by GameRules to connect to the database. Select atlas admin* role. Click on Add User to create it.

_images/mongodbcreatefirstdbuser3.png

Click on Whitelist your IP address, and then on SECURITY > Network Access.

_images/mongodbwhitelistipaddress.png

_images/mongodbwhitelistipaddress2.png

Click on +ADD IP ADDRESS. Either choose your internet IP address or allow access from anywhere. Then click on Confirm.

_images/mongodbwhitelistipaddress3.png

Last step is to connect to your cluster.

_images/mongodbconnect.png

_images/mongodbconnect2.png

Choose Connect your application, and then select C# driver and version 2.5 or later. The connection string will be used to connect GameRules to the MongoDB rule repository.

_images/mongodbconnect3.png

_images/mongodbconnect4.png

(Optional) Create another Database

By default, MongoDB creates a Test database inside the cluster. If you want to have multiple databases for different projects or environments, you can create additional databases inside the cluster.

To do so, go to your main cluster page Atlas > Clusters, and click on Collections, and then Add my own data.

_images/mongodbadddatabase.png

Specify your database name and put anything you want for collection name, then click on create.

_images/mongodbadddatabase2.png

Application Wizard

GameRules can be downloaded through Unity Asset Store. A folder GameRules under Assets is created which contains all libraries. Once installed, you have to open the GameRules Studio window through menu Window > GameRules Studio. You will see this screen the first time it runs:

_images/installwizard.png

  • Application Name: Setup the name of your game. It will then automatically create a root class with this name without spaces in Game Rules.
  • Rule Repository
    • Database type: choose MongoDB if you have multiple developers in your team. Otherwise, choose Sqlite to use internal database.
    • Database URL: when using MongoDB, you need to specify the url to connect to the database. In your previous example, it is
      • mongodb+srv://<dbuser>:<password>@cluster0-vosyj.mongodb.net/mysupergame?retryWrites=true&w=majority

Click on Test Connection to check if your setup is correct. You should see following message:

_images/installwizardtest.png

Click on Connect to existing application if there is already an application in setup in the rule repository. Typically, use this option when on-boarding additional developers to your team.

Click on Create application to create a your new application.

_images/installwizardcreate.png

Once clicked, it can take few minutes to create the rule repository. You should see in the console:

_images/installwizardconsole.png

Once it’s done, you can see a new folder GameRulesWorkspace with following structure:

  • GameRulesWorkspace
    • Editor
      • gamerules.sqlite~
      • gamerulescache.sqlite~
    • Scripts
      • generated scripts during product build

and content in rule repository.

_images/installwizardrulerepository.png

Note

Scripts folder is created only after first product build.

Architecture

The file gamerules.sqlite is used as internal database to store rule repository parameters, recents and favorites. It also contains rules when SQLite is used as rule repository.

  • Assets / GameRulesWorkspace / Editor / gamerules.sqlite~

The file gamerulescache.sqlite is used as rule repository cache to improve performances to limit interactions with the cloud database. A system pulse is automatically checking in Unity Editor every 30 seconds any update from the rule repository to refresh cache.

  • Assets / GameRulesWorkspace / Editor / gamerulescache.sqlite~

Note

To reset the cache, just re-save your Application rule in home tab.

These sqlite files, as they are under Editor folder, will not be part of your final game build and executables. However, as one may contain all rules, it is recommended to backup this file regularly.

Also, as the database file is outside GameRules folder, you can import any new version of GameRules asset without loosing your work.

Note

To see the rule repository setup, click on Game Rules icon on the left top bar > Rule repository.

_images/menurulerepository.png

You can also use this menu to switch rule repository:

_images/rulerepository.png

Important

If you change these settings, it will not recreate a new application, it will only connect to an existing application rule repository. It is advised once changed to restart Unity.