private void UpdateOvrSkeleton() { try { FieldInfo skeletonTypeField = m_ovrSkeleton.GetType().GetField("_skeletonType", BindingFlags.NonPublic | BindingFlags.Instance); skeletonTypeField.SetValue(m_ovrSkeleton, m_isLeftHand ? OVRSkeleton.SkeletonType.HandLeft : OVRSkeleton.SkeletonType.HandRight); } catch (Exception e) { Debug.LogError("Failed to update OVRHand: " + e); } }
public void Initialize(bool isLeftHand) { m_isLeftHand = isLeftHand; try { m_ovrHand = gameObject.AddComponent <OVRHand>(); UpdateOvrHand(); m_ovrSkeleton = gameObject.AddComponent <OVRSkeleton>(); UpdateOvrSkeleton(); FieldInfo updateRootScaleField = m_ovrSkeleton.GetType().GetField("_updateRootScale", BindingFlags.NonPublic | BindingFlags.Instance); updateRootScaleField.SetValue(m_ovrSkeleton, true); FieldInfo updateRootPoseField = m_ovrSkeleton.GetType().GetField("_updateRootPose", BindingFlags.NonPublic | BindingFlags.Instance); updateRootPoseField.SetValue(m_ovrSkeleton, true); MethodInfo skeletonInitializeMethod = m_ovrSkeleton.GetType().GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Instance); skeletonInitializeMethod.Invoke(m_ovrSkeleton, new object[] { }); m_ovrMesh = gameObject.AddComponent <OVRMesh>(); UpdateOvrMesh(); MethodInfo meshInitializeMethod = m_ovrMesh.GetType().GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Instance); meshInitializeMethod.Invoke(m_ovrMesh, new object[] { m_isLeftHand?OVRMesh.MeshType.HandLeft: OVRMesh.MeshType.HandRight }); gameObject.AddComponent <OVRMeshRenderer>(); SkinnedMeshRenderer skinnedMeshRenderer = gameObject.AddComponent <SkinnedMeshRenderer>(); skinnedMeshRenderer.material = new Material(Shader.Find("Legacy Shaders/Diffuse")); } catch (Exception e) { Debug.LogError("OculusHandRenderModel initialize failed: " + e); } }