Generate native Unity sprites
See original GitHub issueCurrently, 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:
- Created 5 years ago
- Reactions:1
- Comments:23 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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 raisesArgumentException: Could not create sprite () from a () texture.
: https://github.com/Elringus/SpriteDicing/blob/8b3073a886d4ad858214be24207a0671db9feecd/Assets/SpriteDicing/Editor/DicedSpriteAtlasEditor.cs#L527It’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.