void Update() { GetPose(out pos, out rot, FrameOffset); TransformValidation.ValidatePose(ref pos, ref rot); // Update local transform with pose data from the network. // Use local transform, so we can child this gameobject to the scene anchor. try { if (gameObject.transform.parent != null && gameObject.transform.parent.lossyScale != Vector3.one) { // If the object we are anchored to has a non-identity scale, // the anchor we get from the pose provider will be off by the scale factor. Vector3 scale = gameObject.transform.parent.lossyScale; gameObject.transform.localPosition = new Vector3( UpdateSVTransformFromParentScale(pos.x, scale.x), UpdateSVTransformFromParentScale(pos.y, scale.y), UpdateSVTransformFromParentScale(pos.z, scale.z) ); } else { // Otherwise, our scale is one and we can set the position as we got it. gameObject.transform.localPosition = pos; } gameObject.transform.localRotation = rot; } catch (Exception ex) { Debug.LogWarning("Error getting position and rotation from SV: " + ex.Message); } if (!frameProviderInitialized) { frameProviderInitialized = InitializeFrameProvider(); } UpdateCompositor(); if (spatialMapping == null) { spatialMapping = new SpatialMapping(); } spatialMapping.UpdateSpatialMapping(transform.parent, SpatialMappingMaterial); }
private void Awake() { // Remove the default audio listener, there can only be one at a time. if (Camera.main != null) { AudioListener listener = Camera.main.GetComponent <AudioListener>(); if (listener != null) { listener.enabled = false; } } ResetHologramSynchronization = false; prevSpatialMaterial = SpatialMappingMaterial; spatialMapping = new SpatialMapping(); InvokeRepeating("SendAnchorInformationToPoseProvider", 10, 10); }