Hololens V1 – Spatial Mapping

Import HoloToolkit 2017.4.3.0
Hierarchy : Add HoloLensCamera, InputManager, DefaultCursor, SpatialMapping
Publishing Setting, Capabilities : Check SpatialPerception

Then we can access environment mesh that the Hololens perceive. (we can select to show or hide mesh in SpatialMapping prefab)

This program will draw a line as we click on room positions.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DrawLineByPoints : MonoBehaviour
{
    private LineRenderer lr;
    private List<Vector3> points;

    private void Awake()
    {
        lr = GetComponent<LineRenderer>();
        points = new List<Vector3>();
    }

    public void SetUpLine(List<Vector3> points)
    {
        lr.positionCount = points.Count;
        this.points = points;
    }

    private void Update()
    {
        for(int i=0;i<points.Count;i++)
        {
            lr.SetPosition(i,points[i]);
            //Debug.Log(points[i].position);
        }
    }
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HoloToolkit.Unity.InputModule;

public class PointAdding : MonoBehaviour, IInputClickHandler
{
    [SerializeField] private DrawLineByPoints line;
    private List<Vector3> positions;

    void Start()
    {
        positions = new List<Vector3>();
        InputManager.Instance.PushFallbackInputHandler(gameObject);
    }

    public void OnInputClicked(InputClickedEventData eventData)
    {
        Debug.Log("\nOnInputClicked");
        Vector3 hitPoint = GazeManager.Instance.HitPosition;

        Debug.Log("Click on " + hitPoint.ToString());
        positions.Add(hitPoint);

        line.SetUpLine(positions); 
    }
}