首页 > 其他 > 详细

Hololens缩放物体源码(待完善)

时间:2016-11-20 13:14:07      阅读:197      评论:0      收藏:0      [点我收藏+]
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缩放物体源码(待完善)

原文:http://www.cnblogs.com/unity3ds/p/6082217.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!