Esempio n. 1
0
        // TODO See if this method can be removed, it appears to not be used at all and it can be misleading when debugging.
        /// <summary>
        /// Instantiates a <see cref="VRControllerVisual"/> for a limb.
        /// </summary>
        /// <param name="limb">The limb for the controller.</param>
        /// <returns>The newly instantiated controller visual for the specified limb, or null if no controller visual was able to be created.</returns>
        public VRControllerVisual InstantiateControllerVisual(IVRAvatarLimb limb)
        {
            if (limb == null)
            {
                throw new ArgumentNullException("limb");
            }

            if (limb.LimbType == VRAvatarLimbType.Head)
            {
                return(null);
            }

            var prefab   = VRAvatarHelper.EnsureLoadPrefab <VRControllerVisual>(ControllerVisualPrefabName);
            var instance = Instantiate(prefab);

            var ovrController = instance.GetComponent <UnityXRControllerVisual>();

            ovrController.m_controller = GetControllerTypeForLimb(limb);
            ovrController.m_modelGearVrController.SetActive(true);
            ovrController.enabled = false;

            instance.gameObject.SetActive(true);

            return(instance);
        }
Esempio n. 2
0
        private void SetupCameraRig()
        {
            var cameraRigPrefab = VRAvatarHelper.EnsureLoadPrefab <GearVRCameraRig>("GearVRCameraRig");

            cameraRigPrefab.gameObject.SetActive(false);
            mCameraRig = Instantiate(cameraRigPrefab);
            mCameraRig.transform.SetParentAndIdentity(mAvatar.Auxiliaries);

            OnActiveCameraChanged(mAvatar.Head);
        }
Esempio n. 3
0
        private void AttachControllerVisual(VRAvatarController avatarController)
        {
            var limb = avatarController.GetComponentInParent <IVRAvatarLimb>();

            var prefab = VRAvatarHelper.EnsureLoadPrefab <VRControllerVisual>(ControllerVisualPrefabName);

            prefab.gameObject.SetActive(false);

            // Create controller instance
            var instance = Instantiate(prefab);

            instance.name = prefab.name;
            instance.transform.SetParentAndIdentity(avatarController.transform);

            // Make sure the OVRGearVrController component exists...
            var trackedRemote = instance.gameObject.GetComponent <OVRControllerHelper>();

            if (trackedRemote == null)
            {
                trackedRemote = instance.gameObject.AddComponent <OVRControllerHelper>();
            }

            avatarController.ControllerVisual = instance;
            mRemotes.Add(trackedRemote);

            // Assign the correct controller based on the limb type the controller is attached to
            OVRInput.Controller controllerType = GetControllerTypeForLimb(limb);
            trackedRemote.m_controller = controllerType;
            trackedRemote.m_modelGearVrController.SetActive(true);

            // Activate the controller
            // TODO Do we need to set active here?
            var active = OVRUtils.IsLimbConnected(limb.LimbType);

            instance.gameObject.SetActive(active);

            Debug.Log($"Attached Controller: {limb.LimbType} and SetActive: {active} Controller Type set to: {controllerType}");
        }