My Next Chapter

I’ve been at Microsoft for just over 3 years and I’ve decided it’s time to move on.

Move on to Redmond, that is!

On March 16th, I will begin my new chapter at Microsoft as a Software Development Engineer in the Worldwide DX group – where I will be helping partners build epic projects.

The decision to accept this position did not come easy, as I have come to care greatly for the developer community in Dallas and surrounding areas. I have made many great friends as an evangelist this past 14 months and I will never forget the great times I had interacting with the community. Let’s face it, being a developer evangelist at Microsoft is an incredible job and one that I do not concede lightly, but I know that whoever they find to replace me will do a fine job.

Sometime in the next few months, my family and I will relocate to Washington, but I have a feeling that we’ll return one day. DFW is and always will be my home – it’s where I grew up, my family is still here and there are opportunities that I hope will someday come to bear here, when the time is right.

Never fear, I will still be actively blogging and interacting with the community on social media. I also hope to be able to bring some of the work I will be doing Redmond back to DFW down the road where it makes sense.

I bid you all in Dallas/Fort Worth a farewell, but not goodbye.

Jason Fox

How to access the UnityPlayer.log file on Windows Phone

Sometimes when debugging a game built with Unity, you need to access the UnityPlayer.log file to see what’s happening on an actual device. Here’s how you get the log file off of Windows Phone for inspection.

Requirements: You need a PC with the Windows Phone 8/8.1 SDK installed and a test device that has your game installed from either Visual Studio or the Application Deployment tool.

Note: this method does not work on games installed from the Windows Phone store.

Finding your game’s GUID

First, you will need to find the GUID for your app. For Windows Phone 8.1, this value is located in the Package.appxmanifest in Visual Studio. You will have to open the file using the text or XML editor. From there, you will need to find the PhoneProductID element of the PhoneIdentity tag.

For Windows Phone 8.0, this value is the Product ID, located in the WMAppManifest.xml file.

Taking a snapshot of IsolatedStorage

Next, we’ll use the IsolatedStorageExplorerTool to capture a snapshot of the game’s Temp directory on the phone and copy it to a directory on your PC.

Open a Windows command prompt and enter the following command –

Windows Phone 8.1 –

C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.1\Tools\IsolatedStorageExplorerTool>
ISEtool ts de appxfolder:Temp <your app’s GUID> "<PC target directory here>"

Windows Phone 8.0 –

C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v8.0\Tools\IsolatedStorageExplorerTool>
ISEtool ts de appxfolder:Temp <your app’s GUID> "<PC target directory here>"

If the operation completed successfully, the tool will print “Done.” In the output window.

Now you can navigate to your output folder and the UnityPlayer.log file should be located in the newly created IsolatedStore directory.

Reference

IsolatedStorageExplorerTool – https://msdn.microsoft.com/en-us/library/windows/apps/dn629254.aspx

Getting started with VR for Windows Phone

I started playing around with VR projects for Windows Phone back in December. I was thinking that if others could do it on Android and iOS, then our platform deserves some support, too. My initial project used the Google Cardboard for Unity SDK with a few tweaks for Windows Phone support. It was really hacky and I didn’t feel too great about releasing it to the public, even though I did drop it out on GitHub.

I spread that initial hacky version around inside my organization at Microsoft and it garnered some attention and resulted in me connecting with Peter Daukintis, a colleague of mine over in the United Kingdom. Peter had published two blogs posts – one about head tracking on Windows Phone and a follow up post using ALPS-VR for Unity.

Learning about ALPS-VR really opened up my eyes to what was possible with an open, cross-platform VR framework for mobile platforms, so I decided to scrap most of what I had done in my hacky Cardboard-based solution and move forward with ALPS-VR.

So, let’s move into actually building a VR experience for Windows Phone. This assumes that you have some working knowledge of Unity3D and Visual Studio for building Windows Phone apps.

You’ll need a few things:

  • A VR headset that can hold your phone – I’ve been using a Google Cardboard headset, since they are cheap and easy to come by. I have found them on e-bay and Amazon for less than $15 USD.
  • Download the Unity package(“alpsvr-wp.unitypackage” ) or clone my GitHub repo
  • Unity 4.6 (Pro for barrel distortion) – http://unity3d.com/unity/download **Not verified to work with Unity 5**
  • Visual Studio 2013 Community Edition – link
  • A Windows Phone running Windows Phone 8.1 – I recommend a phone in the 4.5-5 inch range like the Lumia 1020, 930 or Icon. The 1520 and other larger phones don’t fit the Cardboard googles.

Create your Unity project

  1. Open Unity and create a new 3D project
  2. Import “alps-vr windows phone.unitypackage” into your project
  3. Open the “demo” scene file located in Assets/Scenes – this will show you the structure of how a scene needs to be setup – you really just need to drag the ALPSCamera from ALPS/Prefabs into your scene

Select the ALPSCamera object in the scene and scroll down to the ALPSController script component. Notice that there is a Device setting for which VR headset you are using. I have mine set to “CARDBOARD” and the framework will optimize it’s settings for the Cardboard headset.

Build out for Windows Phone

  1. Open the Build Settings window located in the File->Build Settings menu
  2. Under Platforms, select Windows Store and set SDK to Phone 8.1

  3. Press “Build” and select an output folder for the Visual Studio project. I usually use something like a Builds folder that sits alongside my Unity project’s Assets folder.

Running the project on a device

This wouldn’t be much fun if you run it on an actual phone in a headset, so place that phone in there with the USB cable connected.

  1. Open that newly output Visual Studio project.
  2. Connect your phone to the PC using a USB cable. Make sure the phone is registered as a developer device.
  3. Now, you can run your project on the phone by targeting “Device” and pressing F5. Notice I have my build configuration set to “Master”. This setting yields the best performance, as it removes all of the profiling hooks from the Unity player.

     

What’s next?

Now that you’ve gone through setting up the sample project, you can venture forth to build your own custom scenes for your project. I would love to see what you build, so hit me up on Twitter to share and I will try to get you some exposure for your project – especially if you publish your app to the store.

You can post questions or comments here on the article and I will do my best to answer them in a timely manner. Of course, you are also welcome to contribute back to the GitHub repo. I will take a look at any pull requests submitted.

I should also mention that ALPS VR has support for Android phones as well, but I haven’t tried it yet. The Android phone that I have is far too old to run it.

Here’s what I’m doing at PAX South this weekend

My team here at Microsoft wanted to do something really cool this year at the inaugural PAX South convention, so we decided to help out some Texas-based game developers that we know, by hosting them in our booth.

From that idea, the Texas Indie Game Lounge was born!.

The Texas Indie Game Lounge is a space dedicated to showcasing games from some of the game developers we know and that we’ve partnered with, in Texas, over the past year to bring great games to both Windows and Windows Phone platforms.

Some highlights to look forward to this weekend at our booth –

We’re all excited to see everyone at PAX South this weekend! See you there!

Windows for Devices: Turn your Intel Galileo into a thermometer

010915_2129_WindowsforD3.jpg

This experiment is my first foray into the “internet of things” space using the Galileo Gen 1 board I got back in September. I decided to read the temperature in the room with a TMP36 thermometer sensor and then ultimately feed those readings into Azure. This is the first blog post outlining the steps to build a thermometer sensor out of your Galileo. There will be subsequent posts outlining the connection into Azure, so stay tuned!

If you’re interested in learning more about Windows for Devices, you can visit the portal here. From there, you can sign up for the preview program and learn more about it.

Parts list:

  • A Galileo Gen 1/Gen 2 board running the latest Windows for Devices image(as of this writing is 141114-1440)
  • TMP36 Thermometer component – link
  • Breadboard
  • 5 breadboard jumper wires
  • A LAN cable for connecting to the Galileo from your PC for debugging remotely from Visual Studio
  • Visual Studio 2013 Community Edition with the latest Windows for Devices SDK

First things first, if you have a Galileo board and haven’t set anything up yet, I recommend the setup tutorials on the portal before you get started here – http://ms-iot.github.io/content/. Make sure you install the latest Windows image!

Take a look at the diagrams below to learn how to wire up the temperature sensor.

010915_2105_WindowsforD1.png010915_2105_WindowsforD2.png010915_2129_WindowsforD3.jpg

 

Now that you have that all wired up, it’s time to write some code to read from the sensor.

There are three steps that are critical to getting an accurate temperature reading –

  1. Reading the analog signal from the TMP36 Vout pin, which in my case, is connected to A0, or analog pin zero, on my Galileo – the raw signal has a resolution of 10 mV / degree centigrade and a 500 mV offset for negative temperatures – source
  2. Converting the analog reading to a voltage value – it is critical to know the operating voltage of the sensor. For this example, I am using 5.0 V.
  3. Converting that voltage to Celsius

Code for these steps

int getReading(int pin)
{
    return analogRead(pin);
}
// the sensor reading from the TMP36 has a 10mV offset, so we have to compensate for that.
float getVoltage(int reading)
{
    float voltage = reading * 5.0; // the voltage the board is operating at is 5V - change to 3.3 if running off 3.3 V
	return voltage / 1024.0;
}
// Returns degrees in Celcius.
float convertVoltageToTempC(float voltage)
{
    return (voltage - 0.5) * 100;
}

We’ll use these methods in our sketch loop to read and convert the values.

void loop()
{
    int reading = getReading(sensorPin);
	float voltage = getVoltage(reading);
	Log(L"raw voltage reading: %lf\n", voltage);

	float celcius = convertVoltageToTempC(voltage);
	Log(L"External Sensor Temperature: %lf Celcius\n", celcius);
	delay(4000);
}

The code for the project is part of an overall solution to hook into Azure Event Hubs – you can get the complete solution from GitHub – https://github.com/Foxman13/AzureEventHubsDemo

My first 5K with Microsoft Band

These are my first impressions of using the Microsoft Band during a 5K race.

Let me start by saying that I didn’t find the Microsoft Band the least bit uncomfortable. However, I am a relatively big person with large wrists (6′ 3″, 205 lbs.), so others may have a different experience. This was also my first 5K race in over 10 years, so don’t knock my performance too much!

My current verdict

The Microsoft Band is a well-designed fitness tracker with great app integration and real-world value. I can already tell that is was a worthwhile gadget investment and is leaps and bounds a better experience than the FitBit Flex that I used to wear.

Here’s how it went…

Preparation

Little preparation was required. The band just needed a little charge this morning before I left the house, so when I got up this morning, I charged my Band for about 40 minutes. It started with 40% charge and was at about 80% when I took it off the charger. If you plan to use the onboard GPS chip to enable GPS tracking for your runs, it is important to note that you need enable GPS for your runs by opening the run app and swiping to the right to the toggle.

During the Race

You start a run by opening the run tracking app on your Band and pressing the action button. From there, you can press the action button again to pause the run and then ether resume or end it. This is a pretty standard user experience for these types of applications. What I failed to see was the prompt asking if I wanted to start tracking the run while it was still trying to lock a GPS signal, which required a second press of the action button, so I didn’t actually start the tracking until about .25 miles into the run. I suppose it would’ve helped to read the instructions beforehand. My preference would be for it go ahead and start tracking and then add GPS when it has a lock without requiring a second interaction.

After I got the run tracking enabled, the Band, by default, showed a nice display of calories, heart rate and total time elapsed – if you swipe down from the top, there is a little overlay screen that shows GPS status, pace time, and distance.

Something that I think I noticed (I could be crazy) was that the Band gave me a nice little haptic buzz at every mile marker. I don’t know if this is only done during GPS tracking or it will also happen during a normal run, but it is a good little reminder of how you’re progressing through your run. This replaces the audible function that most run tracking apps have and is a nice touch.

You end the run by pressing the action button and selecting “End”. It took me a few seconds to remember to End the run after crossing the finish line. What can I say? I was in the zone.

After the Race

This is where I think the Microsoft Band and its integration with the Microsoft Health app really shine. After I retrieved my phone from my car, I let the Band sync with my phone and then opened the app on my Nokia Lumia 1520. To my elation, it had a very detailed recounting of my run starting with a summary that included a map of my run. Presumably this map only shows up after runs with GPS tracking enabled.

If you tap on the map, it opens it full screen. The really nice part of the map, is that it has a color map of what your speed was like during the run. You can see where I turned up the heat on the last stretch. It also has mile markers, so you can see where exactly those distances were achieved. The snail and cheetah icons in the color map key are also a nice touch.

The other screen is splits, which is figures out for you automatically, which is nice. Other apps I’ve used leave it up to you to split manually.

One other note on the run summary screen – all the way at the bottom, there are three options – share, delete and rename. I chose to rename the event, so I can log it officially. I also chose to share it on Facebook and I am perplexed as to why Twitter sharing is not available. Hopefully, that will show up in a future update.

Also, I noted that at the beginning of the race my Band had a charge of 79% and afterwards, had dropped to 71%, so it would seem that GPS tracking does drain the battery much faster as expected and is stated in the product manual.

Overall, color me impressed from my first outing with the Microsoft Band in a fitness scenario. The integration between the Band and the Microsoft Health app is top notch and I found the band to be both comfortable and very useful for tracking my run. I can see how using the Microsoft Band and the accompanying app will lead to greater insights into my training to becoming a better runner. Based on my experience this time around, I think it is time to retire Runtastic and finally stop lugging my giant phone with me on runs.

Plus! I stopped at Starbucks on my home and used the Starbucks card app to pay. It works flawlessly and usually starts up a conversation with the person working the register and anyone behind or in front who happens to see you use it.

TAMUHack Winners!

WP_20141025_20_32_20_Pro

Summary

TAMUHack was a Major League Hacking event held at Texas A&M University on October 24th and 25th. It was the first MHL hackathon held at the university and it was met with great enthusiasm.

Congratulations to the team that I helped who were building a VR game in Unity. They ended up winning 3rd place overall at the hackathon and that is a picture of them with me at the top of the article.

Microsoft sponsored the hackathon and provided prizes for the most creative use of Azure cloud services.

I was astonished at the creativity of the projects at the hackathon and there were some very creative hacks that were able to use the Azure platform to enable the cloud portion of their applications. The uses ranged from hosting websites in Azure website to uploading data to Azure Blob storage.

Azure Projects

Here are the projects that leveraged Azure during the hackathon with the winners highlighted.

  • WebBro(our big winner) – a chrome browser extension that allows users to leave comments on a website even if the website doesn’t have a built-in comment system. Think crows-sourced comments. We felt this was a very creative project and solves a problem on the web in a very creative way.
    • Team members – Arun Krishnakumar, Anirudh R, and Brandon Jackson
    • Their use of Azure included
      • Azure web site exposing PHP web service.
      • Persist data in MySQL on Azure.
      • Automatic deployment through Github.
    • Each team member won a Microsoft Universal Mobile Keyboard
    • You can also install the extension via the Chrome web store – https://chrome.google.com/webstore/detail/webbro/mebjfhcfffefpncpfmpkimmplcljipke
  • Projections(runner up) – Retrieving, and analyzing, and reporting Fortune 500 data from Bloomberg. This was a very polished, well-rounded web application. It was a close call between this one and WebBro.
    • Team – Jeffrey Zhao, Son Pham, Benny Yan, Ian Macalinao, and Klayton Wittler
    • Their use of Azure
      • Created Ubuntu VM; connected to Bloomberg VPN. Deployed Java backend app.
    • http://projections.cloudapp.net
  • OcuLeap – Use Leap motion gestures to navigate world map; Oculus Rift displays photos at selected location. The technology uses WebGL for rendering to Oculus.
  • GitBrub – a crowd-sourced repository for food recipes.
    • Team – Justin Emig, Wasim Wadhwani, Logan Collins
    • Their use of Azure
      • Installed “Bottle” micro framework on Azure VM
  • BudgetByte – Web app calculates the maximum calories for a given restaurant and budget.
    • Team – Garrett Whitehorn, Magan Tyler, Chris Gillis, and Harrison Golden
    • Their use of Azure
      • Hosting PHP site in Azure Web Sites
  • SecureStore – Secure storage and sharing of photos.
  • Satyakiran Duggina – Capture American Sign Language gestures with Kinect and translate message.
    • Team – Satyakiran Duggina
    • Use of Azure
      • Deployed app to VM
      • Storing videos in blob storage

Computer Visionaries 2014 – Incredible success!

Computer Visionaries 2014 was a Kinect for Windows hack-a-thon sponsored by Microsoft and the Kinect for Windows team that took place on July 18th and 19th in Dallas, TX.

First of all, it was my pleasure to work with Skip Howard, and the other volunteers from the Computer Vision – Dallas group, to bring the Kinect team to Computer Visionaries 2014 in Dallas! I hope all involved had a great time and a big shout out to The DEC for hosting us in their newly opened facility in the Dallas West End.

How it all started

When we contacted Ben Lower to come down to speak at the Computer Vision – Dallas user group in July, we had no idea that it would blow up into a full blown hack-a-thon! We talked to Ben and he said, “Let’s do something big – it is Dallas after all, where everything is BIG”. So, we went from a simple speaker request to a full blown hack-a-thon on just a few weeks.

From there, we planned the event, marketed the event and drove ticket sales up to 128 the day of the event in just 7 weeks! This speaks volumes about the level of trust, commitment and enthusiasm Microsoft has from the developers in Dallas/Ft. Worth and surrounding areas and I couldn’t be more proud to be a part of that community.

The Event

We had 114/128 registered attendees show up to hack on the Kinect sensor. That is an 89% show rate, which is nearly unheard of for any kind of developer event. This number doesn’t account for the numerous visitors we had come through to see the projects in addition to our guest judges. This to me, shows that the developers, entrepreneurs, makers, and overall tech enthusiasts in the DFW area recognize the potential that Kinect has to change the way we interact with our computers in a day-to-day basis and are truly enthused to be a part of that future.

The event attracted an impressive mixture of attendees – we had programmers, artists, designers, web traffic specialists, local entrepreneurs, composers, DJs, hobbyists, makers, gamers, attorneys, college students, high school students, middle school students, professors, teachers, and a CEO or two snuck in to see what was happening.

At the end, 15 teams presented their projects on Saturday night in front of the judging panel. The projects ranged from scanning your body measurements, detecting head nods for paraplegics on into video games and educational apps. The ideas, innovation and level of execution on these projects was nothing short of amazing and mind-blowing. I could tell by how long it took the judges to come out with the results, that their job was indeed difficult in choosing the winners.

The WINNERS!

In the end, the event was a contest, so we had to have clear winners.

1st Place

Team: Dallas Society of Play

Project: Super Dueling Golem Dudes

Members: Daniel Fairley, Jim Welch

Prize: $500 in cash and a Kinect V2 sensor each

Vine: https://vine.co/v/MQL3lP1MxwX

2nd Place

Team: Kinectergarten

Project: Kinectergarten

Members: Phil Denoncourt, Anthony, Erik Leaseburg, Jason Eads, Kamila, Chris Ford

Prize: $250 cash and a Kinect V2 sensor

3rd Place

Team: Burger ITS

Project: Put Me in Space

Members: Shawn Weisfeld, Theresa Burger, Robert Burger, Harold Pulcher, Corey Drew, Alisson Drew, Taylor Wooley, James Porter

Prize: $100 cash and a Kinect V2 sensor

The Judges

A big heartfelt thanks for our guest judges who volunteered their time to participate in the event and help us choose our winners!

From left to right – Dan Ferguson, Gabriela Draney and Caleb Jenkins. Each of which received a shiny new Kinect V2 sensor for helping us out!

Thank you!

Also, a big thanks to everyone who made this event happen – Skip Howard, Ben Lower and the Kinect for Windows team, Dr. Neil Roodyn, Joshua Blake, Jenifer Conley, Nathalie Goh-Livorness, the judges and all of the volunteers who helped check people in and keep the venue clean.

I really hope everyone had a great time at the event and if you have any feedback, please feel free to reach out to me on Twitter or by e-mail.

Cheers!

Jason Fox

Giving Indie Devs a little Spark

Some of you may have seen me talking about BizSpark on Twitter recently or at one of the Day of Unity events that I hosted and are wondering what the program is all about and how can it help indie game developers?

In my personal assessment of the program, I really do think that BizSpark is a great program that goes underutilized in the game developer space. The program gives you access to tools and resource for 3 years to help offset the costs of starting your company. This can be invaluable to startups who could already be lightly bootstrapped or starting off with no funds at all. Anything that helps, right?

So, what is BizSpark?

  • Microsoft BizSpark is a free program dedicated to helping startups, even game devs, succeed.
  • It gives you free access to the software and tools to build amazing games, as well as the technology to get into the cloud.
  • You can also connect to thousands of other startups and game devs and 1,500+ startup organizations around the world.

Benefits include

  • Access to tools and support that your studio might need.
  • Looking into cloud computing? Microsoft Azure has serious potential to help bring your games to the cloud.
  • Cloud computing has almost limitless potential for supporting games. Here are just a few examples of what cloud computing is being used for – hosting game servers, serving out game updates, hosting websites, running your own leaderboard service, running cloud-hosted game logic/AI (think Titanfall). Maybe you have the next gamer services platform that you’re building to sell to other studios?
  • BizSpark gives you $150 in Azure credit per month – this goes a really long way during development with the option of paying if needed.
  • Visual Studio – Whether you’re coding your own engine in C++/C#/VB or HTML/JS or maybe scripting in Unity, then there’s no denying that Visual Studio is an awesome IDE. Visual Studio Tools for Unity is now free!
  • Do you plan on building games for Windows or Windows Phone? Get the latest tools to help you out.
  • Other benefits are also available – free Windows developer account, 90 days trial of pluralsight training and access to many other partner offerings directly through the program.

There are some qualification to joining BizSpark:

  • Are you making games?
  • Is your game studio less than 5 years old?
  • Are you making less than $1 million USD in revenue per year?
  • Is your game studio privately held?

If you can answer YES to all of these questions, then you qualify for the program! If you answered NO to any of these questions, then you don’t qualify. If you don’t qualify, then please spread the word to people you know who might! Let’s get the word out about this great program!

This all sounds awesome! How do I sign up?

There’s two ways to sign up:

  • The slow way – you can visit this link to register– this adds you to the review queue, which can take several days to several weeks to complete, or
  • The fast way – if you answered YES to the questions above, you can e-mail me about your game studio and I can pre-qualify you into the program. Please detail your studio name, or yourself if you publish under your name, what projects you’re working on and include any reference material about your studio or projects like links, screenshots, etc. Once I verify you, I can send a special link via e-mail that automatically enrolls you into the program.

My e-mail: jason.fox@microsoft.com

As always, if you have any questions, please hit me up at http://twitter.com/JasonGFox or shoot me an e-mail.

Cheers!

Adding a trial experience in your Windows game built with Unity

The case has been made that if you offer a trial mode for your game, then your purchase rate will increase along with the increase in installation footprint. I agree and I know several developers who have increased their game’s revenue by organically growing their install base using a trial mode.

Fortunately, the Windows and Windows Phone stores each make it very simple to implement such an experience. Coupled with Unity who was gracious enough to include a simple API in its platform to check for a trial license from the store platform.

Step 1 – As in game, you will need to decide the basis of your trial experience. Is it going to be:

  • 7 days with unlimited access to features?
  • Unlimited with limited features?
  • Somewhere in between?

***Let me warn you – if you don’t give the player something compelling to do in trial mode, they will *not* purchase your game. I suggesting loading up your search engine of choice – preferably Bing – and doing some research on what works as far as trial experiences.

Once you’ve decided on what your super-awesome trial experience is going to look like, you can start to implement what you need in your code.

Step 2 – On to the code!

As I mentioned above, Unity has included a simple API for probing the license information for the game from the Store platform. I wasn’t able to find any documentation for the API on the Unity docs site, so I’ll just post the code definition here.

using System;
using UnityEngine;

namespace UnityEngine.Windows
{
    public sealed class LicenseInformation
    {
        public LicenseInformation();

        public static bool isOnAppTrial { get; }

        [WrapperlessIcall]
        public static string PurchaseApp();
    }
}

Somewhere in my game scripts, I will want to query this API to see if I need to setup my game to support trial mode or the player can just proceed with normal gameplay. Typically, in a Unity game, you will have some kind of GameController object that will persist across scenes. That is where I am going to put my code for the sake of this tutorial. So, let’s open that up.

We need to store the status of trial mode in a public static field, so that other scripts that query it to limit features in the game.

    public static bool IsTrial = true;
    void Awake()
    {
        GameObject.DontDestroyOnLoad(this); // cause this object to persist

#if UNITY_WINRT
        IsTrial = UnityEngine.Windows.LicenseInformation.isOnAppTrial;
#endif
    }

After I store the state, I can use it to draw a Buy button in my game’s GUI. When the play presses the button, it will call PurchaseApp() to launch the Store purchasing process.

    void OnGUI()
    {
        if (IsTrial)
        {
            if (GUI.Button(new Rect(50, 30, 100, 25), "Buy me!"))
            {
#if UNITY_WINRT || WINDOWS_PHONE
                var receipt = UnityEngine.Windows.LicenseInformation.PurchaseApp();
                IsTrial = false;
#endif
            }
        }
    }

At this point, I can’t tell that the string that PurchaseApp returns is anything at all. I get an empty string when I debug, but I am also not debugging against a game that is published in the store. It appears to just be a fire-and-forget style API, so I want to put in some logic to recheck the trial mode state when FixedUpdate runs, but only after 1 second has passed. So, while the app is in trial mode, we will check for a change every 1 second.

    void FixedUpdate()
    {
        if (IsTrial && (Time.realtimeSinceStartup - _lastTrialCheck) >= 1f)
        {
            _lastTrialCheck = Time.realtimeSinceStartup;

            // we'll detect if the trial state has changed
            if (UnityEngine.Windows.LicenseInformation.isOnAppTrial != IsTrial)
            {
#if UNITY_WINRT
                IsTrial = UnityEngine.Windows.LicenseInformation.isOnAppTrial;
#endif
            }
        }
    }

That’s it. Hopefully, you have enough information to implement a trial in a Windows game. Remember, make the trail mode fun enough where the players will want to purchase your game to continue playing and to support the great work that you’ve done!

Cheers!

Also, here’s the full source for my GameController class.

using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour {

    public static bool IsTrial = true;

    private float _lastTrialCheck = 0f;

    void Awake()
    {
        GameObject.DontDestroyOnLoad(this); // cause this object to persist

#if UNITY_WINRT
        IsTrial = UnityEngine.Windows.LicenseInformation.isOnAppTrial;
#endif
    }

    void FixedUpdate()
    {
        if (IsTrial && (Time.realtimeSinceStartup - _lastTrialCheck) >= 1f)
        {
            _lastTrialCheck = Time.realtimeSinceStartup;

            // we'll detect if the trial state has changed
            if (UnityEngine.Windows.LicenseInformation.isOnAppTrial != IsTrial)
            {
#if UNITY_WINRT
                IsTrial = UnityEngine.Windows.LicenseInformation.isOnAppTrial;
#endif
            }
        }
    }

    void OnGUI()
    {
        if (IsTrial)
        {
            if (GUI.Button(new Rect(50, 30, 100, 25), "Buy me!"))
            {
#if UNITY_WINRT || WINDOWS_PHONE
                var receipt = UnityEngine.Windows.LicenseInformation.PurchaseApp();
                IsTrial = false;
#endif
            }
        }
    }
}