public void LoadProvider() { ARFoundationSessionProvider.RequireARSession(); // Create platform specific rig and mapping #if UNITY_IOS var rigSettings = ARKitBodyRigSettings.instance; SetupRigInstance(rigSettings.ControlRig); m_JointToTransform = rigSettings.GenerateJointMapping(m_BodyRigInstance); #endif var currentSession = ARFoundationSessionProvider.currentSession; if (currentSession) { var currentSessionGameObject = currentSession.gameObject; m_ARHumanBodyManager = Object.FindObjectOfType <ARHumanBodyManager>(); if (!m_ARHumanBodyManager) { m_ARHumanBodyManager = currentSessionGameObject.AddComponent <ARHumanBodyManager>(); m_ARHumanBodyManager.hideFlags = HideFlags.DontSave; m_NewARHumanBodyManager = m_ARHumanBodyManager; } m_ARHumanBodyManager.humanBodiesChanged += ARBodyManagerOnBodiesChanged; } AddExistingTrackables(); }
public void UnloadProvider() { m_ARHumanBodyManager.humanBodiesChanged -= ARBodyManagerOnBodiesChanged; ClearTrackables(); if (m_NewARHumanBodyManager) { UnityObjectUtils.Destroy(m_NewARHumanBodyManager); } if (m_BodyRigInstance) { UnityObjectUtils.Destroy(m_BodyRigInstance); m_BodyRigInstance = null; m_BodyRigAnimator = null; m_BodyPoseExtractor = null; } ARFoundationSessionProvider.TearDownARSession(); }