37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
namespace RR.Common.Behaviour
|
|
{
|
|
/// <summary>
|
|
/// Действие исчезновения сообщения (масштабирование от startScale до endScale)
|
|
/// </summary>
|
|
[Serializable]
|
|
public class MessageDisappearAction : SequenceAction
|
|
{
|
|
[SerializeField] public float startScale = 1f;
|
|
[SerializeField] public float endScale = 0f;
|
|
[SerializeField] public float transitionSpeed = 1f;
|
|
|
|
public override IEnumerator Execute(Sequencer context, GameObject target)
|
|
{
|
|
if (!target) yield break;
|
|
|
|
target.transform.localScale = new Vector3(startScale, startScale, startScale);
|
|
|
|
while (target.transform.localScale.x > endScale)
|
|
{
|
|
target.transform.localScale = Vector3.MoveTowards(
|
|
target.transform.localScale,
|
|
new Vector3(endScale, endScale, endScale),
|
|
Time.deltaTime * transitionSpeed
|
|
);
|
|
|
|
yield return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|