Battle-tested during the development of the quadruple-platform game Snuggle Truck, this tool allows for configuration of specific per-platform settings for all devices. Need to change button sizes for iPhone Retina and swap out textures for iPad? Not a problem. Need to replace text on a per-platform basis or swap fonts? Easy. Need to create a resolution-independent UI that works on all major aspect ratios? It's a breeze!
A component that stores all per-platform information and applies it with ease. All stock platforms are supported (iPhone, iPad, Android, Standalone, Webplayer) as well as custom platforms (Demo build, Press-only build) and major aspect ratios (4x3, 16x9, 16x10, and 3x2 for iOS). Also includes a helper tool called EasyPlatform that emulates different platforms within the Unity Editor.
Your asset management command center. Create configurations of asset compressions and apply them whenever needed. Get the granularity that Unity doesn't provide by creating custom asset configurations for all situations. When you want to change texture compression or audio bitrate on hundreds of files at once, this tool makes it painless.
An automated granular build process. Operates as a one-button menu item for building to different platforms. It scans scenes for platform-specific changes and assets and applies them at BUILD TIME to achieve optimal stripping! If you're trying to stay under 20mb for iPhone, you'll appreciate the flexibility of having PlatformSpecifics and BuildProcess working to your advantage.
Also included are a couple of dependencies and usability extras that are needed for this pipeline's operation, such as AspectPerfect - A tool that automates the process of scaling quads to the proper aspect ratio of a texture, making working with sprites very simple... And RenderQueueSorter - A tool that helps avoid sorting issues in 2d games by adding the ability to hand specify render order.
Unity Pro is required for BuildProcess support! We utilize a custom BuildPipeline, which is a Pro-only feature. If you're not using the BuildProcess but only want to use AssetSettings and PlatformSpecifics, Unity Pro is not required. We're looking into selling a reduced price package with 2 out of the 3 tools. Please contact us if you're interested.
*Fully tested with Unity version 3.3 and version 3.4
So you've got a sweet game, and now you need it to work on multiple devices or at multiple resolutions. You've purchased the MultiPlatform ToolKit and are wondering how to get started. Here's what you do:
PlatformSpecifics does quite a few things and has lots of buttons. What do they all mean? Well, lets investigate:
Lets say you wanted to position a box in the upper left corner of your screen on your iOS game which runs on iPhone, iPhone Retina displays, and iPad. Here's how you'd do it:
Let's say you wanted to have a background plane behind your non-iOS game (Android or Standalone for example) and it should stretch from the left edge to the right edge of the screen, but your game could be played at 320x240, or 640x480, or 800x600, or one of a million other resolutions. Well, most resolutions fall under 5 different aspect ratios:
16:9, 16:10, 3:2, 4:3, or 5:4 - (Check out this handy resolution chart!)
Thankfully we provide support for those 5 aspect ratios as well as some really wonky Android resolutions that Unity Android lists as common resolutions. We've also made it super easy to add additional custom aspect ratios in case you're working with offbeat hardware. So, lets walk through the process of setting up resolution-independent positioning, very similar to Tutorial 1 but outside of the iOS space.
You've set up your scene to use different PlatformSpecifics and are ready to do a real on-device build. You'd like to try out your Mac build, your PC build, your iPhone build, your Android build, etc. We first need to edit BuildProcess.cs so it can cater to your specific needs.
Lets say your Standalone PC/Mac game contained a level editor, but due to time or scope reasons, you wanted to leave the level editor out of your mobile versions. We'll need to make sure the button in the main menu is removed and that the scene itself is not included in the mobile versions of the build. In addition, there's some text in the game that talks about the level editor, but instead of removing it, we want to swap that text to say that the level editor is available *only* on the PC and Mac, to avoid any confusion. MultiPlatform ToolKit to the rescue! Here's how we do it:
static string[] iPhoneScenes = new string[] { @"Assets/Scenes/gameScene.unity" }; Lets say you wanted to have a class that only ran on iOS, for example. Lets see how we'd do that:
#if UNITY_IPHONE
//code goes here
#endif
#if UNITY_IPHONE && !(UNITY_EDITOR) //code goes here #endif
Lets say you wanted to use a high resolution texture on your iPad build but use a differently sized version for your iPhone build. After all, they are two different aspect ratios, so squashing the iPad texture down on the iPhone will end up stretching it, so why not make pixel perfect versions for both builds? Well depending on your goals, you might be trying to stay under 20mb on iPhone and are doing separate iPhone and iPad builds. Other times you don't care about file size. In both cases, we have a solution that fits the bill:
Unity's texture importer only exposes per-platform customization of the Max Size and Format properties and it only distinguishes between WebPlayer, Standalone, iOS, and Android platforms. We had two problems with this scheme: One, there are quite a few other texture import settings that we'd like to have control of on a per-platform basis and Two, in certain cases we'd like to be able to distinguish between iPhone and iPad as separate platforms. Unity's audio importer, on the other hand, does not expose any per-platform customization of its import settings and this is another area we felt needed improvement.
Asset Settings solves these problems by allowing you to create any asset configuration for any type of build; such as Demo builds, Press-only builds, or a Debug builds with special asset import settings. Let's get acquainted with the Asset Settings interface. Note that all buttons in the Asset Settings interface have tooltips that provide additional information, which you can view by hovering your cursor above the buttons.
Now, let's delve into the details of each of these sections of the Asset Settings window.
The MultiPlatform ToolKit has been tested with SpriteManager2 and EZGUI with minimal friction. If your 2d framework works with Transforms in the scene hierarchy that can be scaled and positioned at any time, then it's definitely compatible with the MultiPlatform ToolKit. Here are a few things to consider when dealing with 2d:
The MultiPlatform ToolKit supports replacing text contents on TextMesh objects as well as swapping fonts and font materials. For example, if you want your mobile versions to say "Tap Here!" and your Standalone platforms to say "Click Here!", the Text Mesh Text field will allow you to swap out text for any platform. Or if you want to swap from 60pt font to 24pt font depending on your screen resolution, the toolkit supports that.
Out of the box, the toolkit only supports changes to the TextMesh class, but it could be easily extended to have another text class in its place, such as GUIText, SpriteManager's SpriteText class, 2D Toolkit's BMTextMesh class, or ex2D's SpriteFont class depending on what you're using. Feel free to extend PlatformSpecifics to support it.
In order to extend PlatformSpecifics to support custom text solutions, take a look at PlatformSpecifics' function ApplyFont() and ApplyTextMeshText(). Change these to edit your custom class' text field and material/font field. Then, swap out the instances of "<TextMesh>" within the PlatformSpecificsEditor.cs class to your custom class to ensure proper editor functionality of the PlatformSpecifics class. That's pretty much it.
AutoPilot takes control of the build process and automatically uploads iOS builds to TestFlight for adhoc testing. AssetSettings and PlatformSpecifics are fully supported and compatible with AutoPilot. MultiPlatform ToolKit users are free to use AutoPilot's build process to auto-upload to TestFlight and can safely disregard the BuildProcess class included in the toolkit, so long as they aren't depending on material stripping. If you're unsure if you need material stripping, read item #7 of Tutorial 5 for more information.
The MultiPlatform ToolKit is fully compatible with Prime31 plugins which modify the build process. Prime31's postprocess scripts are handled after the MPTK BuildProcess takes effect, so everything just works. In fact, we used 3 Prime31 plugins with Snuggle Truck on iOS.
Asset Settings supports importing all types of content and the BuildProcess is highly customizable to fit your needs, but what about PlatformSpecifics, you may ask! Out of the box, PlatformSpecifics allows for material swapping, scaling, positioning, font swaps, and text replacement because we found these features to be particularly important when building our own projects. If you have needs beyond this, it is entirely possible to modify any arbitrary property of any arbitrary component per-platform and enjoy the benefits of the automation of the MultiPlatform ToolKit.
See the Custom Text Compatibility section for more information on how to extend that particular are of the MultiPlatform ToolKit.
Note: The aspect ratio calculations currently are based off of landscape orientation. Changing the aspect ratio calculation to divide height by width would allow for support of a portrait-only game. This customization would be near the top of AspectRatios.cs, where aspect4By3Ratio is defined. This would be changed to aspect3By4Ratio and the division would be reversed.
Unsure of how to extend the MultiPlatform ToolKit to your own needs? Shoot us an email! (see below)