Create palpitating effect C#

I am creating a winner screen after the game is finished. I want an image in UI to palpitate while this screen is displayed. I tried using the Update method but it does it very fast. Does somebody know how to create such effect?

That is the actual code I have been using to test the change in the width.

float width = 100;
bool maxSize = false;

void Update()
{
    Resize();
}

void Resize()
{
    if (maxSize == false)
    {
        for (float i = 0f; i <= 4; i += 0.1f)
        {
            width += i;
            GameObject crown = GameObject.Find("Canvas/Crown");
            RectTransform objectRectTran = crown.transform as RectTransform;
            objectRectTran.sizeDelta = new Vector2(width, objectRectTran.sizeDelta.y);
        }
        maxSize = true;
    }
    else
    {
        
        for (float i = 4f; i >= 0; i -= 0.1f)
        {
            width -= i;
            GameObject crown = GameObject.Find("Canvas/Crown");
            RectTransform objectRectTran = crown.transform as RectTransform;
            objectRectTran.sizeDelta = new Vector2(width, objectRectTran.sizeDelta.y);
        }
        maxSize = false;
    }
}

You can use co routines

bool stillGoing = true;
void Start ()
    {
        StartCoroutine(MyCoroutine(1));
    }


IEnumerator MyCoroutine (float seconds)
{
    
    yield return new WaitForSeconds(seconds);

   if(StillGoing)
     StartCoroutine(MyCoroutine(seconds));
}

Then you can just set StillGoing to false when you want it to end

The question isn’t really clear what you actually want to “palpitate”. Do you want the color, the size / scale or the position to change? The easiest way to get a non-linear behaviour to the change is to use an AnimationCurve.

Just something like this:

public AnimationCurve palpitate;
public float speed = 1f;

void Update()
{
    transform.localScale = Vector3.one * palpitate.Evaluate(Time.time * speed);
}

If you want to change the color of an UI image you can use Color.Lerp:

public UnityEngine.UI.Image image;
public Color baseColor = Color.white;
public Color strongColor = Color.red;

void Update()
{
    image.color = Color.Lerp(baseColor, strongColor, palpitate.Evaluate(Time.time * speed));
}

Make sure your used curve does loop on the right so you get a continuous change. Something like this:

Assuming you are modifying the transform of the GameObject, you could simply multiply the intended rate of transform by Time.deltaTime.

As you didn’t provide any code to work with, I’ll provide my falling object code as an example:

void Update()
{
    var y = hitPosition.y - (2 * Time.deltaTime);
    if (y > -0.1f)
    {
        transform.position = new Vector3(hitPosition.x, y, hitPosition.z);
        hitPosition = transform.position;
    }
}