コード例 #1
0
        public override void OnEnter()
        {
#if USES_GAME_SERVICES
            try
            {
                Leaderboard _leaderboard = GameServicesUtils.GetLeaderboard(identifier.Value, isGlobalIdentifier.Value);
                Score       _score       = _leaderboard.LocalUserScore;

                if (_score == null)
                {
                    OnActionDidFail();

                    return;
                }
                else
                {
                    User _user = _score.User;

                    // Update properties
                    userIdentifier.Value = _user.Identifier;
                    userName.Value       = _user.Name;
                    value.Value          = (int)_score.Value;
                    date.Value           = _score.Date.ToString(dateTimeFormat.Value);
                    formattedValue.Value = _score.FormattedValue;
                    rank.Value           = _score.Rank;

                    // Check if image has to be download
                    if (loadImage.Value)
                    {
                        _user.GetImageAsync((Texture2D _image, string _error) => {
                            // Update the image property
                            image.Value = _image;

                            OnActionDidFinish();

                            return;
                        });
                    }
                    else
                    {
                        // Update the image property
                        image.Value = null;

                        OnActionDidFinish();

                        return;
                    }
                }
            }
            catch (System.Exception _exception)
            {
                Debug.Log(_exception.Message);

                OnActionDidFail();

                return;
            }
#endif
        }
コード例 #2
0
        private void DoAction()
        {
#if USES_GAME_SERVICES
            Leaderboard _leaderboard = GameServicesUtils.GetLeaderboard(identifier.Value, isGlobalIdentifier.Value);

            if (_leaderboard == null)
            {
                Log("[GameServices] Leaderboard is null.");
                title.Value = null;
            }
            else
            {
                title.Value = _leaderboard.Title;
            }
#endif
        }
コード例 #3
0
        protected Leaderboard CreateLeaderboard()
        {
            // Create instance
            Leaderboard _newLeaderboard = null;

            if (isGlobalIdentifier.Value)
            {
                _newLeaderboard = NPBinding.GameServices.CreateLeaderboardWithGlobalID(identifier.Value);
            }
            else
            {
                _newLeaderboard = NPBinding.GameServices.CreateLeaderboardWithID(identifier.Value);
            }

            // Set properties
            _newLeaderboard.UserScope  = userScope;
            _newLeaderboard.TimeScope  = timeScope;
            _newLeaderboard.MaxResults = maxResults.Value;

            // Add new instance to the collection
            GameServicesUtils.AddLeaderboardToCollection(_newLeaderboard);

            return(_newLeaderboard);
        }