コード例 #1
0
 private IEnumerator ChangeVolumeTo(float target)
 {
     return(GameUtils.AnimateValue(
                () => _audioSource.volume,
                value => _audioSource.volume = value,
                target,
                VolumeChangeRate));
 }
コード例 #2
0
 private static IEnumerator AnimateAlpha(Graphic gr, float targetValue, float alphaRate)
 {
     return(GameUtils.AnimateValue(
                () => gr.color.a,
                a => gr.color = GameUtils.SetColorAlpha(gr.color, a),
                targetValue,
                alphaRate));
 }
コード例 #3
0
    private IEnumerator HideTip(Text tip)
    {
        yield return(StartCoroutine(GameUtils.AnimateValue(
                                        () => tip.color.a,
                                        v => tip.color = GameUtils.SetColorAlpha(tip.color, v),
                                        0f, TipAlphaRate)));

        tip.gameObject.SetActive(false);
    }
コード例 #4
0
    private IEnumerator ShowTip(Text tip)
    {
        yield return(HideAllTips());

        tip.gameObject.SetActive(true);
        tip.color = GameUtils.SetColorAlpha(tip.color, 0f);

        yield return(StartCoroutine(GameUtils.AnimateValue(
                                        () => tip.color.a,
                                        v => tip.color = GameUtils.SetColorAlpha(tip.color, v),
                                        TipAlpha, TipAlphaRate)));
    }
コード例 #5
0
        private IEnumerator SetLightState(Light lightComponent, float initIntensity, bool state)
        {
            const float tolerance = 0.01f;

            if (lightComponent.gameObject.activeSelf == state &&
                Math.Abs(lightComponent.intensity - initIntensity) < tolerance)
            {
                yield break;
            }

            float target = state ? initIntensity : 0f;

            lightComponent.gameObject.SetActive(true);

            yield return(StartCoroutine(GameUtils.AnimateValue(
                                            () => lightComponent.intensity,
                                            v => lightComponent.intensity = v,
                                            target, 0.04f)));

            lightComponent.gameObject.SetActive(state);
        }