public void OnWhereButtonClicked() { if (serviceUser == null) { FacebookAuthText.text = "Please authenticate before using futher scenarios!"; return; } TodoItem item1 = new TodoItem { Complete = false, Text = "Todo Updated", Id = "5a34a00d8ef34630b6fe19e0e2c31b8b" }; AzureMobileServices.Where <TodoItem>(item => item.Text.Contains("Updated"), (response) => { if (response.Status == CallbackStatus.Failure) { Debug.LogError("Where record failed."); Debug.LogError(response.Exception.ToString()); return; } // print something FacebookAuthText.text = "Successfully looked up item by where"; Debug.Log("Successfully looked up item by where"); }); }
void MainPage_Loaded(object sender, RoutedEventArgs e) { string AzureEndPoint = "https://unityleaderboard.azure-mobile.net/"; string ApplicationKey = "sMkhPtZJYlndEGAWTxxKoOfadQIvmo27"; azure = new AzureMobileServices(AzureEndPoint, ApplicationKey); azure.Where<LeaderBoard>(p => p.UserName != null, ReadHandler); }
public void GetAllItems() { _toDoItems.Clear(); azure.Where <ToDoItem>(p => p.Text != null, ReadHandler); }
void QueryAllItem() { _moregame.Clear(); azure.Where <moregame>(p => p.Username != null, QueryCallback); }
public void OnGUI() { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); // Column 1 GUILayout.BeginVertical(GUILayout.Width(colWidth)); GUILayout.Label("Azure End Point"); AzureEndPoint = GUILayout.TextField(AzureEndPoint, GUILayout.Width(colWidth)); GUILayout.Label("Application Key"); ApplicationKey = GUILayout.TextField(ApplicationKey, GUILayout.Width(colWidth)); GUILayout.EndVertical(); // hide rest of GUI if no connection available GUI.enabled = (azure != null); // Column 2 GUILayout.BeginVertical(GUILayout.Width(colWidth)); GUILayout.Label("Username"); _leaderboard.Username = GUILayout.TextField(_leaderboard.Username); GUILayout.Label("Score"); _leaderboard.Score = Convert.ToInt32(GUILayout.TextField("" + _leaderboard.Score)); if (GUILayout.Button("Add Score", GUILayout.MinWidth(width), GUILayout.Height(height))) { // Note: You don't need to do the following, it's done in the insert method. // _leaderboard.Id = null; if (_leaderboard.Score > 0) { // only insert score if greater than 0 azure.Insert <Leaderboard>(_leaderboard); } else { Debug.Log("Score must be > 0 to insert"); } } GUILayout.Label("Id: " + _leaderboard.Id); // unique item Id (returned once submitted succesfully) GUILayout.EndVertical(); // Column 3 GUILayout.BeginVertical(GUILayout.Width(colWidth)); if (GUILayout.Button("Query User Scores", GUILayout.MinWidth(width), GUILayout.Height(height))) { _leaderboardItems.Clear(); // get a user's scores azure.Where <Leaderboard>(p => p.Username == _leaderboard.Username, ReadHandler); } if (GUILayout.Button("List All Scores", GUILayout.MinWidth(width), GUILayout.Height(height))) { GetAllItems(); } if (GUILayout.Button("List Scores 500+", GUILayout.MinWidth(width), GUILayout.Height(height))) { _leaderboardItems.Clear(); // get high scores azure.Where <Leaderboard>(p => p.Score >= 500, ReadHandler); } GUILayout.Label("Item count: " + _leaderboardItems.Count); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.Height(300)); // Column 4 GUILayout.BeginVertical(); foreach (var item in _leaderboardItems) { GUILayout.BeginHorizontal(); if (GUILayout.Button(">", GUILayout.Width(width), GUILayout.Height(height))) { _selectedItem = item; } GUILayout.Label(item.Username); GUILayout.Label(Convert.ToString(item.Score)); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(colWidth)); var was = GUI.enabled; GUI.enabled = _selectedItem.Id != null; GUILayout.Label("Id: " + _selectedItem.Id); if (_selectedItem.Score > 0) { _selectedItem.Score = Convert.ToInt32(GUILayout.TextField("" + _selectedItem.Score)); } _selectedItem.Username = GUILayout.TextField(_selectedItem.Username); if (GUILayout.Button("Update", GUILayout.MinWidth(width), GUILayout.Height(height))) { azure.Update <Leaderboard>(_selectedItem); } if (GUILayout.Button("Delete", GUILayout.MinWidth(width), GUILayout.Height(height))) { azure.Delete <Leaderboard>(_selectedItem); } GUI.enabled = was; GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.enabled = true; }
/* * public void OnGUI() * { * GUILayout.BeginVertical(); * GUILayout.BeginHorizontal(); * * // Column 1 * GUILayout.BeginVertical(GUILayout.Width(colWidth)); * GUILayout.Label("Azure End Point"); * AzureEndPoint = GUILayout.TextField(AzureEndPoint, GUILayout.Width(colWidth)); * GUILayout.Label("Application Key"); * ApplicationKey = GUILayout.TextField(ApplicationKey, GUILayout.Width(colWidth)); * GUILayout.EndVertical(); * * // hide rest of GUI if no connection available * GUI.enabled = ( azure != null ); * * // Column 2 * GUILayout.BeginVertical(GUILayout.Width(colWidth)); * GUILayout.Label("Username"); * _leaderboard.Username = GUILayout.TextField(_leaderboard.Username); * GUILayout.Label("Score"); * _leaderboard.Score = Convert.ToInt32( GUILayout.TextField(""+_leaderboard.Score) ); * if(GUILayout.Button("Add Score", GUILayout.MinWidth(width), GUILayout.Height(height) )) * { * // Note: You don't need to do the following, it's done in the insert method. * // _leaderboard.Id = null; * * if(_leaderboard.Score > 0) * { * // only insert score if greater than 0 * azure.Insert<Leaderboard>(_leaderboard); * } * else * { * Debug.Log("Score must be > 0 to insert"); * } * } * GUILayout.Label("Id: " + _leaderboard.Id); // unique item Id (returned once submitted succesfully) * GUILayout.EndVertical(); * * // Column 3 * GUILayout.BeginVertical(GUILayout.Width(colWidth)); * if (GUILayout.Button("Query User Scores", GUILayout.MinWidth(width), GUILayout.Height(height) )) * { * _leaderboardItems.Clear(); * // get a user's scores * azure.Where<Leaderboard>( p => p.Username == _leaderboard.Username, ReadHandler); * } * if (GUILayout.Button("List All Scores", GUILayout.MinWidth(width), GUILayout.Height(height) )) * { * GetAllItems(); * } * if (GUILayout.Button("List Scores 500+", GUILayout.MinWidth(width), GUILayout.Height(height) )) * { * _leaderboardItems.Clear(); * // get high scores * azure.Where<Leaderboard>( p => p.Score >= 500, ReadHandler); * } * GUILayout.Label("Item count: " + _leaderboardItems.Count); * scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true, GUILayout.Height(300)); * * // Column 4 * GUILayout.BeginVertical(); * foreach (var item in _leaderboardItems) * { * GUILayout.BeginHorizontal(); * if (GUILayout.Button(">", GUILayout.Width(width), GUILayout.Height(height) )) * { * _selectedItem = item; * } * GUILayout.Label(item.Username); * GUILayout.Label(Convert.ToString(item.Score)); * GUILayout.EndHorizontal(); * } * GUILayout.EndVertical(); * * GUILayout.EndScrollView(); * GUILayout.EndVertical(); * * GUILayout.BeginVertical(GUILayout.Width(colWidth)); * * var was = GUI.enabled; * * GUI.enabled = _selectedItem.Id != null; * * GUILayout.Label("Id: " + _selectedItem.Id); * if(_selectedItem.Score > 0) * { * _selectedItem.Score = Convert.ToInt32( GUILayout.TextField(""+_selectedItem.Score) ); * } * _selectedItem.Username = GUILayout.TextField(_selectedItem.Username); * * if (GUILayout.Button("Update", GUILayout.MinWidth(width), GUILayout.Height(height) )) * { * azure.Update<Leaderboard>(_selectedItem); * } * if (GUILayout.Button("Delete", GUILayout.MinWidth(width), GUILayout.Height(height) )) * { * azure.Delete<Leaderboard>(_selectedItem); * } * * GUI.enabled = was; * * GUILayout.EndVertical(); * GUILayout.EndHorizontal(); * * GUILayout.BeginHorizontal(); * GUILayout.EndHorizontal(); * * GUILayout.EndVertical(); * * GUI.enabled = true; * } */ public void GetAllItems() { _leaderboardItems.Clear(); azure.Where <Leaderboard>(p => p.Username != null, ReadHandler); }
//public void QueryOldLevel(string idFacebook) //{ // _leaderboardItems.Clear(); // azure.Where<pandafruitfarm>(p => p.IdFacebook == idFacebook, QueryOldLevelCallback); //} //private void QueryOldLevelCallback(AzureResponse<List<pandafruitfarm>> response) //{ // var list = response.ResponseData; // foreach (var item in list) // { // GetDataFacebook.Level = item.Level; // } //} public void QueryIdFacebook(string idFacebook, string Level) { _leaderboardItems.Clear(); azure.Where <pandafruitfarm>(p => p.IdFacebook == idFacebook && p.Level == Level, QueryIdFacebookCallback); }