(Unity)一定時間ごとにオブジェクトが透明と不透明を繰り返す

(フレームの更新を利用するプログラム)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Appear : MonoBehaviour
{
    private MeshRenderer ms;
    private int count;
    private bool isOn = true;

    void Start()
    {
        ms = GetComponent<MeshRenderer>();
    }

    void Update()
    {
        count += 1;

        if (count % 150 == 0)
        {
            if (isOn)
            {
                ms.enabled = false;
                isOn = false;
            }
            else if (!isOn)
            {
                ms.enabled = true;
                isOn = true;
            }
        }
    }
}

(コルーチンを利用するプログラム)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Appear : MonoBehaviour
{
    private MeshRenderer ms;
   
    void Start()
    {
        ms = GetComponent<MeshRenderer>();
        StartCoroutine(MeshSwitch());
    }

    private IEnumerator MeshSwitch()
    {
        while(true)
        {
            yield return new WaitForSeconds(1f);

            ms.enabled = false;

            yield return new WaitForSeconds(1f);

            ms.enabled = true;
        }
    }
}