void TryPush() { if (playerIsNear_) { if (ButtonPressedEvent != null) { ButtonPressedEvent.Invoke(); } countdown_ = duration; isAnimating_ = true; GameObject particle = Instantiate(pressParticle); particle.transform.position = transform.position + Vector3.up; } }
void Update() { if (isAnimating_) { countdown_ = countdown_ - Time.deltaTime; if (countdown_ <= 0.0f) { isAnimating_ = false; if (ButtonReleasedEvent != null) { ButtonReleasedEvent.Invoke(); } } countdown_ = Mathf.Clamp(countdown_, 0, duration); buttonRenderer.material.color = Color.Lerp(idleColor, pressedColor, countdown_ / duration); } }