๐Ÿ“‚ Project/Paint the City

[Unity3D/VR] Oculus Integration ํŒจํ‚ค์ง€๋ฅผ ์ด์šฉํ•˜์—ฌ 3D Object ๋ฐ UI์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๊ธฐ

0=2. 2023. 5. 3. 15:19

์ด์ „ ํฌ์ŠคํŠธ์— ํ”„๋กœ์ ํŠธ 'Paint the City'์— ๊ด€๋ จํ•œ ์„ค๋ช…์ด ์žˆ์œผ๋‹ˆ ์ฐธ๊ณ ๋ฐ”๋ž๋‹ˆ๋‹ค.

2022.11.25 - [Paint the City] - [Unity 3D/VR] Tilt Brush, Open brush ์˜คํ”ˆ ์†Œ์Šค๋ฅผ ์ด์šฉํ•˜์—ฌ 3D ํŽ˜์ธํŒ… ๊ธฐ๋Šฅ ๊ตฌํ˜„ํ•˜๊ธฐ


์•ˆ๋…•ํ•˜์„ธ์š”. ์ €๋ฒˆ ํฌ์ŠคํŠธ์— 3D ํŽ˜์ธํŒ… ๊ธฐ๋Šฅ์— ์‚ฌ์šฉํ•  ์˜คํ”ˆ ์†Œ์Šค๋ฅผ ์ด์šฉํ•˜๋Š” ๊ณผ์ •์„ ๋ณด์—ฌ๋“œ๋ ธ๋Š”๋ฐ์š”.

์ €ํฌ ํ”„๋กœ์ ํŠธ์˜ VR ํ”„๋กœ๊ทธ๋žจ์—์„œ 3D ํŽ˜์ธํŒ… ๊ธฐ๋Šฅ์ด ์ฃผ๋œ ๊ธฐ๋Šฅ์ด์ง€๋งŒ, ๊ทธ ์™ธ์—๋„ ๊ตฌํ˜„ํ•ด์•ผ ํ•  ๋ถ€๋ถ„๋“ค์ด ๋งŽ์•˜์Šต๋‹ˆ๋‹ค.

๊ทธ ์ค‘์—์„œ ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์œผ๋กœ VR ํ™˜๊ฒฝ์—์„œ UI ๋˜๋Š” 3D ์˜ค๋ธŒ์ ํŠธ์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๋Š” ๋ฒ•์„ ์„ค๋ช…ํ•ด๋“œ๋ฆฌ๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

์ด ๊ธฐ๋Šฅ์„ ์œ„ํ•ด ์—์…‹ ์Šคํ† ์–ด์— ์žˆ๋Š” Oculus Integration ํŒจํ‚ค์ง€๋ฅผ ์ด์šฉํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๊ฐ„๋‹จํ•œ ๋ฐฐ๊ฒฝ ์„ค์ •๊ณผ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๋ฐฐ์น˜ํ•˜๋Š” ๊ฒƒ๋ถ€ํ„ฐ Interactionํ•˜๋Š” ๋ฐฉ๋ฒ•๊นŒ์ง€ ์ž์„ธํžˆ ์„ค๋ช…๋“œ๋ฆฌ๊ณ , ํ”„๋กœ์ ํŠธ์—์„œ ์–ด๋–ป๊ฒŒ ์“ฐ์˜€๋Š”์ง€๋„ ๋ณด์—ฌ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค.

 

Unity VR ํ™˜๊ฒฝ ์„ธํŒ…์— ๊ด€ํ•œ ๋‚ด์šฉ์€ ๋”ฐ๋กœ ์ž‘์„ฑํ•˜์ง€ ์•Š์•˜์œผ๋‹ˆ, ์„ธํŒ…๋˜์–ด์žˆ์ง€ ์•Š๋‹ค๋ฉด ์„ธํŒ… ํ›„ ์‹œ์ž‘ํ•ด์ฃผ์„ธ์š”.


Oculus Integration ํŒจํ‚ค์ง€ ์„ค์น˜

์—์…‹์Šคํ† ์–ด์—์„œ Oculus Integration ์—์…‹์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

https://assetstore.unity.com/packages/tools/integration/oculus-integration-82022

 

Oculus Integration | ๊ธฐ๋Šฅ ํ†ตํ•ฉ | Unity Asset Store

Use the Oculus Integration from Oculus on your next project. Find this integration tool & more on the Unity Asset Store.

assetstore.unity.com

 

'๋‚ด ์—์…‹์— ์ถ”๊ฐ€ํ•˜๊ธฐ'๋ฅผ ๋ˆ„๋ฅด๋ฉด ์ž์‹ ์˜ ์œ ๋‹ˆํ‹ฐ ๊ณ„์ •์— ์—์…‹์ด ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค. ๋กœ๊ทธ์ธ์„ ์•ˆ ํ•˜์…จ๋‹ค๋ฉด ๋กœ๊ทธ์ธํ•ด์ฃผ์„ธ์š”.

 

๋‹ค์Œ์œผ๋กœ, ์ด ํŒจํ‚ค์ง€๋ฅผ ์‚ฌ์šฉํ•  ํ”„๋กœ์ ํŠธ๋ฅผ ๋ฏธ๋ฆฌ ์—ด์–ด๋‘์…จ๋‹ค๋ฉด, ‘Unity์—์„œ ์—ด๊ธฐ’๋ฅผ ํด๋ฆญํ•˜์—ฌ ํ”„๋กœ์ ํŠธ์—์„œ ์—ด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋˜๋Š” ์œ ๋‹ˆํ‹ฐ ์—๋””ํ„ฐ ๋‚ด์—์„œ [Window - Package Manager - Packages: My Asset]์—์„œ๋„ import ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

import ์™„๋ฃŒ ํ›„, [Asset - Oculus] ์—์„œ ์—์…‹๋“ค์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

UI Interaction

๋ฐฐ๊ฒฝ ์„ค์ • ๋ฐ ์˜ค๋ธŒ์ ํŠธ ๋ฐฐ์น˜

UI Interaction์„ ์œ„ํ•ด Main Menu Scene์„ ๋งŒ๋“ค์–ด ๋ด…์‹œ๋‹ค.

์ƒˆ๋กœ์šด Scene์„ ์ƒ์„ฑํ•˜๊ณ  ์ด๋ฆ„์„ 'MainMenu'๋กœ ์„ค์ •ํ•œ ํ›„, ์”ฌ์„ ์—ด์–ด์ฃผ์„ธ์š”.

 

๊ธฐ์กด์˜ ๋ฐฐ๊ฒฝ์€ ์ด๋Ÿฐ ๋ชจ์Šต์ธ๋ฐ, Menu ์”ฌ์—๋Š” ์ ํ•ฉํ•˜์ง€ ์•Š์€ ๊ฒƒ ๊ฐ™์œผ๋‹ˆ ๋ฐ”๊พธ๊ฒ ์Šต๋‹ˆ๋‹ค.

[Window - Rendering - Lighting - Environment] ์—์„œ Skybox๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์ ์ ˆํ•œ Material์„ ์ฐพ์•„ ์ ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. Oculus ํŒจํ‚ค์ง€์— ์žˆ๋˜ Skybox์ธ๋ฐ, ์›ํ•˜๋Š” ๊ฒƒ์„ ๊ณจ๋ผ ์ ์šฉํ•ด์ฃผ์„ธ์š”.

 

ํ•˜์ด์–ด๋ผํ‚ค ์ฐฝ์—์„œ ์˜ค๋ฅธ์ชฝ ๋งˆ์šฐ์Šค๋ฅผ ๋ˆŒ๋Ÿฌ [3D Object - Plane]์„ ์„ ํƒํ•ด ๋ฐ”๋‹ฅ์„ ๋งŒ๋“ค์–ด ์ค๋‹ˆ๋‹ค.

์˜ค๋ธŒ์ ํŠธ ์ด๋ฆ„์€ 'Floor'๋กœ ์„ค์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

์˜ค๋ธŒ์ ํŠธ์— ์ ์ ˆํ•œ Material์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

Scene์— 'OVRPlayerController' Prefab์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

OVRPlayerController๋Š” Oculus ํ—ค๋“œ์…‹์„ trackingํ•˜๊ณ , ํ”Œ๋ ˆ์ด์–ด ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

 

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋ฐ”๋‹ฅ ์œ„์— ์žˆ์„ ์ˆ˜ ์žˆ๋„๋ก OVRPlayerController์™€ Floor์˜ y๊ฐ’์„ ์กฐ์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

UI Canvas ์„ค์ •

OVRPlayerController์˜ z๊ฐ’์„ ์กฐ์ •ํ•˜์—ฌ ์ƒ์„ฑํ•  UI์™€ ์ ๋‹นํ•œ ๊ฑฐ๋ฆฌ๋ฅผ ์œ ์ง€ํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

 

Menu์™€์˜ ์ƒํ˜ธ์ž‘์šฉ์„ ์œ„ํ•œ Canvas๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

ํ•˜์ด์–ด๋ผํ‚ค ์ฐฝ์—์„œ ์˜ค๋ฅธ์ชฝ ๋งˆ์šฐ์Šค๋ฅผ ๋ˆŒ๋Ÿฌ [UI - Canvas]์„ ์„ ํƒํ•ด Canvas๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ , ์ด๋ฆ„์€ 'Menu Canvas'๋กœ ์„ค์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

์ดํ›„๋ถ€ํ„ฐ๋Š” VRํ™˜๊ฒฝ์—์„œ UI์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๊ธฐ ์œ„ํ•ด ๊ผญ ๋ณ€๊ฒฝํ•ด์•ผ ํ•˜๋Š” Canvas ์„ค์ •๋“ค์ž…๋‹ˆ๋‹ค.

[Canvas - Render Mode]๋ฅผ World Space๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.

 

Canvas์˜ Width์™€ Height๋ฅผ ์ƒ์„ฑํ•  ๋ฉ”๋‰ด UI ํฌ๊ธฐ์— ๋งž๊ฒŒ ์กฐ์ •ํ•ฉ๋‹ˆ๋‹ค.

Position๊ณผ Scale์„ ์กฐ์ •ํ•˜์—ฌ Player์˜ ์‚ฌ์ด์ฆˆ์™€ ๋งž๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

 

Graphic Raycaster ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ญ์ œํ•˜๊ณ , 'OVR Raycaster'์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

 

[Canvas - Event Camera]์— OVRPlayerController์˜ 'CenterEyeAnchor'์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

 

์ด์ œ Scene์— 'UIHelpers'๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

UIHelpers๋Š” Oculus ํŒจํ‚ค์ง€์—์„œ ์ œ๊ณตํ•˜๋Š” Prefab์œผ๋กœ, UI Interaction์— ํ•„์š”ํ•œ ๊ธฐ๋Šฅ์„ ๋‹ด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

 

UIHelpers์— EventSystem์ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์—, ๊ธฐ์กด์˜ EventSystem์„ ์‚ญ์ œํ•ฉ๋‹ˆ๋‹ค.

 

LaserPointer๋Š” ํ”Œ๋ ˆ์ด์–ด๊ฐ€ UI๋ฅผ ๊ฐ€๋ฆฌํ‚ฌ ๋•Œ ํ‘œ์‹œ๋˜๋Š” ๊ด‘์„ ์˜ ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

LineRenderer์„ ํ™œ์„ฑํ™”ํ•˜๊ณ , Material์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  [Menu Canvas - OVR Raycaster - Pointer]์— LaserPointer๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.

 

๋˜๋‹ค๋ฅธ ์„ค์ •์„ ์œ„ํ•ด 'LaserPointer' Script๋ฅผ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.

LaserBeamBehavior ์œ„์— SerializeField๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ, ์œ ๋‹ˆํ‹ฐ ๋‚ด์—์„œ๋„ ์ด ์„ค์ •์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

    [SerializeField]
    private LaserBeamBehavior _laserBeamBehavior;

 

์Šคํฌ๋ฆฝํŠธ ์ˆ˜์ •์ด ์™„๋ฃŒ๋˜๋ฉด, ์ด๋ ‡๊ฒŒ Laser Beam Behavior๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

'On When Hit Target'์œผ๋กœ ์„ค์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

๊ธฐ์กด ์„ค์ •์ด์—ˆ๋˜ 'On'์€ ๊ด‘์„ ์ด ํ•ญ์ƒ ์ผœ์ ธ์žˆ๋Š” ์ƒํƒœ์ž…๋‹ˆ๋‹ค.

On When Hit Target์˜ ๊ฒฝ์šฐ, ์ปจํŠธ๋กค๋Ÿฌ๊ฐ€ ํƒ€๊ฒŸ์„ ๋ฐ”๋ผ๋ณด๊ณ  ์žˆ์„ ๋•Œ ๊ด‘์„ ์ด ํ™œ์„ฑํ™”๋จ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. 

 

'EventSystem'์—์„œ [OVR Input Module - Joy Pad Click Button]์„ ์›ํ•˜๋Š” ๋ฒ„ํŠผ์œผ๋กœ ์„ ํƒํ•ด์ฃผ์„ธ์š”.

์ €๋Š” 'Secondary Index Trigger'๋กœ ์„ค์ •ํ•˜์˜€๊ณ , ์˜ค๋ฅธ์ชฝ ์ปจํŠธ๋กค๋Ÿฌ์˜ ํŠธ๋ฆฌ๊ฑฐ ๋ฒ„ํŠผ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

 

์˜คํ˜๋Ÿฌ์Šค ์ž…๋ ฅ๊ณผ ๊ด€๋ จ๋œ ์ •๋ณด๋Š” ์•„๋ž˜๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”.

 

Sphere์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•ฉ๋‹ˆ๋‹ค.

์ด Sphere๋Š” ๊ด‘์„ ์˜ ๋์— ์žˆ๋Š” ์ ๊ณผ ๊ฐ™์€ ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

์ปจํŠธ๋กค๋Ÿฌ ์„ค์ •

'LeftHandAnchor'๊ณผ 'RightHandAnchor'์— 'CustomHandLeft'์™€ 'CustomHandRight'๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.

CustomHandLeft์™€ CustomHandRight๋Š” Oculus ํŒจํ‚ค์ง€์—์„œ ์ œ๊ณตํ•˜๋Š” ์† ๋ชจ๋ธ Prefab์ž…๋‹ˆ๋‹ค.

์‹คํ–‰ ์‹œ ์‹ค์ œ ์†์˜ ์›€์ง์ž„์ด ๋ฐ˜์˜๋œ ๋ชจ์Šต์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

CustomHandLeft์™€CustomHandRight์˜ [OVR Grabber - Player]์— OVRPlayerController์„ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.

 

OVRCameraRig์˜ [OVR Manager - Tracking Origin Target]์„ 'Floor Level'๋กœ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.

 

OVRPlayerContoller์˜ OVRPlayerController ์Šคํฌ๋ฆฝํŠธ์—์„œ Enable Linear Movement์™€ Enable Rotation์˜ ์ฒดํฌ๋ฅผ ํ’€์–ด์ค๋‹ˆ๋‹ค.

Main Menu ์”ฌ์—์„œ๋Š” ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์›€์ง์ด์ง€ ๋ชปํ•˜๋„๋ก ํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

 

Main Menu ์ƒ์„ฑ

์ด์ œ ์ธํ„ฐ๋ž™์…˜ํ•  ๋ฉ”๋‰ด๋ฅผ ๋งŒ๋“ค ๊ฑด๋ฐ์š”. ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š” UI ๋””์ž์ธ์ด ์žˆ๋‹ค๋ฉด ๊ทธ๊ฑธ๋กœ ์‚ฌ์šฉํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

Menu Canvas์— [์šฐํด๋ฆญ - UI - Image]๋ฅผ ์„ ํƒํ•˜์—ฌ UI๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

๋ฉ”๋‰ด์˜ ๋ฐฐ๊ฒฝ์ด ๋  ์ด๋ฏธ์ง€๋ถ€ํ„ฐ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด, ์ด๋ฆ„์„ 'Background'๋กœ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.

Width์™€ Height๋ฅผ ์กฐ์ •ํ•˜๊ณ , [Image - Source Image]์— ์‚ฌ์šฉํ•  ์ด๋ฏธ์ง€๋ฅผ ๋„ฃ์–ด์ฃผ์„ธ์š”.

 

[Menu Canvas ์šฐํด๋ฆญ - UI - Button]์„ ์„ ํƒํ•˜์—ฌ ๋ฉ”๋‰ด์—์„œ ์‚ฌ์šฉ๋  Button์„ ์ถ”๊ฐ€ํ•ด๋ด…์‹œ๋‹ค.

TMP Essentials๋ฅผ importํ•˜์ง€ ์•Š์•˜๋‹ค๋ฉด, ์ด๋Ÿฐ ์ฐฝ์ด ๋œฐํ…๋ฐ์š”.

TextMeshPro๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด import ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค.

์œ„์˜ Background์ฒ˜๋Ÿผ Button์˜ ์ด๋ฆ„์„ 'Start Btn'์œผ๋กœ ์„ค์ •ํ•˜๊ณ , Width, Height, Source Image๋ฅผ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.

 

Text Input์—๋Š” 'START'๋ผ๊ณ  ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค. Font Size๋„ ์กฐ์ •ํ•ด์ฃผ์„ธ์š”.

์ €๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์„ค์ •ํ–ˆ๊ณ , Scene ์ฐฝ์—์„œ๋Š” ์ด๋Ÿฐ ๋ชจ์Šต์ž…๋‹ˆ๋‹ค.

 

๊ฐ๊ฐ์˜ ๋ฒ„ํŠผ์€ 'START'์™€ 'ABOUT'๋กœ ๊ตฌ์„ฑ๋ฉ๋‹ˆ๋‹ค.

Start Btn์„ ๋ณต์ œํ•ด์„œ About Btn์„ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”.

 

์ด์ œ ๋กœ๊ณ ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

์•ž์—์„œ์ฒ˜๋Ÿผ [UI - Image]๋ฅผ ์„ ํƒํ•˜๊ณ  ์ด๋ฆ„์„ 'Logo'๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

ํฌ๊ธฐ์™€ ์ด๋ฏธ์ง€๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

 

์ด์ œ ๋ฒ„ํŠผ ๋™์ž‘์„ ์œ„ํ•ด ์Šคํฌ๋ฆฝํŠธ๋ฅผ Menu Canvas์— ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

์Šคํฌ๋ฆฝํŠธ ์ด๋ฆ„์€ 'MenuController'๋กœ ์„ค์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

Start ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด Main ์”ฌ์œผ๋กœ ์ด๋™ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์•„๋ž˜์™€ ๊ฐ™์ด ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

์”ฌ ์ „ํ™˜์„ ์œ„ํ•ด using UnityEngine.SceneManager;๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MenuController : MonoBehaviour
{
    public void StartBtn()
    {
        SceneManager.LoadScene("MainScene");
    }
}

 

์ด์ œ ๋‹ค์‹œ Start ๋ฒ„ํŠผ์œผ๋กœ ๋Œ์•„๊ฐ€์„œ, On Click()์—์„œ +๋ฅผ ๋ˆŒ๋Ÿฌ ํ•ญ๋ชฉ์„ ์ถ”๊ฐ€ํ•œ ๋‹ค์Œ, Menu Canvas ์˜ค๋ธŒ์ ํŠธ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ , [MenuController - StartBtn()]์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด Start ๋ฒ„ํŠผ์„ ๋ˆŒ๋ €์„ ๋•Œ, ์œ„์—์„œ ์ž‘์„ฑํ•œ StartBtn() ํ•จ์ˆ˜๊ฐ€ ์‹คํ–‰๋˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

์ด์ œ About ๋ฒ„ํŠผ์˜ ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

Section์„ ๋‚˜๋ˆ„๊ธฐ ์œ„ํ•ด Menu Canvas ์•„๋ž˜์— ๋นˆ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ์ด๋ฆ„์„ 'Main Section'๊ณผ 'About Section'์œผ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.  ([Menu Canvas ์šฐํด๋ฆญ - Create Empty])

์•ž์—์„œ ๋งŒ๋“ค์—ˆ๋˜ ๋กœ๊ณ ์™€ ๋ฒ„ํŠผ๋“ค์„ Main Section ์•„๋ž˜๋กœ ๋„ฃ๊ณ , ๋น„ํ™œ์„ฑํ™” ์ƒํƒœ๋กœ ๋‘ก๋‹ˆ๋‹ค.

About Section์— Text๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์ด๋ฆ„์„ 'About Paragraph'๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

Text์—๋Š” 'This is about paragraph.'๋ฅผ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

Width, Height, Position, Font Size๋ฅผ ์กฐ์ ˆํ•˜๊ณ , ํ…์ŠคํŠธ ์ •๋ ฌ์„ ๊ฐ€์šด๋ฐ๋กœ ๋งž์ถฅ๋‹ˆ๋‹ค.

์ด์ œ ๋Œ์•„๊ฐ€๊ธฐ ๋ฒ„ํŠผ์„ ๋งŒ๋“ค์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

Main Section์˜ Start Btn์„ ๋ณต์‚ฌํ•˜์—ฌ About Section์— ์ถ”๊ฐ€ํ•˜๊ณ , ์ด๋ฆ„์„ 'Back Btn'์œผ๋กœ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค.

Text์— 'BACK'์„ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

 

On Click()์—๋Š” 'About Section'์„ ๋„ฃ๊ณ , [GameObject - SetActive(bool)] ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด, ๋Œ์•„๊ฐ€๊ธฐ ๋ฒ„ํŠผ์„ ๋ˆŒ๋ €์„ ๋•Œ About Section์ด ๋น„ํ™œ์„ฑํ™” ๋ฉ๋‹ˆ๋‹ค.

์ด์ œ Main Section์„ ํ™œ์„ฑํ™” ํ•ด์ค˜์•ผ ๊ฒ ์ฃ ?

On Click()์— +๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์ถ”๊ฐ€ํ•œ ๋’ค, 'Main Section'์„ ๋„ฃ๊ณ , [GameObject - SetActive(bool)]๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

์ฒดํฌ ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ํ™œ์„ฑํ™”๋ฅผ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

 

Main Section์—์„œ About ๋ฒ„ํŠผ์˜ ํ•จ์ˆ˜๋„ ์„ค์ •ํ•ด์ฃผ์–ด์•ผํ•ฉ๋‹ˆ๋‹ค.

About Section์„ ๋น„ํ™œ์„ฑํ™” ์ƒํƒœ๋กœ ๋‘๊ณ , Main Section์„ ๋‹ค์‹œ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค.

์œ„์—์„œ์™€ ๋ฐ˜๋Œ€๋กœ [About Btn - On Click()]์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

ABOUT์„ ๋ˆŒ๋ €์„ ๋•Œ Main Section์ด ๋น„ํ™œ์„ฑํ™”๋˜๊ณ , About Section์ด ํ™œ์„ฑํ™”๋˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

 

3D Object Interaction

๋ฐฐ๊ฒฝ ์„ค์ • ๋ฐ ์˜ค๋ธŒ์ ํŠธ ๋ฐฐ์น˜

์ƒˆ๋กœ์šด Scene์„ ์ƒ์„ฑํ•˜๊ณ  ์ด๋ฆ„์„ 'MainScene'๋กœ ์„ค์ •ํ•œ ํ›„, ์”ฌ์„ ์—ด์–ด์ฃผ์„ธ์š”.

Build Settings์— ์ง€๊ธˆ๊นŒ์ง€ ๋งŒ๋“  Scene๋“ค์„ ์ถ”๊ฐ€ํ•ด์ฃผ์–ด์•ผ ์”ฌ ์ „ํ™˜์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

 

์•ž์—์„œ์ฒ˜๋Ÿผ MainScene์— Floor, OVRPlayerController, UIHelpers๋ฅผ ๋ฐฐ์น˜ํ•ฉ๋‹ˆ๋‹ค.

MainManu ์”ฌ์—์„œ ๊ทธ๋Œ€๋กœ ๋ณต์‚ฌํ•ด์™€๋„ ๋ฉ๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์ธํ„ฐ๋ž™์…˜์„ ํ•  3D Object๋ฅผ ๋ฐฐ์น˜ํ•ฉ๋‹ˆ๋‹ค.

Cube, Sphere, Capsule์„ ์ถ”๊ฐ€ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

์ƒˆ๋กœ์šด Material์„ ๋งŒ๋“ค์–ด ๊ฐ๊ฐ Blue, Green, Red๋กœ ์„ค์ •ํ•œ ํ›„ ์œ„์—์„œ ๋งŒ๋“  Object์— ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.

 

์ปจํŠธ๋กค๋Ÿฌ ์„ค์ •

Main Menu Scene๊ณผ ๋‹ค๋ฅด๊ฒŒ ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์›€์ง์ผ ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

OVRPlayerContoller์˜ OVRPlayerController ์Šคํฌ๋ฆฝํŠธ์—์„œ Enable Linear Movement์™€ Enable Rotation์˜ ์ฒดํฌ๋ฅผ ํ™•์ธํ•ด์ฃผ์„ธ์š”.

 

3D Object์™€ ์ƒํ˜ธ์ž‘์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก[OVRPlayerController - OVRCameraRig]์— 'OVRPhysicsRaycaster' ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

[Layer - Add Layer]๋ฅผ ํ†ตํ•ด 'UICollider' ๋ ˆ์ด์–ด๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ , [OVR Physics Raycaster - Event Mask]๋ฅผ UICollider๋กœ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

Event Trigger ์„ค์ •

์•ž์—์„œ ๋งŒ๋“ค์—ˆ๋˜ ์„ธ ์˜ค๋ธŒ์ ํŠธ์™€ Interaction์„ ํ•  ๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์ด๋ฒคํŠธ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.


Cube: ์ƒ‰์ƒ ๋ณ€ํ™”(Blue → Green)
Sphere: Y์ถ• ๋“œ๋ž˜๊ทธ
Capsule: Y, Z์ถ• ๋“œ๋ž˜๊ทธ

์„ธ 3D ์˜ค๋ธŒ์ ํŠธ์— Event Trigger ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

Cube์˜ Event๋Š” ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค.

'Add New Event Type'์„ ํด๋ฆญํ•ด 'PointerClick'์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

Cube ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๋„ฃ๊ณ , [MeshRenderer - Material material]์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.
๊ทธ๋ฆฌ๊ณ  ์•ž์—์„œ ๋งŒ๋“ค์—ˆ๋˜ Green์„ ๋„ฃ์Šต๋‹ˆ๋‹ค.

์ด๋ ‡๊ฒŒ ์„ค์ •ํ•˜๋ฉด Pointer๋กœ Triggerํ•  ๋•Œ ์ง€์ •ํ•œ ์ƒ‰์ƒ์œผ๋กœ ๋ณ€๊ฒฝ๋˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

์ด์ œ ๋“œ๋ž˜๊ทธ ๊ธฐ๋Šฅ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด 'DragUI'๋ผ๋Š” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

using UnityEngine;

public class DragUI : MonoBehaviour
{
    public Transform pointer;

    [Header("Select To Include In Drag")]
    public bool x;
    public bool y;
    public bool z;

    public void Drag()
    {
        float newX = x ? pointer.position.x : transform.position.x;
        float newY = y ? pointer.position.y : transform.position.y;
        float newZ = z ? pointer.position.z : transform.position.z;
        transform.position = new Vector3(newX, newY, newZ);
    }
}

Drag() ํ•จ์ˆ˜๋Š” ๊ฒŒ์ž„ ์˜ค๋ธŒ์ ํŠธ์˜ position์˜ x, y, z ๊ฐ’์„ ์ƒˆ๋กœ์šด x, y, z๊ฐ’์œผ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.์ฆ‰, ๋“œ๋ž˜๊ทธํ•œ ๋ฐฉํ–ฅ์œผ๋กœ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ์ด๋™ํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

 

ํ•ด๋‹น ์Šคํฌ๋ฆฝํŠธ๋ฅผ Sphere๊ณผ Capsule์— ๋„ฃ์–ด์ค๋‹ˆ๋‹ค.

Pointer์—๋Š” UIHelpers์˜ Sphere์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. (์”ฌ์— ๋ฐฐ์น˜ํ•œ ์ดˆ๋ก์ƒ‰ Sphere๊ณผ ์ฐฉ๊ฐํ•˜์ง€ ์•Š๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.)

Select To Include In Drag๋Š”, Sphere์˜ ๊ฒฝ์šฐ Y๋ฅผ, Capsule์˜ ๊ฒฝ์šฐ Y์™€ Z๋ฅผ ์ฒดํฌํ•ฉ๋‹ˆ๋‹ค.


์ด์ œ [Event Trigger - Add New Event Type - Drag]๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

๊ฐ๊ฐ์˜ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๋„ฃ๊ณ , [DragUI - Drag()]๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

์„ธ ์˜ค๋ธŒ์ ํŠธ์˜ Layer๋ฅผ UICollider๋กœ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

๊ฒฐ๊ณผ

 

์‹คํ–‰ ์˜ค๋ฅ˜์™€ ๊ด€๋ จํ•œ ๋‚ด์šฉ๋„ ์•„๋ž˜์— ์ž‘์„ฑํ•ด๋‘๊ฒ ์Šต๋‹ˆ๋‹ค.

๋”๋ณด๊ธฐ

1. ์นด๋ฉ”๋ผ๊ฐ€ ์›€์ง์ด์ง€ ์•Š๋Š” ๊ฒฝ์šฐ, Scene์—์„œ Main Camera ์˜ค๋ธŒ์ ํŠธ๋ฅผ ์‚ญ์ œํ–ˆ๋Š”์ง€ ํ™•์ธํ•ด์ฃผ์„ธ์š”.

2. Oculus์™€ ์—ฐ๊ฒฐ์ด ๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ, VR ํ™˜๊ฒฝ ์„ธํŒ…์„ ์™„๋ฃŒํ–ˆ๋Š”์ง€ ํ™•์ธํ•ด์ฃผ์„ธ์š”.

Android๋กœ Switch Platform
XR Plug-in Management ์„ค์ •
Player Setting - Other Settings - Identification - Minimum API Level

ํ”„๋กœ์ ํŠธ ์ ์šฉ

์•ž์„œ ์„ค๋ช…ํ•œ ๊ธฐ๋Šฅ๋“ค์ด ํ”„๋กœ์ ํŠธ์—์„œ ์–ด๋–ป๊ฒŒ ์ ์šฉ๋˜์—ˆ๋Š”์ง€ ๋ณด์—ฌ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค.

City

City List: ํ”„๋กœ๊ทธ๋žจ ์‹œ์ž‘ ์‹œ ๋ฐฉ๋ฌธํ•  ๋„์‹œ๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

City: ๋„์‹œ์—์„œ ์ž‘ํ’ˆ์„ ์ƒ์„ฑํ•  ์œ„์น˜๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

Exhibit

์•ž์—์„œ ์ƒ์„ฑํ•œ ์ž‘ํ’ˆ์„ ์ „์‹œํ•ฉ๋‹ˆ๋‹ค.

(*๊ฐ๊ฐ ํŠธ๋ฆฌ๊ฑฐ ์‹œ ๋ฐœ์ƒํ•˜๋Š” ์ด๋ฒคํŠธ ๊ธฐ๋Šฅ์€ VR ๋ฐฑ์—”๋“œ ๋‹ด๋‹น ํŒ€์›์ด ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค.)

 

 


์ดํ›„ ๊ณ„ํš

1. ์ž…๋ ฅ์„ ์œ„ํ•œ VR ๊ฐ€์ƒ ํ‚ค๋ณด๋“œ๋ฅผ ๋งŒ๋“ค๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

2. ๊ทธ๋™์•ˆ ๊ธฐ๋Šฅ ๊ตฌํ˜„์— ์ดˆ์ ์„ ๋‘์–ด ๊ฐ„๋‹จํ•˜๊ฒŒ๋งŒ ๋งŒ๋“ค์—ˆ๋˜ UI์˜ ๋””์ž์ธ์„ ๋ณ€๊ฒฝํ•ด๋ณผ๊นŒ ํ•ฉ๋‹ˆ๋‹ค.

 

์ด์ œ ์กธ์—… ๋ฐœํ‘œ๊นŒ์ง€ ์–ผ๋งˆ ๋‚จ์ง€ ์•Š์•˜๋„ค์š”.

์ €ํฌ ํ”„๋กœ์ ํŠธ Paint the City์— ๋งŽ์€ ๊ด€์‹ฌ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค. :D


์ฐธ๊ณ 

์ด๋ฒˆ ํฌ์ŠคํŠธ์˜ ์œ ๋‹ˆํ‹ฐ ํ”„๋กœ์ ํŠธ๋ฅผ ๊นƒํ—ˆ๋ธŒ์— ์—…๋กœ๋“œํ•ด๋‘์—ˆ์Šต๋‹ˆ๋‹ค. ์ฐธ๊ณ ํ•œ ๋™์˜์ƒ ๋งํฌ๋„ ๊ฐ™์ด ์ฒจ๋ถ€ํ•ฉ๋‹ˆ๋‹ค.