如何将游戏中的变量保存在文件夹中? [英] How to save variables from a game in a folder?

查看:201
本文介绍了如何将游戏中的变量保存在文件夹中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个游戏,现在我正在为该游戏做一个GUI(带有UI).在此GUI中,我有一个名为"SubjectID"的输入字段,玩家可以在其中输入他的名字.我的目标是为每个球员提供一个文件夹,其中包含他的变量(表现和得分).我怎样才能做到这一点?

I created a game and now I am doing a GUI (with the UI) for that game. In this GUI I have an Inputfield named "SubjectID", where the player can write his name in there. My aim would be that for each of the players there would be like a folder with his variables (performance and points). How can I do this?

这是我的SubjectID输入字段的代码:

Here the code I have for my Inputfield of the SubjectID:

public void Start() {


    //Inputfield for SubjectID
    inputFieldSIDCo = GameObject.Find ("Subject").GetComponent<InputField> (); 

    InputFieldSI =  new InputField.SubmitEvent();

    InputFieldSI.AddListener (SubmitSubjectID);

    inputFieldSIDCo.onEndEdit = InputFieldSI; 
}

//function which submits Inputfield SubjectID 
public void SubmitSubjectID(string arg1) {

    //save arg1 in a variable called SUBJECTID (with string characteristics) 
    SUBJECTID = arg1; 
    //Debug.Log (SUBJECTID); 


}

推荐答案

为什么不使用.NET序列化?

Why don't you use .NET serialization?

一旦您了解了它是如何工作的,它基本上就是自动的.

Once you learn how does it work, it's basically automatic.

http://docs.unity3d.com/Manual/script-Serialization.html

这篇关于如何将游戏中的变量保存在文件夹中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆