void OnEnable() { ivrRift = (IVR_RiftGearVR) target; ivr = ivrRift.GetComponent<InstantVR>(); if (ivr != null) { riftHead = ivr.headTarget.GetComponent<IVR_RiftGearVRHead>(); if (riftHead == null) { riftHead = ivr.headTarget.gameObject.AddComponent<IVR_RiftGearVRHead>(); riftHead.extension = ivrRift; } IVR_Extension[] extensions = ivr.GetComponents<IVR_Extension>(); if (ivrRift.priority == -1) ivrRift.priority = extensions.Length - 1; for (int i = 0; i < extensions.Length; i++) { if (ivrRift == extensions[i]) { while (i < ivrRift.priority) { MoveUp(riftHead); ivrRift.priority--; //Debug.Log ("Rift Move up to : " + i + " now: " + ivrRift.priority); } while (i > ivrRift.priority) { MoveDown(riftHead); ivrRift.priority++; //Debug.Log ("Rift Move down to : " + i + " now: " + ivrRift.priority); } } } } }
void OnDestroy() { if (ivrRift == null && ivr != null) { riftHead = ivr.headTarget.GetComponent<IVR_RiftGearVRHead>(); if (riftHead != null) DestroyImmediate(riftHead, true); } }