using System; using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 两点测距脚本 /// public class TwoPointsRanging : RangingLineType { private void Start() { variableX = 5f; variableY = 18f; variableZ = 5f; } public override void HandleOther(bool flag) { if (!flag) { RangSpecialTreat(); } InstanceMeshText(flag); } /// /// 显示米数 /// /// 第一个碰撞点 /// 第二个碰撞点 /// 标记起点米数 /// public void InstanceMeshText(bool flag) { GameObject TwoPointMeshText = Instantiate(Resources.Load("Prefab/Lines/Ranging"), placementPos, Quaternion.identity) as GameObject; TwoPointMeshText.transform.parent = transform; TwoPointMeshText.transform.localScale = new Vector3(2, 2, 1); RangList.Add(TwoPointMeshText); if (!flag) { TwoPointMeshText.transform.Find("text").GetComponent().text = "0"; } else { float distance = Vector3.Distance(placementPos, placementPos2); TwoPointMeshText.transform.position = placementPos2; TwoPointMeshText.transform.Find("text").GetComponent().text = Math.Round(distance, 2).ToString(); placementPos = new Vector3(0, 0, 0); placementPos2 = new Vector3(0, 0, 0); } } }