Oculus(Meta Quest)
Provide an Oculus sign-in option to enable players to authenticate using their Meta Quest accounts on virtual reality platforms.
์ฝ๋ ์๊ฐ 1๋ถ์ต๊ทผ ์
๋ฐ์ดํธ: 7๋ฌ ์
์ต์ SDK ๋ฒ์ : 2.3.1
์ด ๋ฌธ์์์๋ ๊ฒ์์์ Oculus ๊ณ์ ์ ์ฌ์ฉํด ํ๋ ์ด์ด์ ์ธ์ฆ์ ์ค์ ํ๋ ๋ค์ ์๋๋ฆฌ์ค์ ๋ํด ์ค๋ช ํฉ๋๋ค.- Oculus ๋ก๊ทธ์ธ ์ค์
- ๊ธฐ์กด ์ฌ์ฉ์ ๋ก๊ทธ์ธ ๋๋ ์ ์ฌ์ฉ์ ์์ฑ
- ์ฌ์ฉ์๋ฅผ ์ต๋ช ๋ก๊ทธ์ธ์์ ์ปค์คํ ID ์ ๊ณต์ ์ฒด๋ฅผ ํตํ ํ๋ซํผ ๋ก๊ทธ์ธ์ผ๋ก ์ ๋ฐ์ดํธ
Oculus ๋ก๊ทธ์ธ ์ค์
Unity Authentication์ ID ์ ๊ณต์ ์ฒด๋ก Oculus๋ฅผ ์ค์ ํ๋ ค๋ฉด ๋ค์์ ๋ฐ๋ฅด์ญ์์ค.- Unity ์๋ํฐ ๋ฉ๋ด์์ Edit > Project Settingsโฆ ๋ก ์ด๋ํ ํ, ๋ด๋น๊ฒ์ด์ ๋ฉ๋ด์์ Services > Authentication์ ์ ํํฉ๋๋ค.
- ID Providers๋ฅผ Oculus๋ก ์ค์ ํ ํ, Add๋ฅผ ํด๋ฆญํฉ๋๋ค.
- App ID ํ ์คํธ ํ๋์ ์ฑ ID๋ฅผ ์ ๋ ฅํฉ๋๋ค.
- App Secret ํ ์คํธ ํ๋์ ์ฑ ๋น๋ฐ ์ ๋ณด๋ฅผ ์ ๋ ฅํฉ๋๋ค.
- ํค๋์ ์ ์ฐฉ์ฉํ๊ณ Settings > System > Developer๋ก ์ด๋ํฉ๋๋ค.
- USB Connection Dialog ์ต์ ์ ํ์ฑํํฉ๋๋ค.
- USB-C ์ผ์ด๋ธ์ ์ฌ์ฉํด ํค๋์ ์ ์ปดํจํฐ์ ์ฐ๊ฒฐํฉ๋๋ค.
- ๋ฐ์ดํฐ ์ก์ธ์ค ๊ถํ์ ์์ฒญํ๋ ์ฐฝ์ด ํ์๋๋ฉด Allow๋ฅผ ํด๋ฆญํฉ๋๋ค.
- ๊ธฐ๊ธฐ๊ฐ ์ฑ๊ณต์ ์ผ๋ก ์ฐ๊ฒฐ๋์๋์ง ํ์ธํ๊ธฐ ์ํด Unity ํ๋ก์ ํธ๋ฅผ ์ด๊ณ File > Build Settings๋ก ์ด๋ํฉ๋๋ค. Platform ๋ชฉ๋ก์์ Android๋ฅผ ์ ํํ๊ณ Switch Platform์ ํด๋ฆญํฉ๋๋ค.
- Run Device ๋ชฉ๋ก์์ Oculus ํค๋์ ์ ์ ํํฉ๋๋ค. ๋ชฉ๋ก์ ํค๋์ ์ด ์๋ ๊ฒฝ์ฐ Refresh๋ฅผ ํด๋ฆญํด ๋ชฉ๋ก์ ์๋ก ๊ณ ์นฉ๋๋ค.
- ์ด Oculus Integration ํจํค์ง๋ฅผ ์ค์ ํ๊ณ ์ค์นํฉ๋๋ค. Oculus Developer Center์์๋ ํจํค์ง๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.
- ํ๋ก์ ํธ์ ์ํฌํธํ ํ, ์๋ํฐ์ ๋ฉ๋ด ๋ฐ์์ Oculus > Platform > Edit Settings๋ก ์ด๋ํฉ๋๋ค. Oculus ์ฑ ID๋ฅผ ์ ๋ ฅํด์ผ ํฉ๋๋ค.
์ฐธ๊ณ : Oculus ํค๋์ ์ ๊ฐ๋ฐ์ ๋ชจ๋๋ก ์ค์ ํด์ผ ํฉ๋๋ค. ๊ฐ๋ฐ์ ๋ชจ๋๋ก ์ค์ ํ๋ ค๋ฉด ๊ฐ๋ฐ์ ์ฌ์ฉํ๋ ค๋ ๊ฐ๋ฐ์ ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธํด์ผ ํฉ๋๋ค. ์ฌ๊ธฐ์์ Oculus ๊ฐ๋ฐ์ ๊ณ์ ์ ์์ฑํ ์ ์์ต๋๋ค.using UnityEngine;using Oculus.Platform;using Oculus.Platform.Models;public class OculusAuth : MonoBehaviour{ private string userId; private void Start() { Core.AsyncInitialize().OnComplete(OnInitializationCallback); } private void OnInitializationCallback(Message<PlatformInitialize> msg) { if (msg.IsError) { Debug.LogErrorFormat("Oculus: Error during initialization. Error Message: {0}", msg.GetError().Message); } else { Entitlements.IsUserEntitledToApplication().OnComplete(OnIsEntitledCallback); } } private void OnIsEntitledCallback(Message msg) { if (msg.IsError) { Debug.LogErrorFormat("Oculus: Error verifying the user is entitled to the application. Error Message: {0}", msg.GetError().Message); } else { GetLoggedInUser(); } } private void GetLoggedInUser() { Users.GetLoggedInUser().OnComplete(OnLoggedInUserCallback); } private void OnLoggedInUserCallback(Message<User> msg) { if (msg.IsError) { Debug.LogErrorFormat("Oculus: Error getting logged in user. Error Message: {0}", msg.GetError().Message); } else { userId = msg.Data.ID.ToString(); // do not use msg.Data.OculusID; GetUserProof(); } } private void GetUserProof() { Users.GetUserProof().OnComplete(OnUserProofCallback); } private void OnUserProofCallback(Message<UserProof> msg) { if (msg.IsError) { Debug.LogErrorFormat("Oculus: Error getting user proof. Error Message: {0}", msg.GetError().Message); } else { string oculusNonce = msg.Data.Value; // Authentication can be performed here } }}
๊ธฐ์กด ํ๋ ์ด์ด ๋ก๊ทธ์ธ ๋๋ ์ ๊ท ํ๋ ์ด์ด ์์ฑ
SignInWithOculusAsync- Oculus ์๊ฒฉ ์ฆ๋ช ์ ์ฌ์ฉํด ์ Unity Authentication ํ๋ ์ด์ด ์์ฑ
- Oculus ์๊ฒฉ ์ฆ๋ช ์ ์ฌ์ฉํด ๊ธฐ์กด ํ๋ ์ด์ด ๋ก๊ทธ์ธ
SignInWithOculusAsyncSignInWithOculusAsyncSignInWithOculusAsyncasync Task SignInWithOculusAsync(string nonce, string userId){ try { await AuthenticationService.Instance.SignInWithOculusAsync(nonce, userId); Debug.Log(โSignIn is successful.โ); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}
ํ๋ ์ด์ด๋ฅผ ์ต๋ช ๋ก๊ทธ์ธ์์ Oculus ๊ณ์ ๋ก๊ทธ์ธ์ผ๋ก ์ ๋ฐ์ดํธ
์ต๋ช ์ธ์ฆ์ ์ค์ ํ ํ, ํ๋ ์ด์ด๊ฐ Oculus ๊ณ์ ์ ์์ฑํ๊ณ Oculus ๊ณ์ ์ ํตํด ๋ก๊ทธ์ธํ๋๋ก ์ ๊ทธ๋ ์ด๋ํ๋ ค๋ ๊ฒฝ์ฐ, ๊ฒ์์ด ํ๋ ์ด์ด์๊ฒ Oculus ๋ก๊ทธ์ธ ์ฐฝ์ ํ์ํ๊ณ Oculus์์ ์ธ์ ํฐ์ผ์ ๊ฐ์ ธ์์ผ ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์LinkWithOculusAsync- ๋ฅผ ์ฌ์ฉํด ์บ์๋ ํ๋ ์ด์ด์ ๊ณ์ ์ ๋ก๊ทธ์ธํฉ๋๋ค.
SignInAnonymouslyAsync - ๋ฅผ ์ฌ์ฉํด ์บ์๋ ํ๋ ์ด์ด์ ๊ณ์ ์ Oculus ๊ณ์ ์ ์ฐ๊ฒฐํฉ๋๋ค.
LinkWithOculusAsync
async Task LinkWithOculusAsync(string nonce, string userId){ try { await AuthenticationService.Instance.LinkWithOculusAsync(nonce, userId); Debug.Log(โLink is successful.โ); } catch (AuthenticationException ex) when (ex.ErrorCode == AuthenticationErrorCodes.AccountAlreadyLinked) { // Prompt the player with an error message. Debug.LogError(โThis user is already linked with another account. Log in instead.โ); } catch (Exception ex) { Debug.LogError(โLink failed.โ); Debug.LogException(ex); }}
Oculus ๊ณ์ ์ฐ๊ฒฐ ํด์
ํ๋ ์ด์ด๊ฐ Oculus ๊ณ์ ์ฐ๊ฒฐ์ ํด์ ํ ์ ์๋๋กUnlinkOculusAsyncasync Task UnlinkOculusAsync(string idToken){ try { await AuthenticationService.Instance.UnlinkOculusAsync(idToken); Debug.Log("Unlink is successful."); } catch (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}