private void Update() { // SEの音量を設定. m_seSource.volume = m_defaultSEVolume; // BGMのフェード処理. if (m_fadeTime > 0f) { m_volumeRate += Time.deltaTime * m_multiply / m_fadeTime; m_volumeRate = Mathf.Clamp01(m_volumeRate); } else { m_volumeRate = (m_nextBGM == null) ? 1f : 0f; } // BGMの音量が0になったら、次のBGMに切り替え. if (m_volumeRate == 0f && m_nextBGM != null) { m_bgmSource.clip = m_nextBGM; m_bgmSource.Play(); m_multiply = 1f; m_nextBGM = null; } m_bgmSource.loop = m_loop; m_bgmSource.volume = Mathf.Lerp(0f, m_defaultBGMVolume, m_fadeCurve.Evaluate(m_volumeRate)); }
public IEnumerator PlayEffect(Vector2Int position, float delay, Action callback = null) { m_transform = m_transform ?? transform; m_transform.position = new Vector3(position.x, position.y, 0f); var startPos = m_transform.position + Vector3.up * m_moveRangeY.x; var endPos = m_transform.position + Vector3.up * m_moveRangeY.y; m_transform.localScale = m_start; yield return(new WaitForSeconds(delay)); //終わりを合わせるための再生速度の計算 var notWaitAnimTime = 1 / m_animationSpeed; var calcedAnimTime = notWaitAnimTime - delay; var calcedAnimSpeedRate = 1 / calcedAnimTime; float t = 0f; while (t < 1f) { t += Time.deltaTime * calcedAnimSpeedRate; m_transform.position = Vector3.LerpUnclamped(startPos, endPos, m_movingCurve.Evaluate(t)); m_transform.localScale = Vector3.LerpUnclamped(m_start, m_end, m_curve.Evaluate(t)); yield return(null); } m_transform.localScale = m_end; callback?.Invoke(); }
private IEnumerator SetAlphaCoroutine(float startAlpha, float endAlpha, bool activeAtEnd = true) { Image.gameObject.SetActive(true); SetAlpha(startAlpha); float timer = 0f; while (timer < m_fadeTime) { timer += Time.deltaTime; SetAlpha(m_curve.Evaluate(Mathf.Lerp(startAlpha, endAlpha, timer / m_fadeTime))); yield return(null); } SetAlpha(endAlpha); Image.gameObject.SetActive(activeAtEnd); }
IEnumerator StartAnim() { transform.localScale = m_start; var waittime = UnityEngine.Random.Range(m_beforeNoiseRenge.x, m_beforeNoiseRenge.y); yield return(new WaitForSeconds(waittime)); //終わりを合わせるための再生速度の計算 var notWaitAnimTime = 1 / m_animationSpeed; var calcedAnimTime = notWaitAnimTime - waittime; var calcedAnimSpeedRate = 1 / calcedAnimTime; PlaySE(); float t = 0f; while (t < 1f) { t += Time.deltaTime * calcedAnimSpeedRate; transform.localScale = Vector3.LerpUnclamped(m_start, m_end, m_curve.Evaluate(t)); yield return(null); } transform.localScale = m_end; }
public T Update() { if (!EqualityComparer <T> .Default.Equals(TargetValue, m_targetValue)) { Initialize(m_currentValue); } m_timer += Time.deltaTime; m_currentValue = (m_timer >= m_duration) ? TargetValue : Lerp(m_startValue, m_targetValue, m_curve.Evaluate(Mathf.Clamp01(m_timer / m_duration))); return(m_currentValue); }
private T Interpolate(T start, T end, float t) { return(Lerp(start, end, m_curve.Evaluate(t))); }
private T GetCurrentValue() { float rate = Mathf.Clamp01(m_timer / m_duration); return(Lerp(m_startValue, m_targetValue, m_curve.Evaluate(rate))); }
public IEnumerator Animation() { while (NowAnimation) { yield return(null); } NowAnimation = true; targetRectTr.localPosition = m_start_slideIn; float t = 0f; while (t < 1f) { t += Time.deltaTime * m_animationSpeed; targetRectTr.localPosition = Vector3.LerpUnclamped(m_start_slideIn, m_end_slideIn, m_curve.Evaluate(t)); yield return(null); } targetRectTr.localPosition = m_end_slideIn; yield return(null); NowAnimation = false; }
private IEnumerator MoveCoroutine() { float timer = 0f; while (timer < m_time) { timer += Time.deltaTime; float rate = Mathf.Clamp01(timer / m_time); m_transform.position = Vector3.LerpUnclamped(m_startPositon, m_startPositon + m_movement, m_curve.Evaluate(rate)); yield return(null); } m_transform.position = m_startPositon; gameObject.SetActive(false); }