123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using System;
- using UnityEngine;
- public class OvrHandItemMgr : MonoBehaviour
- {
- public int ModelNum
- {
- get
- {
- return this.m_goItem.Length;
- }
- }
- public void SetButtons(AVRControllerButtons f_buttons)
- {
- this.m_buttons = f_buttons;
- }
- private void Awake()
- {
- this.m_vBackPos = base.transform.localPosition;
- }
- private void Start()
- {
- this.ChangeModel(0);
- }
- private void OnEnable()
- {
- if (OvrIK.IsModeVRIK)
- {
- if (this.m_ctrl != null)
- {
- if (this.m_ctrl.m_bHandL)
- {
- base.transform.localPosition = new Vector3(0.009f, -0.068f, -0.109f);
- }
- else
- {
- base.transform.localPosition = new Vector3(-0.021f, -0.044f, -0.1f);
- }
- }
- }
- else
- {
- base.transform.localPosition = this.m_vBackPos;
- }
- }
- public void ChangeModel(int f_nType)
- {
- for (int i = 0; i < this.m_goItem.Length; i++)
- {
- GameObject gameObject = this.m_goItem[i];
- if (i == f_nType)
- {
- gameObject.SetActive(true);
- }
- else
- {
- gameObject.SetActive(false);
- }
- }
- }
- public void NextModel()
- {
- this.m_nModel++;
- if (this.m_goItem.Length <= this.m_nModel)
- {
- this.m_nModel = 0;
- }
- this.ChangeModel(this.m_nModel);
- }
- private void Update()
- {
- if (this.m_buttons != null)
- {
- if (this.m_buttons.GetPressDown(AVRControllerButtons.BTN.VIRTUAL_MENU))
- {
- this.m_fMenuPressBeforeTime = Time.realtimeSinceStartup;
- }
- else if (this.m_buttons.GetPress(AVRControllerButtons.BTN.VIRTUAL_MENU) && Time.realtimeSinceStartup - this.m_fMenuPressBeforeTime > 1f)
- {
- this.NextModel();
- this.m_fMenuPressBeforeTime = Time.realtimeSinceStartup;
- }
- }
- }
- public GameObject[] m_goItem = new GameObject[1];
- public AVRControllerBehavior m_ctrl;
- private Vector3 m_vBackPos;
- private AVRControllerButtons m_buttons;
- private int m_nModel;
- private float m_fMenuPressBeforeTime;
- }
|