我目前工作的一个应用程序内购买商店我的游戏,这是在不同的场景中发现之间传输数据。我遇到的问题是,当我点击一个按钮,例如像白色的皮肤一个新的皮肤,那一幕会保存数据的“didwhiteskin”的布尔为真虽然当我加载gamescene它不会保存这些数据,因此不能运行什么里面,如果statement.Thank你亚勒帮助,如果需要,我会回答任何问题。统一C#传递场景
附加信息:当按钮上点击StoreView函数ChoseWhiteSkin()被调用。
继承人我的代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class StoreScript : MonoBehaviour {
bool didwhiteskin = false;
public static StoreScript Instance {
get;
set;
}
void Awake() {
DontDestroyOnLoad (transform.gameObject);
Instance = this;
}
// Use this for initialization
void Start() {
Scene currentScene = SceneManager.GetActiveScene();
string sceneName = currentScene.name;
if (sceneName == "GameScene") {
if (didwhiteskin) {
Debug.Log ("this ran");
//This where I will put function to change skin but the issue is the if statement never being ran
}
}
else if (sceneName == "StoreView") {
}
}
// Update is called once per frame
void Update() {
}
public void ChoseWhiteSkin() {
PlayerPrefs.Save();
didwhiteskin = true;
}
}
谷歌的前问的问题。这不是一件难事。这个问题最糟糕的部分是它与重复问题具有相同的标题。 – Programmer