12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using System;
- using UnityEngine;
- using Valve.VR;
- public class ViveBaseStationHide : AVRTrackingObjectsMgr
- {
- private void Awake()
- {
- this.m_TrackObjs = base.GetComponentsInChildren<SteamVR_TrackedObject>(true);
- }
- private void OnEnable()
- {
- this.OnTrackedDeviceRoleChanged(new object[0]);
- for (int i = 0; i < SteamVR.connected.Length; i++)
- {
- if (SteamVR.connected[i])
- {
- this.OnDeviceConnected(new object[]
- {
- i,
- true
- });
- }
- }
- SteamVR_Utils.Event.Listen("device_connected", new SteamVR_Utils.Event.Handler(this.OnDeviceConnected));
- SteamVR_Utils.Event.Listen("TrackedDeviceRoleChanged", new SteamVR_Utils.Event.Handler(this.OnTrackedDeviceRoleChanged));
- SteamVR_Utils.Event.Listen("render_model_loaded", new SteamVR_Utils.Event.Handler(this.OnRenderModelLoaded));
- }
- private void OnDisable()
- {
- SteamVR_Utils.Event.Remove("device_connected", new SteamVR_Utils.Event.Handler(this.OnDeviceConnected));
- SteamVR_Utils.Event.Remove("TrackedDeviceRoleChanged", new SteamVR_Utils.Event.Handler(this.OnTrackedDeviceRoleChanged));
- SteamVR_Utils.Event.Remove("render_model_loaded", new SteamVR_Utils.Event.Handler(this.OnRenderModelLoaded));
- }
- private void OnTrackedDeviceRoleChanged(params object[] args)
- {
- this.Refresh();
- }
- private void OnDeviceConnected(params object[] args)
- {
- uint num = (uint)((int)args[0]);
- bool flag = (bool)args[1];
- this.Refresh();
- }
- private void OnRenderModelLoaded(params object[] args)
- {
- this.Refresh();
- }
- public override void Refresh()
- {
- this.m_TrackObjs = base.GetComponentsInChildren<SteamVR_TrackedObject>(true);
- this.m_listTrackTracker.Clear();
- for (int i = 0; i < this.m_TrackObjs.Length; i++)
- {
- CVRSystem system = OpenVR.System;
- if (system != null)
- {
- SteamVR_TrackedObject.EIndex index = this.m_TrackObjs[i].index;
- if (system.GetTrackedDeviceClass((uint)index) == ETrackedDeviceClass.TrackingReference)
- {
- MeshRenderer component = this.m_TrackObjs[i].GetComponent<MeshRenderer>();
- if (component != null)
- {
- component.enabled = false;
- }
- }
- else
- {
- MeshRenderer component2 = this.m_TrackObjs[i].GetComponent<MeshRenderer>();
- if (component2 != null)
- {
- component2.enabled = true;
- }
- }
- if (system.GetTrackedDeviceClass((uint)index) == (ETrackedDeviceClass)3 && this.m_TrackObjs[i].isValid)
- {
- this.m_listTrackTracker.Add(this.m_TrackObjs[i].transform);
- }
- }
- }
- }
- private void Update()
- {
- }
- private SteamVR_TrackedObject[] m_TrackObjs;
- }
|