void ExamInfo()
 {
     if (!string.IsNullOrEmpty(tempMessageString))
     {
         TempStruct tempStruct = JsonUtility.FromJson <TempStruct>(tempMessageString);
         if (tempStruct.eventName == "RequestExamInfo")
         {
             ExamData examInfo = JsonUtility.FromJson <ExamData>(tempMessageString);
             if (examInfo.status == true)
             {
                 // var data = examInfo.message.Split(',');
                 List <string> data = new List <string>(examInfo.message.Split(','));
             }
             Debug.Log("success");
         }
         else
         {
             Debug.Log("err");
         }
     }
     tempMessageString = string.Empty;
 }
Beispiel #2
0
        private static void TestArray()
        {
            // C++ will return its TempStruct array in ptr

            Interop.GetArrResult(out var ptr, out var size);

            TempStruct[] someData2 = new TempStruct[size];

            for (int i = 0; i < size; i++)
            {
                IntPtr ptr2 = Marshal.ReadIntPtr(ptr, i * IntPtr.Size);
                someData2[i] = (TempStruct)Marshal.PtrToStructure(ptr2, typeof(TempStruct));
            }

            // Important! We free the TempStruct allocated by C++. We let the
            // C++ do it, because it knows how to do it.
            Interop.FreeArrSomeData(ptr, size);

            foreach (var item in someData2)
            {
                Console.WriteLine(item);
            }
        }