标签:direct unity size object empty forward ant set blog
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); } } }
标签:direct unity size object empty forward ant set blog
原文地址:http://www.cnblogs.com/unity3ds/p/6082217.html