順番のプログラム
最終更新日時 :
1人が閲覧中
順番のプログラム
| public static IEnumerator 待つ(float 秒) {yield return new WaitForSeconds(秒); } |
| public static IEnumerator 移動する(GameObject obj, Vector3 追加座標, float 速度) { RectTransform rect = obj.GetComponent<RectTransform>(); if (rect != null) { Vector3 start = rect.anchoredPosition; Vector3 target = start + 追加座標; while (Vector3.Distance(rect.anchoredPosition, target) > 0.01f) { rect.anchoredPosition = Vector3.MoveTowards( rect.anchoredPosition, target, 速度 * Time.deltaTime ); yield return null; } yield break; } Vector3 start3 = obj.transform.position; Vector3 target3 = start3 + 追加座標; while (Vector3.Distance(obj.transform.position, target3) > 0.01f) { obj.transform.position = Vector3.MoveTowards( obj.transform.position, target3, 速度 * Time.deltaTime ); yield return null; } } |
| public static IEnumerator テキスト表示する(GameObject obj, string 文, float 速度 = 0.05f) { var tmp = obj.GetComponent<TextMeshProUGUI>(); if (tmp != null) { tmp.text = ""; foreach (char c in 文) { tmp.text += c; yield return new WaitForSeconds(速度); } yield break; } var text = obj.GetComponent<Text>(); if (text != null) { text.text = ""; foreach (char c in 文) { text.text += c; yield return new WaitForSeconds(速度); } yield break; } Debug.LogWarning($"{obj.name} にテキストコンポーネントがありません"); } |
| public static IEnumerator フェードアウトする(GameObject obj, float 時間) { CanvasGroup cg = obj.GetComponent<CanvasGroup>(); if (cg == null) cg = obj.AddComponent<CanvasGroup>(); float t = 0f; while (t < 時間) { t += Time.deltaTime; cg.alpha = 1f - (t / 時間); yield return null; } cg.alpha = 0f; } |
コメント (順番のプログラム)
この記事を作った人

