Пример #1
0
    // Update is called once per frame
    void CreatSendPb()
    {
        TestForProto tbProto = new TestForProto();

        tbProto.Name = nameT.text;
        tbProto.Age  = int.Parse(ageT.text);
        string pnum = phoneNumT.text;

        for (int i = 0; i < pnum.Length; i++)
        {
            tbProto.PhoneNum.Add(int.Parse(pnum[i].ToString()));
        }

        byte[] dataBytes = tbProto.ToByteArray();
        this.dataBytes = dataBytes;



        TestForProto cbProto = TestForProto.Parser.ParseFrom(this.dataBytes);

        rNameT.text     = cbProto.Name;
        rAgeT.text      = cbProto.Age.ToString();
        rPhoneNumT.text = "";
        for (int i = 0; i < cbProto.PhoneNum.Count; i++)
        {
            rPhoneNumT.text = rPhoneNumT.text + cbProto.PhoneNum[i];
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        TestForProto testForProto = new TestForProto();

        testForProto.Name = "stms";
        Debug.Log(testForProto.ToByteArray());
        Debug.Log(Application.dataPath);
        FileStream   fileStream   = new FileStream(Application.dataPath + "/local/file.txt", FileMode.OpenOrCreate, FileAccess.Write);
        StreamWriter streamWriter = new StreamWriter(fileStream);

        //fileStream.
        //streamWriter.Write("ddddddddddddddddd");
        fileStream.Close();
    }
Пример #3
0
    void Start()
    {
        btn.onClick.AddListener(CreatSendPb);
        TestForProto tbProto = new TestForProto();

        tbProto.Name = nameT.text;
        tbProto.Age  = int.Parse(ageT.text);
        string pnum = phoneNumT.text;

        for (int i = 0; i < pnum.Length; i++)
        {
            tbProto.PhoneNum.Add(int.Parse(pnum[i].ToString()));
        }

        byte[] dataBytes = tbProto.ToByteArray();
        this.dataBytes = dataBytes;
        //IMessage imPerson = new TestForProto();
        //TestForProto cbProto = (TestForProto)imPerson.Descriptor.Parser.ParseFrom(dataBytes);
        //cbProto =
    }