Skip to content

Commit

Permalink
Merge pull request #32 from beamable/feature/cloudDataUpdate
Browse files Browse the repository at this point in the history
Bump Beamable version, use new cloud data API
  • Loading branch information
Leinnan committed Sep 2, 2022
2 parents 39797a6 + 43a4526 commit ee8f973
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1649044195
GameObject:
Expand Down Expand Up @@ -388,99 +388,94 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1721234230
--- !u!115 &1735918461
MonoScript:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
serializedVersion: 5
m_Script:
m_DefaultReferences: {}
m_Icon: {fileID: 0}
m_ExecutionOrder: 0
m_ClassName: ApplicationLifetimeDetector
m_Namespace: Beamable.Service
--- !u!1001 &2083833754
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 637265494769770602, guid: e9fa306a98c29420ea7bc2c17da51254,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 637265494769770602, guid: e9fa306a98c29420ea7bc2c17da51254,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -0.00009609533
objectReference: {fileID: 0}
- target: {fileID: 637265495396818175, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870545, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_Name
value: AdminFlow
objectReference: {fileID: 0}
- target: {fileID: 2813540873945479318, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870557, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_RootOrder
value: 5
value: 4
objectReference: {fileID: 0}
- target: {fileID: 2813540873945479318, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870557, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2813540873945479318, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870557, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2813540873945479318, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870557, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2813540873945479318, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870557, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2813540873945479318, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870557, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2813540873945479318, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870557, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2813540873945479318, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870557, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2813540873945479318, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870557, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2813540873945479318, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870557, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2813540873945479318, guid: e9fa306a98c29420ea7bc2c17da51254,
- target: {fileID: 1879866759196870557, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1879866760483718077, guid: 28d63d278d26a754eaec42724a1334d7,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -7445.908
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e9fa306a98c29420ea7bc2c17da51254, type: 3}
--- !u!115 &1735918461
MonoScript:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
serializedVersion: 5
m_Script:
m_DefaultReferences: {}
m_Icon: {fileID: 0}
m_ExecutionOrder: 0
m_ClassName: ApplicationLifetimeDetector
m_Namespace: Beamable.Service
m_SourcePrefab: {fileID: 100100000, guid: 28d63d278d26a754eaec42724a1334d7, type: 3}
--- !u!1001 &2742554814026651718
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Beamable.Api;
using Beamable.Common.Api;
using Beamable.Common.Api.CloudData;
using Beamable.Examples.Services.CloudSavingService;
Expand Down Expand Up @@ -54,7 +55,7 @@ public class TrialDataServiceExample : MonoBehaviour
// Fields ---------------------------------------
private TrialDataServiceExampleData _data = new TrialDataServiceExampleData();
private ICloudDataApi _trialDataService;
private IBeamableAPI _beamableAPI;
private BeamContext _beam;


// Unity Methods --------------------------------
Expand All @@ -75,11 +76,10 @@ protected void Start()
// Methods --------------------------------------
private async void SetupBeamable()
{
_beamableAPI = await Beamable.API.Instance;

Debug.Log($"beamableAPI.User.id = {_beamableAPI.User.id}");

_trialDataService = _beamableAPI.TrialDataService;
_beam = BeamContext.Default;
await _beam.OnReady;
Debug.Log($"_beam.PlayerId = {_beam.PlayerId}");
_trialDataService = BeamContext.Default.Api.TrialDataService;

await LoadTrialData();
}
Expand All @@ -88,23 +88,16 @@ private async void SetupBeamable()
public async Task<EmptyResponse> LoadTrialData()
{
// Load any trials
GetCloudDataManifestResponse playerManifestResponse =
await _trialDataService.GetPlayerManifest();

var playerManifestResponse = await _trialDataService.GetPlayerManifest();
// Loop through trials
_data.MyPlayerProgression = null;
_data.CloudMetaDatas = playerManifestResponse.meta;

foreach (CloudMetaData cloudMetaData in _data.CloudMetaDatas)
{
string path = $"http://{cloudMetaData.uri}";

// Load the data, respecting GZip format
string response =
await ExampleProjectHelper.GetResponseFromHttpWebRequest(path);

MyPlayerProgression myPlayerProgression =
JsonUtility.FromJson<MyPlayerProgression>(response);

var response = await _trialDataService.GetCloudDataContent(cloudMetaData);
var myPlayerProgression = JsonUtility.FromJson<MyPlayerProgression>(response);

// If trial is related, store data
if (myPlayerProgression != null)
{
Expand All @@ -125,7 +118,7 @@ public void Refresh()
$"\n * CloudMetaDatas.Count = {_data.CloudMetaDatas.Count}" +
$"\n\n";

//Debug.Log(refreshLog);
Debug.Log(refreshLog);

// Send relevant data to the UI for rendering
OnRefreshed?.Invoke(_data);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using Beamable.Api.Stats;
using Beamable.Common.Api;
Expand Down Expand Up @@ -83,24 +81,6 @@ public static async Task<EmptyResponse> SetPublicPlayerStat(IBeamableAPI beamabl
return new EmptyResponse();
}

/// <summary>
/// Get the reponse from a <see cref="HttpWebRequest"/>
/// and convert GZip response to text.
/// </summary>
public static async Task<string> GetResponseFromHttpWebRequest(string path)
{
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(path);
httpWebRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
WebResponse webResponse = await httpWebRequest.GetResponseAsync();
string resultText = "";
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
resultText = await streamReader.ReadToEndAsync();
}

return resultText;
}

/// <summary>
/// Determines if incoming content matches a given type
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion client/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
],
"dependencies": {
"com.beamable": "1.2.4",
"com.beamable": "1.3.3",
"com.unity.addressables": "1.18.19",
"com.unity.ide.rider": "3.0.7",
"com.unity.ide.visualstudio": "2.0.12",
Expand Down
12 changes: 10 additions & 2 deletions client/Packages/packages-lock.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"dependencies": {
"com.beamable": {
"version": "1.2.4",
"version": "1.3.3",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.modules.uielements": "1.0.0",
"com.unity.addressables": "1.18.19",
"com.unity.textmeshpro": "1.4.1"
"com.unity.textmeshpro": "1.4.1",
"com.unity.editorcoroutines": "1.0.0"
},
"url": "https://nexus.beamable.com/nexus/content/repositories/unity"
},
Expand All @@ -25,6 +26,13 @@
},
"url": "https://packages.unity.com"
},
"com.unity.editorcoroutines": {
"version": "1.0.0",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ext.nunit": {
"version": "1.0.6",
"depth": 1,
Expand Down

0 comments on commit ee8f973

Please sign in to comment.