Scaling sprite with BoxCollider2D attached

Hello.

I’m having an issue when trying to scale a sprite that has a BoxCollider2D attached.
I have tried both adding the collider directly to the sprite, and I have also tried creating a prefab and adding the collider to that instead.
The issue is that when I scale the sprite (Press ‘r’ in the scene view when it is selected and then scale up or down), it appears that the sprite scaled properly and the box collider also appears to scale with it.
However, when I press Play and the game starts, only the collider scaled. The sprite is still the original size even though in the scene view, the sprite is the scaled size.

Does anybody know why this might be happening?

if its animated the collider won’t scale…I used the animation window to scale and move the colliders with the animation

Currently it is not animated at all. It is simply a prefab with a BoxCollider2D, a Rigidbody2D, and a few scripts.

What are these scripts doing?

The sprite I am trying to scale is an enemy.

It contains a character controller (which references the BoxCollider2D for collision purposes), and it has an AI script which deals with when to shoot projectiles at the player.
Those are the only scripts attached to the sprite.

I had a feeling that it had something to do with the character controller since my player also seems to have the same problem if I try to scale him.

The part that is confusing me is that I have prefabs for other objects (my ground, for example), which have box colliders attached to them. If I scale those prefabs, the box collider scales appropriately as well and works exactly as expected.
I am only having trouble with scaling the sprites that have character controllers on them.

Without seeing the sprites i can’t help much more.
But you can try disable one of these scripts and see if the problem persist. If the sprites maintan the scale with the script disable, something in the script is changing it.

That’s the troubling part.
If I disable the BoxCollider2D on the sprite but keep my character controller script on, it still collides with other objects even though it has BoxCollider2D in the Inspector window.

If you disable the character controller script, the sprite and the BoxCollider2D maintain the scale?

The BoxCollider2D always appears to maintain scale in the scene view, but then when the game is started, it reverts back to the original size. Same with the texture.
If I disable the character controller script, gravity and collision will no longer be applied and I won’t be able to test the collision anyway.
I have a feeling the problem is inside the character controller script, but I just don’t understand how. Nowhere am I changing the values of the scale of either the collider or the texture.

Post the character controller script please.
And some screenshots of the problem if you can.

I managed to solve the problem. It turns out that it wasn’t the character controller at all. The problem existed in the one script that I was certain was not the problem the entire time. It turns out that for some reason, in my AI script, I was setting the scale back to 1 whenever the player re-spawns. It is considered a re-spawn the very first time the player spawns too, so it was doing it immediately every time I started the game.
Once I removed that line, everything worked as expected.
Thanks for your help!

Glad you solved the problem.
Like i said before:

I was certain that I had tried disabling each one with different results. I went back and did it again yesterday, which is how I found the issue.
Thanks again.