Unity – generate SpriteSheets at runtime!
Switch branches/tags
Nothing to show
Clone or download
Latest commit b9be43a Feb 2, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
Assets Typo fix Jan 25, 2017
ProjectSettings Corrected build path Jan 20, 2017
.gitignore Prevent creating new texture each time! Jan 25, 2017
README.MD Update README.MD Feb 2, 2017


Unity Runtime SpriteSheets Generator

Unity and plugins provide many great ways to build Sprite Sheets. However they're used directly into Unity Editor or with an external software which is perfect in many case, but none provide the ability to generate SpriteSheets at runtime.

The RectanglePacking algorithm is a port of the AS3 version made by Ville Koskela. Assets used in the demo come from Kenney.

You could combine the generated Sprite Sheets.png with a pngquant compression via this script PngQuantNativeProcess.


Add the AssetPacker component to your GameObject:

using DaVikingCode.AssetPacker;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;

public class AssetPackerExample : MonoBehaviour {
	public Image anim;

	AssetPacker assetPacker;
	void Start () {

		string[] files = Directory.GetFiles(Application.persistentDataPath + "/Textures", "*.png");

		assetPacker = GetComponent<AssetPacker>();



	void LaunchAnimations() {


	IEnumerator LoadAnimation() {

		Sprite[] sprites = assetPacker.GetSprites("walking");

		int j = 0;
		while (j < sprites.Length) {

			anim.sprite = sprites[j++];

			yield return new WaitForSeconds(0.1f);

			if (j == sprites.Length)
				j = 0;