using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class akerutwo : MonoBehaviour
{
//public int stage_num; // スコア変数
//public GameObject ni;
public GameObject Popup;
public GameObject score_object = null;
public static int score_num = 0;
//int cose; // Start is called before the first frame update void Start() { score_num=PlayerPrefs.GetInt("SCORE", 0); Text score_text = score_object.GetComponent<Text>(); score_text.text = "Score:" + score_num; } void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("kaihou2")) { score_num = 2; PlayerPrefs.SetInt("Score", score_num); PlayerPrefs.Save(); } } // Update is called once per frame void Update() { } public void test() { if (score_num < 2) { Popup.SetActive(true); } if (score_num == 2) { SceneManager.LoadScene("wara6"); } }
}
のプログラミングではセーブされたのですが、
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class akeruthree : MonoBehaviour
{
//public int stage_num; // スコア変数
//public GameObject ni;
public GameObject Popup;
public GameObject score_object = null;
public static int score_num = 0;
// Start is called before the first frame update void Start() { score_num = PlayerPrefs.GetInt("SCORE", 0); Text score_text = score_object.GetComponent<Text>(); score_text.text = "Score:" + score_num; } void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("kaihou3")) { score_num = 200; PlayerPrefs.SetInt("Score", score_num); PlayerPrefs.Save(); } } // Update is called once per frame void Update() { } public void test() { if (score_num < 200) { Popup.SetActive(true); } if (score_num== 200) { SceneManager.LoadScene("wara3"); } }
}
のプログラミングではセーブされません。
なぜか?分かりますか?
あなたの回答
tips
プレビュー