Platform Specific Sprite Collection with Unity 2dToolkit

When working on platforms with different resolutions, it’s common to have assets prepared for them with different sizes. For example, you might have a 320×480(1x) background image for iPhone 3GS, 640×960(2x) for iPhone 4G retina display and 1280*1920 for iPad3. With 2dToolkit, managing these assets become a breeze. In this tutorial, we’re going to use 2dToolkit’s Platform Specific Sprite Collection and Camera Override to solve this problem.

Setup your scene with 1x assets

When swapping sprites with Platform Specific Sprite Collection, 2dToolkit will maintain the size of sprite as the same. So it’s better to setup your scene with 1x sprites.

Import your high-quality assets with correct asset path

Make sure all assets in the sprite collection have corresponding high-quality version(2x, 4x) and correct file path. Check documentation for more information.

Enable multiple platform support of sprite collection

Just follow the “Ideal Workflow" in the documentation

Setup a empty scene before other scenes in your game

In order to make 2dToolkit swap the sprite collection to the one with better quality assets, you have to tell it to do so BEFORE any sprite being loaded into memory. Therefore, the easiest way to do so is prepare an empty scene before your game and put the following script into it:

using UnityEngine;
using System.Collections;

public class ResolutionSetting : MonoBehaviour {
	void Awake () {
		tk2dSystem.CurrentPlatform = "2x"; // Or 4x, based on the resolution of your target device
		Application.LoadLevel("YOUR STARTING SCENE");

Setup the tk2dCamera resolution override

tk2dCamera can automatically scale the game to fit the resolution of target device. You can set it up like mine or trying out different settings by yourself:


Since we’re setting up the game with assets having the lowest quality, we set the Native Resolution to the target resolution of your lowest quality assets. In this case, It’s 320×480.

The most important setting is the “Pixel Perfect Fit" of Auto Scale. Combine with platform specific sprite collection, it will maintain the pixel perfect of your game and stretch the game’s resolution to fit the screen, leaving some letterbox space if not possible.

Bonus: enable Force Editor Resolution to show the correct resolution in unity’s game view

tk2dCamera comes with a setting called “Force Editor Resolution“. Unity’s game view won’t display in the correct resolution if you don’t enable it.