36 lines
841 B
C#
36 lines
841 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Animancer;
|
|
using UnityEngine;
|
|
|
|
namespace BITFALL.Items
|
|
{
|
|
public class AnimatedItemContainer : MonoBehaviour
|
|
{
|
|
[SerializeField] private WorldItemContainer container;
|
|
[SerializeField] private AnimancerComponent animancerComponent;
|
|
[SerializeField] private AnimationClip openClip;
|
|
[SerializeField] private AnimationClip closeClip;
|
|
private void Start()
|
|
{
|
|
container.OnRelease += OnRelease;
|
|
}
|
|
private void OnRelease(bool obj)
|
|
{
|
|
animancerComponent.enabled = true;
|
|
animancerComponent.Stop();
|
|
animancerComponent.enabled = true;
|
|
|
|
var state = animancerComponent.Play(obj ? closeClip : openClip);
|
|
state.Events.OnEnd = OnEnd;
|
|
}
|
|
private void OnEnd()
|
|
{
|
|
animancerComponent.Stop();
|
|
animancerComponent.enabled = false;
|
|
}
|
|
}
|
|
|
|
}
|