Что такое sprite в unity

Sprites

Sprites are 2D Graphic objects. If you are used to working in 3D, Sprites are essentially just standard textures but there are special techniques for combining and managing sprite textures for efficiency and convenience during development.

See Importing and Setting up Sprites below for information on setting up assets as Sprites in your Unity project.

Sprite Tools

Sprite Creator

Use the Sprite Creator to create placeholder sprites in your project, so you can carry on with development without having to source or wait for graphics.

Sprite Editor

The Sprite Editor lets you extract sprite graphics from a larger image and edit a number of component images within a single texture in your image editor. You could use this, for example, to keep the arms, legs and body of a character as separate elements within one image.

Sprite Renderer

Sprites are rendered with a Sprite Renderer component rather than the Mesh Renderer used with 3D objects. Use it to display images as Sprites for use in both 2D and 3D scenes.

Sprite Packer

Use Sprite Packer to opimize the use and performance of video memory by your project.

Importing and Setting Up Sprites

Sprites are a type of Asset in Unity projects. You can see them, ready to use, via the Project View.

There are two ways to bring Sprites into your project:

In your computer’s Finder (Mac OS X) or File Explorer (Windows), place your image directly into your Unity project’s Assets folder.

Unity detects this and displays it in your project’s Project View.

In Unity, go to Assets>Import New Asset… to bring up your computer’s Finder (Mac OS X) or File Explorer (Windows).

From there, select the image you want, and Unity puts it in the Project View.

See Importing Assets for more details on this and important information about organising your Assets folder.

Setting your Image as a Sprite

If your project mode is set to 2D, the image you import is automatically set as a Sprite.

However, if your project mode is set to 3D, your image is set as a Texture, so you need to change the asset’s Texture Type:

Click on the asset to see its Import Inspector.

Set the Texture Type to Sprite (2D and UI).

(See Fig 1: Set Texture Type….)

See 2D or 3D Projects for details on setting your project mode to 2D.

Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unityFig 1: Set Texture Type to Sprite (2D and UI) in the asset’s inspector

Источник

Спрайты в Unity: определение, как их создавать и использовать

Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

Как создать спрайт для Unity? Для этого в игровом движке предусмотрены свои инструменты, о которых мы поговорим чуть ниже.

В Unity работа со спрайтами внедрена по умолчанию, когда движок настроен на разработку 2D-игр. Если спрайт посмотреть в 3D-режиме, тогда он окажется «плоским», как лист бумаги. Все потому, что спрайт — это 2D-объект и у него нет Z-ширины.

Как создать спрайт для Unity

Когда на Unity создается новый спрайт, ему необходимо задать текстуру. Текстура — это изображение, которое отражает внешний вид спрайта. Такое изображение прикрепляется к спрайту, создавая GameObject, который можно использовать в игре.

Если нет возможности сразу добавить текстуру в проект, но наличие спрайта в игре вам обязательно, тогда можно применить «заполнитель спрайтов» на Unity. Заполнитель — это встроенный инструмент, который создает спрайт в виде простых геометрических фигур типа треугольника, квадрата, круга и заполняет их белым цветом. В дальнейшем всегда будет доступно редактирование «заполнителя».

Assets → Create → Sprites

Подход с использованием заполнителей для спрайтов актуален в том случае, когда графика для спрайта не готова, но нужно продолжать разработку проекта.

Редактирование спрайтов в Unity

Создать спрайт для Unity несложно, как это делается — описано чуть выше. Вся сложность заключается в редактировании спрайта. Чем сложнее игровой спрайт и сложнее проект, тем труднее будет редактировать спрайт.

Найти кнопку «Sprite Editor». Вам откроется редактор спрайтов, в котором будет несколько доступных инструментов. Например : изменение масштаба, изменение расцветки, изменение местоположения спрайта на экране, поворот спрайта, настроить прозрачность, обрезать и др.

Средство визуализации спрайтов в Unity

Отобразить спрайт в Unity помогает компонент Sprite Renderer. Его нужно добавлять в GameObject через меню Components:

Components → Rendering → Sprite Renderer

Когда создается 3D-графика, тогда способов отразить объемный объект очень много. Например, внешний вид объекта будет зависеть от его положения на экране, освещенности, перемещения, положения камеры и др. С 2D-объектами этого всего нет.

Заключение

Как создать спрайт для Unity? Добавить спрайт в Unity несложно. Спрайт — это анимированная картинка, состоящая из множества кадров. О подготовке спрайта для Unity нужно позаботит ь ся заранее. Благо для этого есть много программ. Например:

Источник

Работа со спрайтами (Unity3d)

Введение

Всем привет.
Вначале небольшой экскурс.
Эта статья является своеобразным переводом обучающей программы от Jesse Freeman. Ему спасибо за мою теперешнюю возможность получить инвайт. Остальным спасибо за понимание, что это моя первая статья.
В утопическом мире населенном только хабралюдьми, я постараюсь сделать так, чтобы за этой статьей последовало еще 9, но мир не идеален, так что пока не известно как всё пойдет. Вроде всё, тогда поехали.

Импортирование спрайтов

Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

Отлично, теперь перетащим спрайт игрока на сцену, и что мы видим спрайт стал gameobject’ом.
Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

Следующее свойство спрайтов о котором я расскажу называется Pixels To Units. Как вы видите спрайт игрока 80×80 пикселей, а в Unity 100×100 пикселей соответствуют одному квадратному метру, поэтому перейдя к настройкам импорта спрайта в строке Pixels To Units вы увидите значение 100 и это означает, что спрайт отображается корректно.Давайте изменим значение на 80, в таком случае вы увидите, что спрайт игрока увеличился, теперь он занимает равно один юнит квадратный.

Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

Примечание от переводчика для более корректного отображения спрайтов рекомендуется использовать в этом поле значение 100.

Следующее свойство спрайтов о котором я расскажу называется Pivot. Если кратко — это точка привязки. По умолчанию установлена на центр. Вы можете изменить ее в случае необходимости, но в большинстве случае привязка в центре подходит. Здесь обойдемся без иллюстраций.
Едем дальше.

Поле Filter Mode по умолчанию имеет значение Bilinear, но так как у нас Pixel Art нам нужно изменить его значение на Point, после применения изменений вы видите, что спрайт стал выглядеть лучше, но при приближении видны аномалии, для того чтобы избавиться от них изменим значение поля Format на TrueColor.
Теперь спрайт не имеет никаких аномалий. Запомните такие настройки, поскольку их нужно применять каждый раз при работе с Pixel Art’ом.

Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

Внимание:

Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

Возможно следующие уроки будут объемнее, а пока всё.

Источник

Sprites

Sprites are 2D Graphic objects. If you are used to working in 3D, Sprites are essentially just standard textures but there are special techniques for combining and managing sprite textures for efficiency and convenience during development.

See Importing and Setting up Sprites below for information on setting up assets as Sprites in your Unity project.

Sprite Tools

Sprite Creator

Use the Sprite Creator to create placeholder sprites in your project, so you can carry on with development without having to source or wait for graphics.

Sprite Editor

The Sprite Editor lets you extract sprite graphics from a larger image and edit a number of component images within a single texture in your image editor. You could use this, for example, to keep the arms, legs and body of a character as separate elements within one image.

Sprite Renderer

Sprites are rendered with a Sprite Renderer component rather than the Mesh Renderer used with 3D objects. Use it to display images as Sprites for use in both 2D and 3D scenes.

Sprite Packer

Use Sprite Packer to opimize the use and performance of video memory by your project.

Importing and Setting Up Sprites

Sprites are a type of Asset in Unity projects. You can see them, ready to use, via the Project view.

There are two ways to bring Sprites into your project:

In your computer’s Finder (Mac OS X) or File Explorer (Windows), place your image directly into your Unity Project’s Assets folder.

Unity detects this and displays it in your project’s Project view.

In Unity, go to Assets > Import New Asset to bring up your computer’s Finder (Mac OS X) or File Explorer (Windows).

From there, select the image you want, and Unity puts it in the Project view.

See Importing for more details on this and important information about organising your Assets folder.

Setting your Image as a Sprite

If your project mode is set to 2D, the image you import is automatically set as a Sprite. For details on setting your project mode to 2D, see 2D or 3D Projects.

However, if your project mode is set to 3D, your image is set as a Texture, so you need to change the asset’s Texture Type:

For details on Sprite Texture Type settings, see Texture type: Sprite (2D and UI).

Sorting Sprites

Renderers in Unity are sorted by several criteria, such as their Layer order or their distance from the Camera. Unity’s GraphicsSettings (menu: Edit > Project Settings, then select the Graphics category) provide a setting called Transparency Sort Mode, which allows you to control how Sprites are sorted depending on where they are in relation to the Camera. More specifically, it uses the Sprite’s position on an axis to determine which ones are transparent against others, and which are not.

An example of when you might use this setting is to sort Sprites along the Y axis. This is quite common in 2D games, where Sprites that are higher up are sorted behind Sprites that are lower, to make them appear further away.

Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

There are four Transparency Sort Mode options available:

Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

    If you have set the Transparency Sort Mode to Custom, you then need to set the Transparency Sort Axis:

    Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

    If the Transparency Sort Mode is set to Custom Axis, renderers in the Scene view are sorted based on the distance of this axis from the camera. Use a value between –1 and 1 to define the axis. For example: X=0, Y=1, Z=0 sets the axis direction to up. X=1, Y=1, Z=0 sets the axis to a diagonal direction between X and Y.

    For example, if you want Sprites to behave like the ones in the image above (those higher up the y axis standing behind the Sprites that are lower on the axis), set the Transparency Sort Mode to Custom Axis, and set the Y value for the Transparency Sort Axis to a value higher than 0.

    Sorting Sprites using script

    You can also sort Sprites per camera through scripts, by modifying the following properties in Camera:

    TransparencySortMode (corresponds with Transparency Sort Mode)

    TransparencySortAxis (corresponds with Transparency Sort Axis)

    2018–04–25 Page amended with limited editorial review

    2017–05–24 Page amended with no editorial review

    Источник

    Sprites

    Sprites are 2D Graphic objects. If you are used to working in 3D, Sprites are essentially just standard textures but there are special techniques for combining and managing sprite textures for efficiency and convenience during development.

    Unity provides a placeholder Sprite Creator, a built-in Sprite Editor, a Sprite Renderer A component that lets you display images as Sprites for use in both 2D and 3D scenes. More info
    See in Glossary and a Sprite Packer A facility that packs graphics from several sprite textures tightly together within a single texture known as an atlas. Unity provides a Sprite Packer utility to automate the process of generating atlases from the individual sprite textures. More info
    See in Glossary

    See Importing and Setting up Sprites below for information on setting up assets as Sprites in your Unity project.

    Sprite Tools

    Sprite Creator

    Use the Sprite Creator to create placeholder sprites in your project, so you can carry on with development without having to source or wait for graphics.

    Sprite Editor

    The Sprite Editor lets you extract sprite graphics from a larger image and edit a number of component images within a single texture in your image editor. You could use this, for example, to keep the arms, legs and body of a character as separate elements within one image.

    Sprite Renderer

    Sprite Packer

    Use Sprite Packer to optimize the use and performance of video memory by your project.

    Importing and Setting Up Sprites

    Sprites are a type of Asset Any media or data that can be used in your game or project. An asset may come from a file created outside of Unity, such as a 3D Model, an audio file or an image. You can also create some asset types in Unity, such as an Animator Controller, an Audio Mixer or a Render Texture. More info
    See in Glossary in Unity projects. You can see them, ready to use, via the Project In Unity, you use a project to design and develop a game. A project stores all of the files that are related to a game, such as the asset and Scene files. More info
    See in Glossary view.

    There are two ways to bring Sprites into your project:

    In your computer’s Finder (Mac OS X) or File Explorer (Windows), place your image directly into your Unity Project’s Assets folder.

    Unity detects this and displays it in your project’s Project view.

    In Unity, go to Assets > Import New Asset to bring up your computer’s Finder (Mac OS X) or File Explorer (Windows).

    From there, select the image you want, and Unity puts it in the Project view.

    See Importing for more details on this and important information about organising your Assets folder.

    Setting your Image as a Sprite

    If your project mode is set to 2D, the image you import is automatically set as a Sprite. For details on setting your project mode to 2D, see 2D or 3D Projects.

    For details on Sprite Texture Type settings, see Texture type: Sprite (2D and UI).

    Sorting Sprites

    An example of when you might use this setting is to sort Sprites along the Y axis. This is quite common in 2D games, where Sprites that are higher up are sorted behind Sprites that are lower, to make them appear further away.

    Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

    There are four Transparency Sort Mode options available:

    Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

      If you have set the Transparency Sort Mode to Custom, you then need to set the Transparency Sort Axis:

      Что такое sprite в unity. Смотреть фото Что такое sprite в unity. Смотреть картинку Что такое sprite в unity. Картинка про Что такое sprite в unity. Фото Что такое sprite в unity

      If the Transparency Sort Mode is set to Custom Axis, renderers in the Scene view An interactive view into the world you are creating. You use the Scene View to select and position scenery, characters, cameras, lights, and all other types of Game Object. More info
      See in Glossary are sorted based on the distance of this axis from the camera. Use a value between –1 and 1 to define the axis. For example: X=0, Y=1, Z=0 sets the axis direction to up. X=1, Y=1, Z=0 sets the axis to a diagonal direction between X and Y.

      For example, if you want Sprites to behave like the ones in the image above (those higher up the y axis standing behind the Sprites that are lower on the axis), set the Transparency Sort Mode to Custom Axis, and set the Y value for the Transparency Sort Axis to a value higher than 0.

      Sorting Sprites using script

      TransparencySortMode (corresponds with Transparency Sort Mode)

      TransparencySortAxis (corresponds with Transparency Sort Axis)

      Источник

      Добавить комментарий

      Ваш адрес email не будет опубликован. Обязательные поля помечены *