IGL.Samples Unity Sample

A new Unity project has been added to IGL.Samples.  The purpose of the project is to illustrate how a Unity game can send messages to and receive messages from the IGL Backbone.

The project contains a scene that has a button to start listening and a button to send a message.  The result of a message is shown in a message box as illustrated below:


When a message is received, then a message is shown in the console:



The Canvas object contains a script with the following implementation.

Setting up initial configuration

On the start, some initial configuration is required as well as setting up an event handler for GameEvent messages received and for when errors are encountered in the ServiceBusListener.

Note the settings below are for the IGL Backbone Service and its status can be viewed on the services tab.

void Start () {
_instance = Guid.NewGuid();
//// initial setup of IGL
 IGL.Client.Configuration.IssuerName = "IGLGuestClient";
 IGL.Client.Configuration.IssuerSecret = "2PenhRgdmlf6F1oNglk9Wra1FRH31pcOwbB3q4X0vDs=";
 IGL.Client.Configuration.ServiceNamespace = "indiegameslab";
IGL.Client.Configuration.GameId = 100;
 IGL.Client.Configuration.PlayerId = "TestingTesting";
_listener = new IGL.Client.ServiceBusListener();
 IGL.Client.ServiceBusListener.OnGameEventReceived += ServiceBusListener_OnGameEventReceived;
 IGL.Client.ServiceBusListener.OnListenError += ServiceBusListener_OnListenError; 

Listening for GameEvents

The following show the implementation of the event handlers and both write a message to the console.

private void ServiceBusListener_OnListenError(object sender, System.IO.ErrorEventArgs e)
 Debug.LogErrorFormat("Error:{0}", e.GetException().Message);
private void ServiceBusListener_OnGameEventReceived(object sender, IGL.GamePacketArgs e)
 if (e.GamePacket.GameEvent.Properties["Instance"] == null ||
 e.GamePacket.GameEvent.Properties["Instance"] != _instance.ToString())
 var sentTime = DateTime.Parse(e.GamePacket.GameEvent.Properties["Created"]);
 Debug.LogFormat("Packet:{0} Round Trip in {1} milliseconds.", 

The IGL.ServiceBusListener() contains a method that performs an async retrieve from the IGL Backbone for messages addressed to the player.  Though this message is called in Update(), only one request to the Backbone will be sent at a time.

void Update()
 if (_listenForMessages == true)

Sending a GameEvent

The SendEchoMessage() method is called when the send button is pressed and submits a simple GameEvent to the IGL Backbone:

public void SendEchoMessage()
 var gameEvent = new IGL.GameEvent
 Properties = new Dictionary<string, string>()
 { "Created", DateTime.UtcNow.ToString() },
 { "Instance", _instance.ToString() }
 bool wasSuccessful = IGL.Client.ServiceBusWriter.SubmitGameEvent("Echo", 1, gameEvent);
 MessageDisplay.text = "Sent message without error: " + wasSuccessful.ToString() + Environment.NewLine + MessageDisplay.text;


Echo Function

The Echo Function is live and available for general use while the 1 million free executions lasts!  The status of the Echo Function is on the Echo Function page (Service tab).

As an illustration, the Echo Function will read new messages that are published to the echo queue and publish to the specific player Topic.


Unity AssetServer – FATAL: could not reattach to shared memory

If you run into an issue where the Unity AssetServer fails to start, try a simple restart of the server in the first instance.  There are a heap of posts indicating it is postgres related but I have not gotten to the root of the error.  So far a simple restart of the server seems to clear the shared memory lock but I will be making regular backups as well as at least one person has not been so lucky.

LOG:  database system was interrupted; last known up at 2014-11-12 04:06:49 GMT
LOG:  database system was not properly shut down; automatic recovery in progress
LOG:  record with zero length at 1/F3E78290
LOG:  redo is not required
LOG:  database system is ready to accept connections
FATAL:  could not reattach to shared memory (key=256, addr=018D0000): 487
LOG:  background writer process (PID 2132) exited with exit code 1
LOG:  terminating any other active server processes
FATAL:  could not reattach to shared memory (key=256, addr=018D0000): 487
LOG:  autovacuum launcher started
LOG:  all server processes terminated; reinitializing
FATAL:  pre-existing shared memory block is still in use
HINT:  Check if there are any old server processes still running, and terminate them.

Asset Server on Azure

There are many advantages and disadvantages of using hosted team collaboration services like Visual Studio Online, Git and Subversion compared with the Unity Asset Server.  In some situations, standing up a self-hosted source control repository is a good choice.

Unity Asset Server is only available with a Team License holder.

The following are the steps required to create a Unity Asset Server on the Azure.  Assuming an Azure subscription is already in place, the first step is to provision a new virtual machine.  As we do not require any additional features, a quick create will suffice:


The setup is very simple.  A DNS name that has not been currently registered is required and some information about what type of VM.  For my purposes I went with the most inexpensive option with the idea that I could scale up as required (an advantage of using Azure to host the VM).  The user name and password specified here is primarily for remote desktop access to the VM.


Once the server has been fully created, connect to the server from the virtual machine dashboard:


Once a connection has been made then install Unity Asset Server.  Before this can be done though the .Net Framework version needs to be updated to include 3.5.  The first step is to start the Server Manager dashboard (at the bottom of the screen):


The next step is to enable a new feature:


The wizard will take you through several steps.  Most notably are selecting the type of feature-based installation:


The particular server needs to be selected:


Finally the framework needs to be selected:


Once this is complete, then the Asset Server can be installed.  The easiest way is to download the package via the Unity Collaboration page.  The setup is uneventful except for an Asset Server Admin password is required.  This password will be used to create projects and users on the Asset Server from the Unity IDE.


The Asset Server should then start and should display that it is running successfully:


Now for connectivity to the server remotely.  Back in the Azure Management Portal, the accessible endpoints are listed on the endpoints section of the VM:


Click ADD to launch the endpoint wizard.  As this is for a single VM, select the Add a stand-alone endpoint option:


On the next page the details of the endpoint are specified:


Great.  We are done!  The simplest way to verify the server is listening and available is to use a simple test test.  I used paging as it is free and simple:


From here, there are many posts about how to setup the Asset Server including:

Asset Server

Setting up Asset Server with Unity3D over local-network

Debugging Unity with Visual Studio

Congrats to SyntaxTree on being acquired by Microsoft.  I look forward to seeing more innovation in from SyntaxTree and Microsoft in regards to Unity.

You can download the latest tools from the Visual Studio Gallery and install them as normal.

After starting Unity you will see a new Asset available as Visual Studio 2013 Tools:


This will bring in two new dlls into the Unity IDE:


If you want to debug your solution in Visual Studio, check the build settings to allow Visual Studio to connect:



Winner KiwiGameStarter 2014

Great news!  Phantasmal has won the KiwiGameStarter 2014 competition run by the New Zealand Game Developers Association Incorporated (NZGDA).

KiwiGameStarter 2014 is a business start-up competition for New Zealand-based game development teams. Its purpose is to support the commercial success of one high-potential team or project

So what does it mean.  Kudos, a sense of achievement and

  • $10,000 cash
  • One one-year license for Autodesk Maya LT
  • One commercial suite license for Unity 3D
  • public relations and marketing strategy advice from Pursuit Public Relations to the value of $2,000
  • assistance by Hudson Gavin Martin (specialist Technology and IP lawyers) with the drafting of a licence agreement for the winning Entry to license the Winner’s Game to end users (worth $2,000 plus GST) and additional legal advice from Hudson Gavin Martin in relation to the Game up to the value of $2,000 plus GST
  • introductions from the NZGDA to experienced game development professionals in New Zealand (Mentors) who have expertise in a domain or genre relevant to the Winner’s Entry

The pressure is on.  If you haven’t done so, please head over and look at Steam Greenlight: http://steamcommunity.com/sharedfiles/filedetails/?id=291861158&result=1

Unity and UnityVS

When you are used to the power of Visual Studio, debugging Unity can be awkward and frustrating.  The common approach is to set debug messages in code, cross your fingers and hope when the game runs you set the message in the correct place for it to be useful.  This approach was fine in the ’80s when I had more patience, but now it is just painful.

I heard of SyntaxTree’s UnityVS from some more experienced Unity developers but they were put off by the price: ~$100 for an individual license.  They were not the only ones.

Hmmm…  the price did not sound to bad if UnityVS does what it says in the list of features.  The features I am interested in are Seamless Integration, Debugging, and the Unity Console within Visual Studio.

I had some time and with the free 14 day free trial, I decided to give UnityVS a test run.

Installation of UnityVS 2012

The UnityVS 14 day trial is given out per email address, and given a password supplied by email, the download (~7mb) and installation process was straightforward .

Sample Project

At the same time, I decided to take a look at the Unity 4.3 2D support by downloading the sample project from the Asset Store.


After downloading the package, I created a new project and selected the following packages:


First off, I opened the Level scene and gave the game a run.  Cool, my little character runs around the screen as expected.

I then found an interesting looking script attached to the hero and double clicked.  Visual Studio, my default script editor, launched and I am presented with a dialog to enter my UnityVS license that I received attached to my registration email:


As expected, Visual Studio correctly shows the scripts in the project; granted the display is more clear.  I like the Seamless Integration feature but still not worth $100.


Unity debug message

Let’s say we wanted to identify when the number of available bombs goes from 1 to 0.  A simple way would be to add the highlighted debug message in the LayBombs.cs script:


Now when the game is run and the player runs out of bombs, the following is printed to the Unity console window:


Now with UnityVS

Let’s check out UnityVS now.  The first thing is to check the integration while the game is running in Unity.  I simply start the debugger in Visual Studio (F5).  UnityVS gives me a prompt at the bottom to let me know it is all ready:


And after some game play, yes the console is log messages are shown in the Error List window with the benefit of extra information.  Nice feature!


Now, let’s get rid of the code to write the debug message and set a breakpoint when the number of bombs is decremented.


Now when the breakpoint is triggered when a bomb is laid, and as expected, a view of the variables in scope are available:


It is important to note that gameplay stops while the breakpoint is active.

Why Visual Studio?

For those that might not be familiar with Visual Studio, there are many cool features.  Just to illustrate one, I decided to change the breakpoint to only fire when the number of bombs becomes 0.  To do this simply set a condition to the breakpoint by selecting the condition option on the breakpoint:


and entering in the following evaluation:


Now the breakpoint will only trigger when the bombs run out.  The great thing here is your code does not become clouded with pointless debug messages.

Definitely worth the price.