private void ConfigureHelpers() { Transform head = transform.Find("body/body_renderPart_0/root_JNT/body_JNT/chest_JNT/neckBase_JNT/neck_JNT/head_JNT"); if (head == null) { AvatarLogger.LogError("Avatar helper config failed. Cannot find head transform. All helpers spawning on root avatar transform"); head = transform; } if (MouthAnchor == null) { MouthAnchor = CreateHelperObject(head, MOUTH_HEAD_OFFSET, MOUTH_HELPER_NAME); } if (GetComponent<OvrAvatarLocalDriver>() != null) { if (audioSource == null) { audioSource = MouthAnchor.gameObject.AddComponent<AudioSource>(); } spatializedSource = MouthAnchor.GetComponent<ONSPAudioSource>(); if (spatializedSource == null) { spatializedSource = MouthAnchor.gameObject.AddComponent<ONSPAudioSource>(); } spatializedSource.UseInvSqr = true; spatializedSource.EnableRfl = false; spatializedSource.EnableSpatialization = true; spatializedSource.Far = 100f; spatializedSource.Near = 0.1f; // Add phoneme context to the mouth anchor lipsyncContext = MouthAnchor.GetComponent<OVRLipSyncContext>(); if (lipsyncContext == null) { lipsyncContext = MouthAnchor.gameObject.AddComponent<OVRLipSyncContext>(); } lipsyncContext.provider = EnableLaughter ? OVRLipSync.ContextProviders.Enhanced_with_Laughter : OVRLipSync.ContextProviders.Enhanced; // Ignore audio callback if microphone is owned by VoIP lipsyncContext.skipAudioSource = !CanOwnMicrophone; StartCoroutine(WaitForMouthAudioSource()); } if (GetComponent<OvrAvatarRemoteDriver>() != null) { GazeTarget headTarget = head.gameObject.AddComponent<GazeTarget>(); headTarget.Type = ovrAvatarGazeTargetType.AvatarHead; AvatarLogger.Log("Added head as gaze target"); Transform hand = transform.Find("hand_left"); if (hand == null) { AvatarLogger.LogWarning("Gaze target helper config failed: Cannot find left hand transform"); } else { GazeTarget handTarget = hand.gameObject.AddComponent<GazeTarget>(); handTarget.Type = ovrAvatarGazeTargetType.AvatarHand; AvatarLogger.Log("Added left hand as gaze target"); } hand = transform.Find("hand_right"); if (hand == null) { AvatarLogger.Log("Gaze target helper config failed: Cannot find right hand transform"); } else { GazeTarget handTarget = hand.gameObject.AddComponent<GazeTarget>(); handTarget.Type = ovrAvatarGazeTargetType.AvatarHand; AvatarLogger.Log("Added right hand as gaze target"); } } }
void Start() { if (OvrAvatarSDKManager.Instance == null) { return; } #if !UNITY_ANDROID if (CombineMeshes) { CombineMeshes = false; AvatarLogger.Log("Combined Meshes currently only supported on mobile"); } #endif #if !UNITY_5_5_OR_NEWER if (CombineMeshes) { CombineMeshes = false; AvatarLogger.LogWarning("Combined Meshes requires Unity 5.5.0+"); } #endif materialManager = gameObject.AddComponent <OvrAvatarMaterialManager>(); try { oculusUserIDInternal = UInt64.Parse(oculusUserID); } catch (Exception) { oculusUserIDInternal = 0; AvatarLogger.LogWarning("Invalid Oculus User ID Format"); } // If no oculus ID is supplied then turn off combine meshes to prevent the texture arrays // being populated by invalid textures. if (oculusUserIDInternal == 0) { AvatarLogger.LogWarning("Oculus User ID set to 0. Provide actual user ID: " + gameObject.name); CombineMeshes = false; } AvatarLogger.Log("Starting OvrAvatar " + gameObject.name); AvatarLogger.Log(AvatarLogger.Tab + "LOD: " + LevelOfDetail.ToString()); AvatarLogger.Log(AvatarLogger.Tab + "Combine Meshes: " + CombineMeshes); AvatarLogger.Log(AvatarLogger.Tab + "Force Mobile Textures: " + USE_MOBILE_TEXTURE_FORMAT); AvatarLogger.Log(AvatarLogger.Tab + "Oculus User ID: " + oculusUserIDInternal); Capabilities = 0; if (EnableBody) { Capabilities |= ovrAvatarCapabilities.Body; } if (EnableHands) { Capabilities |= ovrAvatarCapabilities.Hands; } if (EnableBase && EnableBody) { Capabilities |= ovrAvatarCapabilities.Base; } if (EnableExpressive) { Capabilities |= ovrAvatarCapabilities.Expressive; } // Enable body tilt on 6dof devices if (OVRPlugin.positionSupported) { Capabilities |= ovrAvatarCapabilities.BodyTilt; } ShowLeftController(StartWithControllers); ShowRightController(StartWithControllers); OvrAvatarSDKManager.AvatarSpecRequestParams avatarSpecRequest = new OvrAvatarSDKManager.AvatarSpecRequestParams( oculusUserIDInternal, this.AvatarSpecificationCallback, CombineMeshes, LevelOfDetail, USE_MOBILE_TEXTURE_FORMAT, LookAndFeelVersion, FallbackLookAndFeelVersion, EnableExpressive); OvrAvatarSDKManager.Instance.RequestAvatarSpecification(avatarSpecRequest); OvrAvatarSDKManager.Instance.AddLoadingAvatar(GetInstanceID()); waitingForCombinedMesh = CombineMeshes; if (Driver != null) { Driver.Mode = UseSDKPackets ? OvrAvatarDriver.PacketMode.SDK : OvrAvatarDriver.PacketMode.Unity; } }