SinScale.cs 612 Bytes
using UnityEngine;
using System.Collections;

public class SinScale : MonoBehaviour
{
    public Vector3 amount;
    public float speed;
    public bool randomStartPos;

    private float _timer = 0;
    private Vector3 _lastSin;

    void Start()
    {
        if (randomStartPos)
            _timer = Random.Range(0.0f, 10.0f);
    }

	void LateUpdate ()
    {
        float sin = Mathf.Sin(_timer * speed);
        Vector3 thisSin = amount * sin;
        Vector3 sinDelta = thisSin - _lastSin;
        _lastSin = thisSin;
        transform.localScale += sinDelta;
        _timer += Time.deltaTime;
    }
}