2021년 4학년 1학기 기업연계프로젝트2 컴퓨터소프트웨어공학과 <원광투어팀> 팀장 : 송유진 팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

53 lines
1.6 KiB

//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
namespace Valve.VR.InteractionSystem.Sample
{
public class TargetMeasurement : MonoBehaviour
{
public GameObject visualWrapper;
public Transform measurementTape;
public Transform endPoint;
public Text measurementTextM;
public Text measurementTextFT;
public float maxDistanceToDraw = 6f;
public bool drawTape = false;
private float lastDistance;
private void Update()
{
if (Camera.main != null)
{
Vector3 fromPoint = Camera.main.transform.position;
fromPoint.y = endPoint.position.y;
float distance = Vector3.Distance(fromPoint, endPoint.position);
Vector3 center = Vector3.Lerp(fromPoint, endPoint.position, 0.5f);
this.transform.position = center;
this.transform.forward = endPoint.position - fromPoint;
measurementTape.localScale = new Vector3(0.05f, distance, 0.05f);
if (Mathf.Abs(distance - lastDistance) > 0.01f)
{
measurementTextM.text = distance.ToString("00.0m");
measurementTextFT.text = (distance * 3.28084).ToString("00.0ft");
lastDistance = distance;
}
if (drawTape)
visualWrapper.SetActive(distance < maxDistanceToDraw);
else
visualWrapper.SetActive(false);
}
}
}
}