Version: Unity 6.0 (6000.0)
언어 : 한국어
인앱 구매가 가능하도록 애플리케이션 준비
iOS용 빌드 및 배포

소셜 API

참고: 소셜 API는 지원이 중단되어 향후 릴리스에서 제거될 예정입니다.

소셜 API는 Unity에서 다음과 같은 소셜 기능에 액세스하는 방법입니다.

  • 사용자 프로필
  • 친구 리스트
  • 업적
  • 통계/리더보드

GameCenter 같은 다양한 소셜 백엔드용 통합 인터페이스를 제공하며, 주로 게임 프로젝트의 프로그래머가 사용하도록 고안되었습니다.

소셜 API는 주로 비동기 API이며, 함수를 호출하고 해당 함수가 완료되면 콜백을 등록하는 것이 일반적인 사용 방식입니다. 이 비동기 함수는 API의 특정 상태 변수를 채우는 등 부작용이 있을 수 있으며, 콜백에는 처리할 서버의 데이터가 포함될 수 있습니다.

Social 클래스는 UnityEngine 네임스페이스에 있으므로 항상 사용 가능하지만, 다른 소셜 API 클래스는 자체 네임스페이스인 UnityEngine.SocialPlatforms에 저장됩니다. 또한 소셜 API는 SocialPlatforms.GameCenter 같은 하위 네임스페이스에 구현됩니다.

다음은 소셜 API를 사용할 수 있는 방법에 대한 예시입니다.

using UnityEngine;
using UnityEngine.SocialPlatforms;

public class SocialExample : MonoBehaviour {

    void Start () {
        // Authenticate and register a ProcessAuthentication callback
        // This call needs to be made before we can proceed to other calls in the Social API
        Social.localUser.Authenticate (ProcessAuthentication);
    }

    // This function gets called when Authenticate completes
    // Note that if the operation is successful, Social.localUser will contain data from the server.
    void ProcessAuthentication (bool success) {
        if (success) {
            Debug.Log ("Authenticated, checking achievements");

            // Request loaded achievements, and register a callback for processing them
            Social.LoadAchievements (ProcessLoadedAchievements);
        }
        else
            Debug.Log ("Failed to authenticate");
    }

    // This function gets called when the LoadAchievement call completes
    void ProcessLoadedAchievements (IAchievement[] achievements) {
        if (achievements.Length == 0)
            Debug.Log ("Error: no achievements found");
        else
            Debug.Log ("Got " + achievements.Length + " achievements");

        // You can also call into the functions like this
        Social.ReportProgress ("Achievement01", 100.0, result => {
            if (result)
                Debug.Log ("Successfully reported achievement progress");
            else
                Debug.Log ("Failed to report achievement");
        });
    }
}

소셜 API에 대한 자세한 내용은 소셜 API 스크립팅 레퍼런스를 참조하십시오.

인앱 구매가 가능하도록 애플리케이션 준비
iOS용 빌드 및 배포