When scaling a sprite, we use this sprite in the formula itself.

//Идет присвоение в методе, без этого никак - у нас не один спрайт. backStationaryCircle = back; //Берем координаты правой верхней и левой нижней точки спрайта,вычитая их - получаем размер var radiusX = (back.CurrentSprite.positions[3].x - back.CurrentSprite.positions[0].x)/2; var radiusY = (back.CurrentSprite.positions[3].y - back.CurrentSprite.positions[0].y)/2; //Меняем размер спрайта backStationaryCircle.scale = new Vector3(((workZoneInPixX / back.scale.x) / radiusX), ((workZoneInPixY / back.scale.y) / radiusY), 0.001f); 

And at the next iteration we work with a resized sprite. And we don’t need it, we just need to take the size of the sprite initially and use it as a variable, no matter how it changes during the transformation.

  • It is not clear what prevents you from working directly with the size values - eastwing
  • one
    xs, can have, for example, a dictionary Dictionary<GameObject, float> in which the reference to the object and the initial size. The object appears - is added to it, destroyed - is killed and from the dictionary too. - Alexey Shimansky

1 answer 1

Everything, as always, is simpler than it seems. Remove the original values ​​in the Start () method; or any other that is called only 1 time. Then we use them as we want - taken once, they do not change.