{"id":13661894,"url":"https://github.com/DaVikingCode/UnityRuntimeSpriteSheetsGenerator","last_synced_at":"2025-04-25T06:30:42.771Z","repository":{"id":147844902,"uuid":"79228856","full_name":"DaVikingCode/UnityRuntimeSpriteSheetsGenerator","owner":"DaVikingCode","description":"Unity – generate SpriteSheets at runtime!","archived":false,"fork":false,"pushed_at":"2020-09-23T09:20:04.000Z","size":212,"stargazers_count":558,"open_issues_count":1,"forks_count":143,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-11-10T17:45:21.378Z","etag":null,"topics":["runtime","spritesheets","unity"],"latest_commit_sha":null,"homepage":"http://davikingcode.com/blog/unity-generate-spritesheets-at-runtime/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DaVikingCode.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-01-17T13:11:07.000Z","updated_at":"2024-11-05T08:23:52.000Z","dependencies_parsed_at":"2023-05-27T16:45:12.337Z","dependency_job_id":null,"html_url":"https://github.com/DaVikingCode/UnityRuntimeSpriteSheetsGenerator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaVikingCode%2FUnityRuntimeSpriteSheetsGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaVikingCode%2FUnityRuntimeSpriteSheetsGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaVikingCode%2FUnityRuntimeSpriteSheetsGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaVikingCode%2FUnityRuntimeSpriteSheetsGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DaVikingCode","download_url":"https://codeload.github.com/DaVikingCode/UnityRuntimeSpriteSheetsGenerator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250767005,"owners_count":21483905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["runtime","spritesheets","unity"],"created_at":"2024-08-02T05:01:43.668Z","updated_at":"2025-04-25T06:30:42.006Z","avatar_url":"https://github.com/DaVikingCode.png","language":"C#","readme":"Unity Runtime SpriteSheets Generator\n====================================\n\nUnity 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.\n\nThe RectanglePacking algorithm is a port of the AS3 version made by [Ville Koskela](https://github.com/villekoskelaorg/RectanglePacking). Assets used in the demo come from [Kenney](http://kenney.nl/).\n\nYou could combine the generated Sprite Sheets.png with a [pngquant](https://pngquant.org/) compression via this script [PngQuantNativeProcess](https://github.com/DaVikingCode/PngQuantNativeProcess).\n\nPlease note that Unity provides a [Texture2D.PackTextures method](https://docs.unity3d.com/ScriptReference/Texture2D.PackTextures.html), I didn't test it nor made benchmark performances.\n\nExample:\n--------\nAdd the `AssetPacker` component to your GameObject:  \n![AssetPacker](http://davikingcode.com/blog/wp-content/uploads/2017/01/AssetPacker.png)\n```csharp\nusing DaVikingCode.AssetPacker;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.IO;\nusing UnityEngine;\nusing UnityEngine.UI;\n\npublic class AssetPackerExample : MonoBehaviour {\n\t\n\tpublic Image anim;\n\n\tAssetPacker assetPacker;\n\t\n\tvoid Start () {\n\n\t\tstring[] files = Directory.GetFiles(Application.persistentDataPath + \"/Textures\", \"*.png\");\n\n\t\tassetPacker = GetComponent\u003cAssetPacker\u003e();\n\n\t\tassetPacker.OnProcessCompleted.AddListener(LaunchAnimations);\n\n\t\tassetPacker.AddTexturesToPack(files);\n\t\tassetPacker.Process();\n\t}\n\n\tvoid LaunchAnimations() {\n\n\t\tStartCoroutine(LoadAnimation());\n\t}\n\n\tIEnumerator LoadAnimation() {\n\n\t\tSprite[] sprites = assetPacker.GetSprites(\"walking\");\n\n\t\tint i = 0;\n\t\twhile (i \u003c sprites.Length) {\n\n\t\t\tanim.sprite = sprites[i++];\n\n\t\t\tyield return new WaitForSeconds(0.1f);\n\n\t\t\t// loop\n\t\t\tif (i == sprites.Length)\n\t\t\t\ti = 0;\n\t\t}\n\t}\n}\n\n```\n","funding_links":[],"categories":["C\\#"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaVikingCode%2FUnityRuntimeSpriteSheetsGenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDaVikingCode%2FUnityRuntimeSpriteSheetsGenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaVikingCode%2FUnityRuntimeSpriteSheetsGenerator/lists"}