タイトルの通りです。
例えば3.539という数値を保存していた場合、もう一度計測してみると0になっているんです。
ソースはこちらです。
こちらが計測をするPlayerです。
public static float mode1FirstTime = 999;
public static float mode1SecondTime = 999;
public static float mode1ThirdTime = 999;
float allTime; private void Start() { mode1FirstTime = 0; mode1SecondTime = 0; mode1ThirdTime = 0; }
void Update(){
allTime += Time.deltaTime;
if (flag)
{
switch (SceneManager.GetActiveScene().name)
{
case "FirstStage":
mode1FirstTime = allTime;
break;
case "SecondStage": mode1SecondTime = allTime; break; case "ThirdStage": mode1ThirdTime = allTime; break; } click = 0; SceneManager.LoadScene("Select"); }
}
そしてこちらがタイムを保存、表示するコードです。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TimeRecord : MonoBehaviour {
public Text firstText; float firstStageTime = Player.mode1FirstTime; float highTime = 999; bool One = true; // Use this for initialization void Start () { highTime = PlayerPrefs.GetFloat("high", 999); firstText.text = "Time : " + highTime.ToString(); Debug.Log(PlayerPrefs.HasKey("high")); } // Update is called once per frame void Update () { if (highTime > firstStageTime) { firstText.text = "Time : " + PlayerPrefs.GetFloat("high").ToString(); PlayerPrefs.SetFloat("high", firstStageTime); highTime = PlayerPrefs.GetFloat("high"); } if (One) { PlayerPrefs.Save(); One = false; } if (Input.GetKey(KeyCode.Space)) { PlayerPrefs.DeleteAll(); } }
}
なぜ0になるのか全く分かりません。かなり困っています。是非、よろしくお願いします。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/21 09:06