question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate native Unity sprites

See original GitHub issue

Currently, a custom scriptable object is used to represent diced sprite asset. This leads to multiple complications and issues, like the need to use a custom renderer and the lack of some core native sprite features, like animation and masking support.

The main issue stopping us from switching to the native sprites is the lack of a way to set custom texture UVs to the Sprite objects. This is, alongside with the ability to set custom mesh geometry, is essential to reconstruct the original sprite from the diced atlas texture.

In case someone have an idea how to deal with the issue, or have any info on possible upcoming changes to the Unity’s sprite API, which will allow to set the UVs, please share it in this thread.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:23 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
Elringuscommented, Jul 22, 2019

If I’ve got it right, you’re forcing the atlas to be larger just for the sake of preventing those error when creating sprites? Don’t think that’s a good idea, as the main purpose of this solution it to compress the textures as much as possible. Guess we’d have to either find some other solution or wait for Unity to allow using sprite rects without limitations.

2reactions
Elringuscommented, Jul 21, 2019

Looks like everything is working, but there is one issue. When the sprite rect of a generated sprite is bigger than the atlas texture, Sprite constructor raises ArgumentException: Could not create sprite () from a () texture.: https://github.com/Elringus/SpriteDicing/blob/8b3073a886d4ad858214be24207a0671db9feecd/Assets/SpriteDicing/Editor/DicedSpriteAtlasEditor.cs#L527

It’s possible to provide a fake sprite rect, which is smaller or equal to the atlas texture, but in this case some features would be broken (eg, culling, pivot, editor position and scale tools, etc).

I’ll keep the unity-sprite branch until this is resolved.

Meanwhile, I’ve added asmdef and package.json files to the master branch, so it now can be used with Unity’s package manager.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sprite Creator
Accessing the Sprite Creator. Select Assets > Create > 2D > Sprite and then select the placeholder sprite you want to make (square,...
Read more >
Generating sprites dynamically from PNG or JPEG files in ...
Hey everyone! I was searching the forums here (and some external sources) to find a way to load an external PNG file into...
Read more >
Boosting Unity Game Performance: Sprite Sheet Optimization
Free Tutorial: Create optmized sprite sheets for you Unity game. Reduce overdraw, vertex count and draw calls. Simplify your sprite ...
Read more >
How to make Sprites the same size regardless of pixels per ...
So to replicate this in Unity, we know that on a 1080p monitor, we need a sprite the size of 67 pixels in...
Read more >
Unity - 2D - Draw a sprite with it's "real" size
Is there a way to draw a 10x20px sprite always with 10x20px regardless of the resolution? I don't mean to add it as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found