csharp オバケはDOTween.Sequenceで不透明度変更を缲り返す。倒されたら序列を止める
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp オバケはDOTween.Sequenceで不透明度変更を缲り返す。倒されたら序列を止める相关的知识,希望对你有一定的参考价值。
using UnityEngine;
using DG.Tweening;
using System.Linq;
/// <summary>
/// オバケは DOTween.Sequence で不透明度変更を繰り返す。倒されたら Sequence を止める
/// </summary>
public class EnemyObakeFade : MonoBehaviour, IEnemyBeaten
{
[SerializeField] float minAlpha = 0.2f;
[SerializeField] float maxAlpha = 0.7f;
[SerializeField] float fadeDuration = 1f;
[SerializeField] float appearanceDuration = 3f;
private Sequence sequence;
private void Start ()
{
var renderer = GetComponent<SpriteRenderer>();
var colliders = GetComponents<Collider2D>();
sequence = DOTween.Sequence ()
.Append ( renderer.DOFade ( minAlpha, fadeDuration ) ).SetEase ( Ease.InOutSine )
.AppendCallback ( () => ColliderEnabler ( colliders, false ) )
.AppendInterval ( appearanceDuration )
.Append ( renderer.DOFade ( maxAlpha, fadeDuration ) ).SetEase ( Ease.InOutSine )
.AppendCallback ( () => ColliderEnabler ( colliders, true ) )
.AppendInterval ( appearanceDuration )
.SetLoops ( -1 );
}
private void ColliderEnabler ( Collider2D[] colliders, bool b )
{
foreach ( var collider in colliders ) collider.enabled = b;
}
void IEnemyBeaten.OnBeaten () => sequence.Kill ();
}
以上是关于csharp オバケはDOTween.Sequenceで不透明度変更を缲り返す。倒されたら序列を止める的主要内容,如果未能解决你的问题,请参考以下文章
csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertWithCustomInputDataHandler.cs
csharp 例如-CSHARP-GroupDocs.Conversion.Examples.CSharp - 程序 - ConvertFilesToDifferentFormats.cs
csharp 例如-CSHARP-GroupDocs.Conversion.Examples.CSharp渲染,RenderPSDImageAsPath.cs
csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs
csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs
csharp 实例-CSHARP-GroupDocs.Conversion.Examples.CSharp变频-ConvertTopresentationAsPath.cs