Exemplo n.º 1
0
    /// <summary>
    /// NOTE: We need to query the database FIRST and pull in results, then we can make changes to it
    /// </summary>
    private void UpdateAndDeleteBtns()
    {
        // Have you tried to connect to Azure first? Is there anything in our leaderboard?
        //if (_leadersList != null || _leadersList.Count > 0)
        if (_leadersList.Count > 0)

        {
            // REMOVE the first (latest) thing in the leaderboard (then delete it later)
            if (GUILayout.Button("DELETE LATEST ITEM"))
            {
                // Grab the first item in the list
                var leaderToRemove = _leadersList[0];

                // Removes item at the specified index.
                _leadersList.RemoveAt(0);

                // DELETE it from the leaderboard
                Azure.delete(leaderToRemove,
                             () => Debug.Log("Deleted latest item from leaderboard:" + " " + leaderToRemove.username));
            }

            // UPDATE the first (latest) thing in the leaderboard
            if (GUILayout.Button("Update latest Item"))
            {
                // Grab the first item in the leaderboard list
                var leaderToUpdate = _leadersList[0];

                // Set the item's username to what we entered in the username input field
                leaderToUpdate.username = GUILayout.TextField(_leaderBoardItem.username);

                // Update the item in the leaderboard
                Azure.update(leaderToUpdate, () => Debug.Log("Updated leaderboard item:" + " " + leaderToUpdate.username));
            }
        }
    }