コード例 #1
0
    void Awake()
    {
        garland = GetComponent <Garland>();

        currentColors = lightColors.Select(x => (Color32)x).ToArray();
        garland.SetColors(currentColors);
    }
コード例 #2
0
    void Update()
    {
        skippedTime += Time.deltaTime;
        if (skippedTime > updatePeriod)
        {
            skippedTime -= updatePeriod;
        }
        else
        {
            return;
        }

        var phase = Time.time * speed;

        switch (effect)
        {
        case Effect.SmoothTransition:
        {
            var w = Mathf.PI * 2.0f / lightColors.Length;
            for (int i = 0; i < lightColors.Length; ++i)
            {
                currentColors[i] = (Mathf.Sin(w * (i + 1) + phase) + 1) * 0.5f * lightColors[i];
            }
        } break;

        case Effect.RandomFlashes:
        {
            for (int i = 0; i < lightColors.Length; ++i)
            {
                currentColors[i] = Random.Range(0, 2) * lightColors[i];
            }
        }
        break;

        default:
            return;
        }

        garland.SetColors(currentColors);
    }