「Unity/おすすめアセット/紙吹雪」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→kayacの紙吹雪) |
|||
(同じ利用者による、間の2版が非表示) | |||
行1: | 行1: | ||
==kayacの紙吹雪== | ==kayacの紙吹雪== | ||
# https://techblog.kayac.com/unity-physically-simulated-confetti にあるunitypackageを入れる | # https://techblog.kayac.com/unity-physically-simulated-confetti にあるunitypackageを入れる | ||
− | # prefab/ | + | # prefab/Confettiをシーンに置く |
− | # | + | # Confetti.csを空オブジェクトにAddComponentする |
公式:https://techblog.kayac.com/unity-physically-simulated-confetti | 公式:https://techblog.kayac.com/unity-physically-simulated-confetti | ||
行25: | 行25: | ||
{ | { | ||
confettiObject.GetComponent<Confetti>().EmitPiecePerSecond = 0; | confettiObject.GetComponent<Confetti>().EmitPiecePerSecond = 0; | ||
+ | Destroy(confettiObject, 5f); | ||
Confetti(); | Confetti(); | ||
}); | }); |
2022年3月20日 (日) 10:33時点における最新版
kayacの紙吹雪
- https://techblog.kayac.com/unity-physically-simulated-confetti にあるunitypackageを入れる
- prefab/Confettiをシーンに置く
- Confetti.csを空オブジェクトにAddComponentする
公式:https://techblog.kayac.com/unity-physically-simulated-confetti
5秒ごとに紙吹雪花火サンプル(Dotween必須)
void Confetti() { GameObject prefab = playRunView.confettiPrefab; GameObject confettiObject = Instantiate(prefab, Vector3.zero, Quaternion.identity); confettiObject.transform.localScale = new Vector3(0.03f, 0.03f, 0.03f); Vector3 initPosition = new Vector3(82, 5, 1); // Vector3 initPosition = new Vector3(0, 5, 1); confettiObject.GetComponent<Confetti>().PieceWidth = 3f; confettiObject.GetComponent<Confetti>().PieceLength = 3f; confettiObject.transform.localPosition = new Vector3(initPosition.x, 0, initPosition.z); var sequence = DOTween.Sequence(); sequence.Append(confettiObject.transform.DOLocalMoveY(initPosition.y, 0.5f)); sequence.Append(confettiObject.transform.DOLocalMoveY(initPosition.y * 0.8f, 5f)); sequence.Play().OnComplete(() => { confettiObject.GetComponent<Confetti>().EmitPiecePerSecond = 0; Destroy(confettiObject, 5f); Confetti(); }); }