VR¿¡¼ Gaze Æ÷ÀÎÅÍ°¡ UGUI SliderÀ§¿¡ ÀÖÀ»¶§ ÁøÇà¹Ù¸¦ ½Ã°£¿¡ µû¶ó¼ ÁøÇà ½ÃÄÑ º¸ÀÚ. ½ÇÇàȸéÀº ´ÙÀ½°ú °°´Ù. 1. UI > canvas¸¦ Ãß°¡ÇÑ´Ù.2. Slider¸¦ Ãß°¡ÇÑ´Ù.3. Canvas¿¡ GvrPionterGraphicRaycaster¸¦ Ãß°¡ÇÑ´Ù."Graphic Raycater" ÄÄÆ÷³ÍÆ®´Â ÇØÁ¦ÇÑ´Ù.4. "Handle Slide Area"¸¦ Á¦°ÅÇÑ´Ù.
5. Fill ¿ÀºêÁ§Æ®ÀÇ Width¸¦ 0À¸·Î ¼³Á¤ÇÑ´Ù.¿ÞÂÊÀÇ ¿øÀÌ »ç¶óÁ³´Ù. 6. Fill Area ¿ÀºêÁ§Æ®ÀÇ Left, Right°ªÀ» 0À¸·Î ¼³Á¤ÇÑ´Ù.
7. InteractableÀ» ÇØÁ¦ÇÏ°í TransitionÀ» ÇØÁ¦ÇÑ´Ù.¾ÆÁ÷±îÁö Ä¿¼ Æ÷ÀÎÅÍ°¡ Ŭ¸¯ÇϱâÀü±îÁö ½½¶óÀÌ´õ À§¿¡ Ä¿¼°¡ À§Ä¡ÇØ ¹ÝÀÀÀÌ ¾ø´Ù. 8. Slider ¿ÀºêÁ§Æ®¿¡ EventTrigger¸¦ Ãß°¡ÇÑ´Ù.½½¶óÀÌ´õÀ§¿¡ Ä¿¼°¡ À§Ä¡Çϸé Ä¿¼°¡ Ä¿Áø´Ù. 9. VRSlider ½ºÅ©¸³Æ®¸¦ ÀÛ¼ºÇÏ°í Slider ÄÄÆ÷³ÍÆ®·Î Ãß°¡ÇÑ´Ù.VRSlider.cs ÆÄÀÏusing UnityEngine;
using UnityEngine.UI; using System.Collections; public class VRSlider : MonoBehaviour { public float fillTime = 2f; Slider mySlider; private float timer; private bool gazedAt; private Coroutine fillBarRoutine; // Use this for initialization void Start() { mySlider = GetComponent<Slider>(); if (mySlider == null) Debug.Log("Please add a Slider Component to this GameObject!"); } // Update is called once per frame void Update() { } public void PointerEnter() { gazedAt = true; fillBarRoutine = StartCoroutine(FillBar()); } public void PointerExit() { gazedAt = false; if (fillBarRoutine != null) { StopCoroutine(fillBarRoutine); } timer = 0f; mySlider.value = 0f; } //Fill the Bar IEnumerator FillBar() { timer = 0f; while (timer < fillTime) { timer += Time.deltaTime; mySlider.value = timer / fillTime; yield return null; if (gazedAt) continue; timer = 0f; mySlider.value = 0f; yield break; } //The bar has been filled OnBarFilled(); } private void OnBarFilled() { Debug.Log("Do Something Amazing!!!"); } } 10. Slider ¿ÀºêÁ§Æ® - EventTrigger¿¡ "PointerEnter", "PointerExit" À̺¥Æ®¸¦ Ãß°¡ÇÏ°í VRSlider ½ºÅ©¸³Æ®ÀÇ PointerEnter, PointExit ÇÔ¼ö¿Í ¿¬°áÇÑ´Ù.½Ã°£¿¡ µû¸¥ ÁøÇà¹Ù·Î »ç¿ëÇÒ·Á¸é SliderÀÇ "Eventer Trigger"¸¦ Á¦°ÅÇÏ°í VRSlider.PointerEnter¸¦ È£ÃâÇÏ¸é µÈ´Ù. Âü°í) https://www.youtube.com/watch?v=x0CAZYvrzGM |