-2

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?

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); 


}
sportente
  • 61
  • 1
  • 2
  • 8
  • 1
    If you want to "store" something then why not to use database? Or Application Settings or some file structure if that suits you. – Mangesh Apr 01 '16 at 16:05

1 Answers1

1

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

Tiziano Coroneo
  • 640
  • 6
  • 18
  • I am not a programmer so I am not used and experienced with all this. Can you give me a hint? As I said my aim is, that I write for example in the inputfield: Subject1 , and then I would have a folder named Subject1 with all the variables of Subject 1. – sportente Apr 01 '16 at 16:07
  • this is waaaay more complicated than pretty much all the modern methods to store anything. Just use the tools that other people made for all of us. Like serialization: https://msdn.microsoft.com/en-us/library/ms233843.aspx – Tiziano Coroneo Apr 01 '16 at 16:09
  • Olala this is too high for my level of programming knowledge=( If I would do it with this method, would it also be possible to see which variables are from Subject1 and which are from Subject2? – sportente Apr 01 '16 at 16:12
  • if with this technique (which sounds hard but, really, it's one of the silliest things in c#) you create a class instance, you can "serialize" the instance to convert it to an encoded file in memory. Then, whenever you decide to ask for the "deserialized" item, the system will automagically take the right file and restore the instance as it was before. If your object contains a "name" field, and you mark that as SerializeField if it is private, or not mark it at all if public, you'll get that value back as well. – Tiziano Coroneo Apr 01 '16 at 16:17
  • Ok, thank you for your explanations. I found now a tutorial for this in Unity. My question now is: I have to analyze then the data after saving it. For example the health of a player is not for the whole game the same. In which format do I have to save data in order to analyze them afterwards? – sportente Apr 02 '16 at 13:59