Hololens缩放物体源码(待完善)
Posted 北田
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hololens缩放物体源码(待完善)相关的知识,希望对你有一定的参考价值。
using UnityEngine; using System.Collections; public class ScaleQuad : MonoBehaviour { public GameObject master; //Empty before the Quad public GameObject quad; //The Quad I want to scale Raycast hitInfo; private Vector3 offsetOld; void Update() { var headPosition = Camera.main.transform.position; var gazeDirection = Camera.main.transform.forward; if (Physics.Raycast(headPosition, gazeDirection, out hitInfo)) { //Create the offset offset = hitInfo.point - master.transform.position; // To get the new offset between hitpoint and master.transform.position for the new size Vector3 diff = offset - offsetOld; vFBMaster.transform.position = new Vector3((diff.x + master.transform.position.x), (diff.y + master.transform.position.y), master.transform.position.z); quad.transform.localScale = new Vector3((diff.x / 2) + quad.transform.localScale.x, (diff.y / 2) + quad.transform.localScale.y, quad.transform.localScale.z); Debug.Log(diff); //To save the old offset offsetOld = offset; Debug.Log("Old Offset = " + offsetOld); Debug.Log("new Offset = " + offset); } } }
以上是关于Hololens缩放物体源码(待完善)的主要内容,如果未能解决你的问题,请参考以下文章
HoloLens开发手记 - Unity之World Anchor空间锚
Hololens官方教程精简版 - 08. Sharing holograms(共享全息影像)
Hololens官方教程精简版 - 08. Sharing holograms(共享全息影像)