Search Unity

Tutorial: MultiPlatform Toolkit by Owlchemy Labs

July 18, 2013 in Games | 4 min. read
Topics covered

Is this article helpful for you?

Thank you for your feedback!

The idea of 'Code Once - Deploy Everywhere' has been a Unity development mantra since its inception. With most of the tough porting work handled under the hood by Unity Technologies, porting games has become largely about producing a great user experience. Maintaining a quality product across multiple platforms means resolution independence and support for major aspect ratios.


It means an understanding that writing "Click here" in a mobile game is a huge turn-off for users. It means that standalone users need a quit button while Android users use the hardware back button and iOS users don't need a quit button.

It means that the play button on Retina iPads needs to be scaled up 2x compared to non-retina devices. It means handling all of these platform-specific changes in a graceful, simple way, with a live preview of each platform right in the Unity Editor.

THAT is what Multiplatform Toolkit does best!


So how does it do all of this? Well, lets walk through a quick example.

Let's say you wanted to scale up a button 2x on iPhone to be large enough to hit with our big fat human fingers. The first thing we need to do is attach the PlatformSpecfics component to the button's transform. (Fig. 1)







Fig 1

Then, in the inspector we can choose to tag the object with the appropriate platform-specific data. In this case we want to pick Scale by Platform. (Fig. 2)










Fig. 2

Hit the plus sign and choose iPhone as your platform. In our example, the button already has a (1,1,1) scale, and on iPhones we want it to be (2,2,2). You can manually input the target scale for iPhone or use the get and set buttons to either grab the current value from the transform or apply the selected value to the transform. These help avoid having to copy paste values manually, especially when using the scale tool to eyeball sizes. Make sure to apply the (2,2,2) scale to iPhone Retina as well! It's up to you whether you want this to apply to iPhone 5. It's as simple as adding it as a third option. (Fig. 3)












Fig. 3

Now our button will scale up 2x on iPhone platforms. What? You don't believe me? Well then, let's test it within the Unity editor with our handy platform emulator. Go to the Window menu -> MultiPlatform Toolkit -> EasyPlatform. An editor window will appear. Dock it for easy access. This tool does one thing: lets you pick which platform you'd like to emulate in the Unity Editor. In our case, we want to pick iPhone and then hit Play in the Unity Editor. (Fig. 4)







Fig. 4

The platform-specific changes will occur on Awake() and you won't need to spend minutes doing actual builds to the hardware to test out your changes. It only takes seconds! (Fig. 5)












Fig. 5

This is one tiny example of the ways MultiPlatform Toolkit saves hours upon hours when dealing with platform-specific changes. Let's quickly dig into another code-centric example.

Let's say you wanted to load, at runtime, a small, compressed texture for use as a backdrop in your menus on iPhones, while you wanted to load a huge, 2048x2048px screen backdrop for your Retina iPad and Standalone PC/Mac builds. Easy! The quickest, most seamless way to do this is to Resources.Load() your texture from disk and pick the right one. MPTK makes it as simple as this:

if(Platforms.platform == Platform.iPadRetina || Platform.platform == Platform.Standalone) { //iPad 3, iPad 4, and PC/Mac/Linux
  //load the huge texture
  myRenderer.sharedMaterial.mainTexture = Resources.Load("backgrounds/hugeTexture");
} else { //All other platforms
  //load the tiny texture
  myRenderer.sharedMaterial.mainTexture = Resources.Load("backgrounds/tinyTexture");


Customers have told us that the more they use MultiPlatform Toolkit, the more they wonder how they got by without it. If you're doing any kind of Unity project that involves publishing to multiple targets, feel free to check out our product. We developed it because we needed it for our own games and realized it would be useful for others!

For more information about MultiPlatform Toolkit, check out the Unity Asset Store page  or our product website. Happy publishing!

Back to the Asset Store

July 18, 2013 in Games | 4 min. read

Is this article helpful for you?

Thank you for your feedback!

Topics covered