- Home /
Is there a way to modify sprites on animations during runtime?
I am implementing a pixel game, and I've created scripts that do the following:
Scaling
Load the sprite from the SpriteRenderer.
Resize the Texture to 5x, while keeping the pivot, and rect proportional.
Update the SpriteRenderer with the new sprite (Effectively making the sprite 5x larger).
Outlining.
Load the sprite from the sprite renderer.
Draw an outline of 1px to contour the 5x-scaled sprites.
I've done this so I can use 8x8 sprites to build 40x40 sprites (42x42 when you have an outline), these are executed in the GameObject's Start() Method.
However, if I do this for animations I am at a loss. So I'm wondering if there is a way to apply the same principles above to the textures used by an Animation during runtime.
Something like:
Loading the "Animator a" component from the GameObject.
Loading the animations from the "a.runtimeAnimationController".
Iterating over the states configured in the animation controller, so we can iterate over the frames and scale+outline all the textures...
Of course I would set this up to be executed in the GameObject's Start() method as well.
I would hate having to do it old school if I can actually get something going with what the Unity API has to offer...
Another idea of how to do it would be by actually running the aforementioned Scripts over every sprite as soon as it is loaded into memory, but I don't really figure out how that would be..
,I am implementing a pixel game, and I've created scripts that do the following:
Scaling 1.- Load the sprite from the SpriteRenderer. 2.- Resize the Texture to 5x, while keeping the pivot, and rect proportional. 3.- Update the SpriteRenderer with the new sprite (Effectively making the sprite 5x larger).
Outlining. 1.- Load the sprite from the sprite renderer. 2.- Draw an outline of 1px to contour the 5x-scaled sprites.
I've done this so I can use 8x8 sprites to build 40x40 sprites (42x42 when you have an outline), these are executed in the GameObject's Start() Method.
However, if I do this for animations I am at a loss. So I'm wondering if there is a way to apply the same principles above to the textures used by an Animation during runtime.
Something like:
Loading the "Animator a" component from the GameObject.
Loading the animations from the "a.runtimeAnimationController".
Iterating over the states configured in the animation controller, so we can iterate over the frames and scale+outline all the textures...
Of course I would set this up to be executed in the GameObject's Start() method as well.
I would hate having to do it old school if I can actually get something going with what the Unity API has to offer...
Another idea of how to do it would be by actually running the aforementioned Scripts over every sprite as soon as it is loaded into memory, but I don't really figure out how that would be..
Your answer
![](https://koobas.hobune.stream/wayback/20220612160305im_/https://answers.unity.com/themes/thub/images/avi.jpg)