Saturday, March 7, 2015

Moving from Scaleform to Unity UI

We started a new project in Advanced Production last semester called "Quantum Keeper", a PC game with the objective of teaching middle school kids about the revolutionary war. The game is a 3rd person adventure game with stealth game play and some puzzle solving. As with all recent Advanced Production projects we decided to make the game in Unity. My professor had just purchased a Scaleform key and wanted us to make the UI using Scaleform. Knowing that learning Scaleform could be valuable skill I chose to develop the UI. It was definitely an adventure, I had to learn Actionscript and the basics of real UI development.

Because of the learning curve with learning Scaleform and the fact that I would be passing on my work to a new programmer after I graduate in the spring, our programming lead thought it would be better if I re made the UI in the new Unity UI included in 4.6. Honestly for our purposes, Unity UI does just fine and my workflow is a bit nicer now since I don't have to go back and forth between Flash, Unity, and Mono.

The menu hasn't been skinned yet but most of the options functionality has been added, as of now settings are saved to PlayerPrefs but we may switch to JSON in the future.



Here is my Main Menu Manager script as of Feb 16.

Menu Manager:
http://pastebin.com/fn1nVEJW

I've just started the HUD this week, beginning with the Minimap and Compass.
When I started the mini map I tried simply moving an image around behind a mask and lining it up with the player location in the world but had a lot of issues lining it up correctly with map rotation. My solution was to use an orthographic camera pointed down at the player that could only see UI elements. I used a render texture where the map goes to render that camera, then placed a screenshot of the level under the level marked as UI as well as a marker that follows above the player. The result works well and the performance drop was tiny.



As of the time of the screenshot I was updating the compass, which is a default progress bar, by shooting a vector straight away from the camera, and towards the objective, then getting that angle and turning it positive or negative based on which side was closer to some empty objects placed on the left and right of the player's vision. This caused some jumpiness when you got too close to the objective so what I'm doing now is just firing a vector left and getting its angle relative to that. Then I convert that value to the progress bar percent and it results in a much smoother compass.

HUD manager as of Feb 18th:
http://pastebin.com/0siAPMcF

So far so good, I'll post updates to problems I find as I go.


Here are some of the Scaleform Scripts
Scripts I was working on at the time. They are not properly commented since the Scaleform version of the UI was very early in development.

HUD Manager:
http://pastebin.com/HXXsiEsH

HUD Cam:
http://pastebin.com/R2HT6ELs


No comments:

Post a Comment