Home

Awesome

NSprites Foundation

This package provides various solutions for Unity DOTS sprite rendering based on the NSprites package. While NSprites tries to be a flexible solution for all of your 2D sprite rendering needs, this project is more like a set of samples and useful tools. These tools may or may not be perfect for your use-case.

How to Use

I would recommend downloading this as an embedded package and adapting it to your needs. You can use most parts separately except those which depend on each other (details below). You can also implement your own tools on top of those or from scratch looking here for an example.

Also, before working with this package please read the NSprites documentation to understand what is going on (or use this package without editing :D).

Package Contents

namerunningdescription
ComponentsruntimeContains components to be used with NSprites
AuthoringeditorBakes basic render data, uses all other parts
Render data registrationruntimeRegister render data for NSprites render system
SortingruntimeCalculate SortingValue depending on 2D position to use in shader
CullingruntimeDisables or Enables rendering based on 2D position relative to the camera (disabled by default due to performance)
AnimationruntimeShifts UV values to simulate sprite animation
GraphicsruntimeProvides shaders / materials / other render assets

Installation

Requirements

Install via Package Manager

Install via git submodule

Install via .unitypackage (recommended)

Quick Start

This guide will help you create a new project using NSprites Foundation, and render a single sprite to ensure the system is working.

  1. Create a new project using one of the supported Unity versions listed above. Make sure to use the 3D Cross-Platform URP template. The 2D URP project template is incompatible with the built-in shader in NSprites Foundation.
  2. Add NSprites to the project, using one of the recommended install methods. This will also automatically add the required ECS/DOTS packages to the repository if they have not yet been added.
  3. Add NSprites Foundation to the project, using one of the recommended install methods.
  4. Typically, it's a good idea to restart Unity at this point since you've sometimes added/updated Burst.
  5. Change the main camera to Orthographic view. Perspective view is incompatible with the built-in culling system. You may also want to change the scene view to 2D.
  6. In the current scene, add a subscene for entity baking, and into that subscene, add a blank game object.
  7. On this default game object, add a new component of type Sprite Renderer Authoring.
  8. On this new component, set the required fields:
    • Set the Sprite field to either a built-in sprite or one of your own sprites!
    • Set the Sprite Render Data / Material to the included RegularSprite_Material
    • Set the Sprite Render Data / Properties Set to the included RegularSprite_PropertiesSet
  9. Make sure all sprites which uses same basic authoring assets (which makes them use same RenderArchetype) are one the same texture. If they not then use any atlasing tool.
  10. Press play and make sure your sprite shows up!

Good to Know