TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Unity 2D Sprite Sheet

Unity 2D Sprite Sheet with Introduction, Installing, GameObject, First Unity Project, Unity 2D, Sprite Unity, Loops, If Statement, Data Types, Swith Statements, Unity UI, Unity Asset Store etc.

<< Back to UNITY

2D Sprite Sheet

In a nutshell, a sprite sheet is a way of packing images together as one image, which is then used to create animations and sprite graphics as it will use low memory and increase the performance of games.

Creating GameObject and Adding Components

  • First of all, we need a GameObject in our scene. For this Right Click on the Hierarchy tab and select Create Empty.
2D Sprite Sheet
  • Rename the new GameObject. Here, we renamed it to Player.
  • Select the Player GameObject and Go to the Inspector tab. In the Inspector tab, click the Add Component button. Choose miscellaneous -> Animator. Make sure to choose Animator nor Animation.
2D Sprite Sheet
  • Add another component, RigidBody2D. For this, click on the Add Component button and choose Physics 2D -> Rigidbody 2D.
2D Sprite Sheet
  • Now, in the Rigidbody 2D component, set the Gravity Scale to zero.
2D Sprite Sheet

Importing the Sprite Sheet

  • First of all, download the sprite sheet that contains all the frames of animation for a simple walking animation. A link is given below from where you can download: ken-sprite-sheet.png
  • Right-click on the Assets and select Import New Asset...
2D Sprite Sheet
  • Browse to the sprite sheet image you downloaded and click the import button.
2D Sprite Sheet
  • Select this imported Asset, and in the Inspector window, change the Sprite mode option from Single to Multiple. Click the Apply button in the Inspector tab.
2D Sprite Sheet

Now Unity will treat ken-sprite-sheet.png as a sprite sheet with multiple frames of animation.

Slicing Sprite Sheet

  • Go to the Windows menu and select 2D -> Sprite Editor.
2D Sprite Sheet
  • Drag the Sprite Editor window and dock it. I docked mine alongside the Console tab.
2D Sprite Sheet
  • Click on the Slice drop-down, and here we can see that the options Automatic, Centre, and Delete Existing are default chosen. Some sprite-sheets have their images ordered in different ways. That is why there are a number of options to choose from.

Here I changed the Pivot value from Centre to Bottom. When you change the Pivot to Bottom means it sets the pivot point to the center bottom of the sprite, and slicing Type in this particular case should be set to be automatic.

2D Sprite Sheet
  • Then click on the Slice button. Unity has now separated all the sprites. Each sprite should have its own bounding box, clicking them provide information on each sprite and allow fine-tuning of sizes and pivot points.
2D Sprite Sheet
  • Now, click on Apply in the top right corner of the Sprite Editor window.
2D Sprite Sheet
  • Select the Player object in the Hierarchy tab and then in the Inspector tab click on Add Component button. Then select Rendering -> Sprite Renderer.
2D Sprite Sheet
  • Finally, you will be able to see all of your Sprites as an individual object in the Project -> Assets Folder.
2D Sprite Sheet




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf