Esempio n. 1
0
    // Start is called before the first frame update
    void Start()
    {
        _testDataObj = new TestSaveData();
        Debug.Log("实例化一个数据类对象,用来存放具体数据");

        uiInputTxt.onValueChanged.AddListener(GetInputTxt);

        uiBtnSave.onClick.AddListener(
            () =>
        {
            BinaryTool.SaveBinaryData <TestSaveData>(_testDataObj, "DataFile");
            Debug.Log("序列化对象, _testDataObj, 内容为:" + _testDataObj.inputStr);
        });

        uiBtnShow.onClick.AddListener(
            () =>
        {
            _testDataObj = BinaryTool.ReadBinaryData <TestSaveData>("DataFile");
            Debug.Log("反序列化对象, _testDataObj, 读取内容为:" + _testDataObj.inputStr);
            uiTxtOutput.text = _testDataObj.inputStr;
        });
    }