The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Tap To Place Bug?
Hi everyone. Im running into issues with TapToPlace that I cant seem to figure out.
I attach TapToPlace from the HoloToolkit on my object. When I launch in the emulator everything works as expected. When I launch to the device after placing and moving a couple of times all code after SpatialMappingManager.Instance.DrawVisualMeshes = true; no longer runs. Here is some code I was testing with. Im changing the color of the cube I am using to move things around to see what is happening. The first few times the cube goes back and forth between blue and red as expected but after about the third time the cube goes black and never gets to blue. The Spatial Mapping Manager draws meshes as expected. Am I missing something?
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using UnityEngine;
namespace HoloToolkit.Unity
{
///
/// public partial class TapToPlace : MonoBehaviour { bool placing = false; public GameObject myItem; public GameObject myAudio; // Called by GazeGestureManager when the user performs a tap gesture. void OnSelect() { if (SpatialMappingManager.Instance != null) { // On each tap gesture, toggle whether the user is in placing mode. placing = !placing; // If the user is in placing mode, display the spatial mapping mesh. if (placing) { gameObject.GetComponent<Renderer>().material.color = Color.black; SpatialMappingManager.Instance.DrawVisualMeshes = true; gameObject.GetComponent<Renderer>().material.color = Color.blue; } // If the user is not in placing mode, hide the spatial mapping mesh. else { SpatialMappingManager.Instance.DrawVisualMeshes = false; gameObject.GetComponent<Renderer>().material.color = Color.red; } } else { Debug.Log("TapToPlace requires spatial mapping. Try adding SpatialMapping prefab to project."); } } // Update is called once per frame. void Update() { // If the user is in placing mode, // update the placement to match the user's gaze. if (placing) { // Do a raycast into the world that will only hit the Spatial Mapping mesh. var headPosition = Camera.main.transform.position; var gazeDirection = Camera.main.transform.forward; RaycastHit hitInfo; if (Physics.Raycast(headPosition, gazeDirection, out hitInfo, 30.0f, SpatialMappingManager.Instance.LayerMask)) { // Move this object to where the raycast // hit the Spatial Mapping mesh. // Here is where you might consider adding intelligence // to how the object is placed. For example, consider // placing based on the bottom of the object's // collider so it sits properly on surfaces. this.transform.position = hitInfo.point; // Rotate this object to face the user. Quaternion toQuat = Camera.main.transform.localRotation; toQuat.x = 0; toQuat.z = 0; this.transform.rotation = toQuat; } } } }
}
Best Answer
-
OptionsPatrick mod
Yes, I believe there is a bug. I just pushed what I think is the fix. The DrawVisualMeshes property had the potential to access a renderer that had been deleted.
Can you either pull or update UpdateRendering in SpatialMappingManager.cs with:
private void UpdateRendering(bool Enable) { List<MeshRenderer> renderers = Source.GetMeshRenderers(); for (int index = 0; index < renderers.Count; index++) { if (renderers[index] != null) { renderers[index].enabled = Enable; if (Enable) { renderers[index].sharedMaterial = SurfaceMaterial; } } } }
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.(Daddy, what does 'now formatting drive C:' mean?)
6
Answers
@AWarren,
Yes, I believe there is a bug. I just pushed what I think is the fix. The DrawVisualMeshes property had the potential to access a renderer that had been deleted.
Can you either pull or update UpdateRendering in SpatialMappingManager.cs with:
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.
(Daddy, what does 'now formatting drive C:' mean?)
That did the trick! Thanks so much!
Thanks for reporting the issue.
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.
(Daddy, what does 'now formatting drive C:' mean?)