{"id":13786440,"url":"https://github.com/paullj/unity-ecs-instanced-sprite-renderer","last_synced_at":"2025-04-14T22:23:05.700Z","repository":{"id":115826351,"uuid":"128260964","full_name":"paullj/unity-ecs-instanced-sprite-renderer","owner":"paullj","description":"An example of a simple performant sprite renderer using Unity's new ECS system","archived":false,"fork":false,"pushed_at":"2019-06-21T17:22:54.000Z","size":59,"stargazers_count":138,"open_issues_count":7,"forks_count":22,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-28T10:21:23.661Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/paullj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-04-05T20:31:32.000Z","updated_at":"2024-08-16T06:59:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"779c79db-3709-4cde-b498-dda49ecbd936","html_url":"https://github.com/paullj/unity-ecs-instanced-sprite-renderer","commit_stats":null,"previous_names":["toinfiniityandbeyond/ecs-instanced-sprite-renderer"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paullj%2Funity-ecs-instanced-sprite-renderer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paullj%2Funity-ecs-instanced-sprite-renderer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paullj%2Funity-ecs-instanced-sprite-renderer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paullj%2Funity-ecs-instanced-sprite-renderer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paullj","download_url":"https://codeload.github.com/paullj/unity-ecs-instanced-sprite-renderer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248969626,"owners_count":21191296,"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":[],"created_at":"2024-08-03T19:01:15.870Z","updated_at":"2025-04-14T22:23:05.677Z","avatar_url":"https://github.com/paullj.png","language":"C#","funding_links":[],"categories":[":space_invader: 2D \u003ca name=\"2d\"\u003e\u003c/a\u003e","C#","ECS","Game Development"],"sub_categories":["Unity Engine: Resources"],"readme":"# Instanced Sprite Renderer for Unity's ECS\n\nThis project is a simple example of how Unity's new Entity Component System (ECS) in 2018.1.14f1 can be used to create a performant instanced sprite renderer. Find out about the [new ECS in Unity here](https://github.com/Unity-Technologies/EntityComponentSystemSamples).\n\nThe assets used in the example are from [Kenney's Animal Pack](https://kenney.nl/).\nThanks to [@Shinao](https://www.reddit.com/user/Shinao) for the help. \n\n## Quick Start\n1. Make sure you have [this version of Unity 2018.1.0b12](https://beta.unity3d.com/download/ed1bf90b40e6/public_download.html) installed\n2. Make sure the manifest.json file located at `.../[PROJECT FOLDER]/Packages/manifest.json` looks like this:\n```\n{\n  \"dependencies\": {\n      \"com.unity.entities\": \"0.0.12-preview.19\",\n      \"com.unity.package-manager-ui\": \"1.9.11\",\n      \"com.unity.modules.ui\": \"1.0.0\"\n    },\n    \"testables\": [\n      \"com.unity.collections\",\n      \"com.unity.entities\",\n      \"com.unity.jobs\"\n    ],\n}\n```\n3. Download [this .unitypackage file](https://github.com/toinfiniityandbeyond/ecs-instanced-sprite-renderer/releases/download/0.2/ECS.Instanced.Sprite.Renderer.unitypackage) and import it.\n4. Open **SpriteRendererScene** and press play.\n\n## How it Works\nBy adding `SpriteInstanceRenderer` to an entity it is rendered using its `Position` and `Rotation` as a quad with a texture on it.  The `SpriteInstanceRender` inherits `ISharedComponentData` meaning any entity using same instance of will be drawn in one draw call. This is possible because of [Graphics.DrawMeshInstanced](https://docs.unity3d.com/ScriptReference/Graphics.DrawMeshInstanced.html) method. In the Example Scene included, 10,000 sprites are drawn. However the before mentioned method only draws a maximum of 1023 instances at once, so it splits up into as many groups necessary to draw all the instances.\n\n## Limitations\n* No way to push the matrices from a job\n* No NativeArray API, currently uses `Matrix4x4[]`\n\nAs a result this code is not yet jobified. For now, we have to copy our data into Matrix4x4[] with a specific upper limit of how many instances we can render in one batch.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaullj%2Funity-ecs-instanced-sprite-renderer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaullj%2Funity-ecs-instanced-sprite-renderer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaullj%2Funity-ecs-instanced-sprite-renderer/lists"}