Unity的Scene之间如何传递数据,成为UP主的第777天留念。
写一个Static的Singleton的class,数据存里面就可以了。别忘了加DontDestroyOnLoad(this.gameObject);
例子:
public class PlayerDataSingleton : MonoBehaviour
{
public static PlayerDataSingleton instance;
public int anyData;
private void Awake()
{
instance = this;
DontDestroyOnLoad(this.gameObject);
}
}