| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | namespace DCL |
| | 4 | | { |
| | 5 | | public class StickerAnimationListener : MonoBehaviour |
| | 6 | | { |
| | 7 | | private const float WEIGHT_THRESHOLD = 0.5f; |
| | 8 | | private StickersController stickersController; |
| | 9 | |
|
| 0 | 10 | | private void Awake() { stickersController = GetComponentInParent<StickersController>(); } |
| | 11 | |
|
| | 12 | | //It's going to be called through an AnimationEvent |
| | 13 | | private void PlaySticker(AnimationEvent animEvent) |
| | 14 | | { |
| 0 | 15 | | if (string.IsNullOrEmpty(animEvent.stringParameter)) |
| 0 | 16 | | return; |
| | 17 | |
|
| 0 | 18 | | if (animEvent.animationState.weight < WEIGHT_THRESHOLD) |
| 0 | 19 | | return; |
| | 20 | |
|
| 0 | 21 | | stickersController?.PlaySticker(animEvent.stringParameter); |
| 0 | 22 | | } |
| | 23 | | } |
| | 24 | | } |