유니티

유니티VR - PaletteMgr.cs

hololol 2019. 7. 23. 10:39
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
 
public class PaletteMgr : MonoBehaviour
{
    //왼손 컨트롤러의 Input Source
    public SteamVR_Input_Sources lefthand = SteamVR_Input_Sources.LeftHand;
 
    //트랙패드의 클릭 여부
    public SteamVR_Action_Boolean trackPad = SteamVR_Actions.default_Teleport;
 
    //트랙패드의 터치 위치
    public SteamVR_Action_Vector2 trackPadPosition = SteamVR_Actions.default_TrackpadPosition;
 
    private void Update()
    {
        //트랙패드를 클릭했을 경우
        if (trackPad.GetStateDown(lefthand))
        {
            //트랙패드의 터치 위치값을 추출
            Vector2 touchPos = trackPadPosition.GetAxis(lefthand);
 
             
            if (touchPos.x >= 0.2f)
            {
                //트랙패드의 오른쪽 부분을 터치했을 경우
                //90도씩 회전값을 누적해 감소
                iTween.RotateAdd(this.gameObject, iTween.Hash("y"-90.0f, "time"0.2f, "easetype", iTween.EaseType.easeOutBounce));
            }
 
            else if (touchPos.x <= -0.2f)
            {
                //트랙패드의 왼쪽 부분을 터치했을 경우
                //90도씩 회전값을 누적해 증가
                iTween.RotateAdd(this.gameObject, iTween.Hash("y"90.0f, "time"0.2f, "easetype", iTween.EaseType.easeOutBounce));
            }
        }
    }
}
 
cs