public void SaveProfile() { var builder = new FlatBufferBuilder(1); StringOffset saveDate = builder.CreateString(DateTime.Now.ToString()); var cbs = new Offset <CubeData> [_cubesHolder.Cubes.Count]; //Cubes Data if (_cubesHolder.Cubes.Count != 0) { for (int i = _cubesHolder.Cubes.Count - 1; i >= 0; i--) { var cubePos = Vec3.CreateVec3(builder, _cubesHolder.Cubes[i].Position.x, _cubesHolder.Cubes[i].Position.y, _cubesHolder.Cubes[i].Position.z); var cubesScale = _cubesHolder.Cubes[i].Scale; var cubesScr = (short)_cubesHolder.Cubes[i].Scr; CubeData.StartCubeData(builder); CubeData.AddPosition(builder, cubePos); CubeData.AddScale(builder, cubesScale); CubeData.AddScr(builder, cubesScr); var _cube = CubeData.EndCubeData(builder); cbs[i] = _cube; builder.Finish(_cube.Value); } } var cubesToSave = PlayerData.CreateCubesVector(builder, cbs); //Player Data PlayerData.StartPlayerData(builder); PlayerData.AddDate(builder, saveDate); PlayerData.AddSessions(builder, _player.TotalSessions); PlayerData.AddCubes(builder, cubesToSave); var playerOffset = PlayerData.EndPlayerData(builder); PlayerData.FinishPlayerDataBuffer(builder, playerOffset); var buf = builder.DataBuffer; File.WriteAllBytes("PlayerSave.pron", builder.SizedByteArray()); Debug.Log("SAVED !"); }