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 mLab.

Sign-up at mLab.com

Go to mlab.com and click on Sign-up to create an account, or login if you already have one.

_images/mlabsignup.png

Database creation

Once logged-in, click on MongoDB Deployments > Create new button.

_images/mlabcreatenew.png

Choose Sandbox as plan type, then click on continue.

_images/mlabplantype.png

Choose AWS region of your choice, then click on continue.

_images/mlabawsregion.png

Setup the database name of your choice, then click on continue.

_images/mlabdatabasename.png

Then click on Submit Order to confirm the database creation.

_images/mlaborderconfirmation.png

After few seconds, it is ready.

_images/mlabdatabaseready.png

Database user and url

Once the database is created, you need to create a database user used by Unity Editor to connect to it. This database user can be reused by all developers of your team.

Click on the link to open the database, and then go the Users tab, and click on Add database user.

_images/mlabuserstab.png

Specify user and password, then click on create.

_images/mlabadddbuser.png

Once done, note the url to connect, where <dbuser> and <dbpassword> have been replaced by previously created user:

  • mongodb://unity:unity@ds121289.mlab.com:21289/fantasticgame
_images/mlaburl.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://unity:unity@ds121289.mlab.com:21289/fantasticgame

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:

_images/installwizardwait.png

and 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.