2021년 4학년 1학기 기업연계프로젝트2
컴퓨터소프트웨어공학과 <원광투어팀>
팀장 : 송유진
팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: UIElement that responds to VR hands and generates UnityEvents
//
//=============================================================================
using UnityEngine;using UnityEngine.Events;using UnityEngine.UI;using System;
namespace Valve.VR.InteractionSystem{ //-------------------------------------------------------------------------
[RequireComponent( typeof( Interactable ) )] public class UIElement : MonoBehaviour { public CustomEvents.UnityEventHand onHandClick;
protected Hand currentHand;
//-------------------------------------------------
protected virtual void Awake() { Button button = GetComponent<Button>(); if ( button ) { button.onClick.AddListener( OnButtonClick ); } }
//-------------------------------------------------
protected virtual void OnHandHoverBegin( Hand hand ) { currentHand = hand; InputModule.instance.HoverBegin( gameObject ); ControllerButtonHints.ShowButtonHint( hand, hand.uiInteractAction); }
//-------------------------------------------------
protected virtual void OnHandHoverEnd( Hand hand ) { InputModule.instance.HoverEnd( gameObject ); ControllerButtonHints.HideButtonHint( hand, hand.uiInteractAction); currentHand = null; }
//-------------------------------------------------
protected virtual void HandHoverUpdate( Hand hand ) { if ( hand.uiInteractAction != null && hand.uiInteractAction.GetStateDown(hand.handType) ) { InputModule.instance.Submit( gameObject ); ControllerButtonHints.HideButtonHint( hand, hand.uiInteractAction); } }
//-------------------------------------------------
protected virtual void OnButtonClick() { onHandClick.Invoke( currentHand ); } }
#if UNITY_EDITOR
//-------------------------------------------------------------------------
[UnityEditor.CustomEditor( typeof( UIElement ) )] public class UIElementEditor : UnityEditor.Editor { //-------------------------------------------------
// Custom Inspector GUI allows us to click from within the UI
//-------------------------------------------------
public override void OnInspectorGUI() { DrawDefaultInspector();
UIElement uiElement = (UIElement)target; if ( GUILayout.Button( "Click" ) ) { InputModule.instance.Submit( uiElement.gameObject ); } } }#endif
}
|