unityでシューティングゲームを作成していて,
ゲーム終了時に命中率と達成率が%表示ででるようになっているのですが,次のシーンに移動したときにもその結果を表示させられるようにしたいです。命中率と達成率のプログラムは下にあります,
よろしくお願いします。
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class Daveragetext : MonoBehaviour 6{ 7 8 public static TextMesh Averagetext; //達成率の割合テキスト 9 10 public float RateTimer; 11 private float timeelapse; 12 13 public float correct = 0.0f; 14 public float count = 0.0f; 15 public float Average = 0.0f; 16 // Use this for initialization 17 void Start() 18 { 19 20 } 21 22 // Update is called once per frame 23 void Update() 24 { 25 26 } 27 28 public void CountPlus(float fool) 29 { 30 count += fool; 31 } 32 33 public void PointPlus() 34 { 35 correct += 1.0f; 36 DRatecalculate(); 37 } 38 39 public void DRatecalculate() 40 { 41 Average = Mathf.Round((correct / count) * 100); 42 Averagetext.text = "Avarage =" + Average.ToString("N3") + " % "; 43 } 44 45 public void LastRatecalculate() 46 { 47 Debug.Log("達成率= " + Average.ToString("N3") + "%"); 48 } 49} 50
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class Dhitaverage : MonoBehaviour { 6 7 public float Trigger; 8 public float Hit; 9 private float HAverage; 10 public static TextMesh HitAverageText; 11 // Use this for initialization 12 void Start () { 13 14 } 15 16 // Update is called once per frame 17 void Update () { 18 19 } 20 21 public void TriggerCount() 22 { 23 Trigger += 1; 24 } 25 26 public void HitCount() 27 { 28 Hit += 1; 29 } 30 31 public void HitAverageCulculate() 32 { 33 HAverage = Mathf.Round((Hit / Trigger) * 100); 34 HitAverageText.text = "HitAvarage =" + HAverage.ToString("N3") + " % "; 35 Debug.Log("ヒット率 = " + HAverage); 36 } 37} 38 39
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。