:実現したいこと
変数に数字の値をいれてTextに反映します。今現在textに1という数字を表示しています。別のSceneに移動してtext+1をして元のSceneに戻ってきたときに2という数字を表示したいです。今自分でいろいろ試した結果のスクリプトを貼り付けました。
:エラーはありません。
:スクリプト
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Main : MonoBehaviour
{
public static int text = 1;
public Text scoreText;
public static int GetText () { return text; } // Use this for initialization void Start() { Invoke("Scene", 3.5f); } // Update is called once per frame void Update() { scoreText.text = "Stage:" + text.ToString(); } void Scene() { if (text == 1) { SceneManager.LoadScene("Game6"); } else if (text == 2) { SceneManager.LoadScene("Game2"); } } void RefreshScoreText () { scoreText.text = "Stage:" + text.ToString(); }
}
2つめのText
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Game6 : MonoBehaviour {
void Start() { int game6Text = Main.GetText(); game6Text += 1; }
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/14 03:08