「Unity/おすすめアセット/紙吹雪」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==kayacの紙吹雪== # https://techblog.kayac.com/unity-physically-simulated-confetti にあるunitypackageを入れる # prefab/Confetiをシーンに置く # Confeti.c...」) |
(→kayacの紙吹雪) |
||
行5: | 行5: | ||
公式:https://techblog.kayac.com/unity-physically-simulated-confetti | 公式:https://techblog.kayac.com/unity-physically-simulated-confetti | ||
+ | |||
+ | 5秒ごとに紙吹雪花火サンプル(Dotween必須) | ||
+ | <pre> | ||
+ | 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; | ||
+ | Confetti(); | ||
+ | }); | ||
+ | } | ||
+ | </pre> |
2022年3月19日 (土) 23:21時点における版
kayacの紙吹雪
- https://techblog.kayac.com/unity-physically-simulated-confetti にあるunitypackageを入れる
- prefab/Confetiをシーンに置く
- Confeti.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; Confetti(); }); }