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.
47 lines
1.6 KiB
47 lines
1.6 KiB
4 years ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
/// <summary>
|
||
|
/// 两点测距脚本
|
||
|
/// </summary>
|
||
|
public class TwoPointsRanging : RangingLineType
|
||
|
{
|
||
|
private void Start()
|
||
|
{
|
||
|
variableX = 5f;
|
||
|
variableY = 18f;
|
||
|
variableZ = 5f;
|
||
|
}
|
||
|
public override void HandleOther(bool flag)
|
||
|
{
|
||
|
if (!flag) { RangSpecialTreat(); }
|
||
|
InstanceMeshText(flag);
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 显示米数
|
||
|
/// </summary>
|
||
|
/// <param name="placementPos">第一个碰撞点</param>
|
||
|
/// <param name="placementPos2">第二个碰撞点</param>
|
||
|
/// <param name="flag">标记起点米数</param>
|
||
|
/// <param name="hit"></param>
|
||
|
public void InstanceMeshText(bool flag)
|
||
|
{
|
||
|
GameObject TwoPointMeshText = Instantiate(Resources.Load<GameObject>("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<TextMesh>().text = "0";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
float distance = Vector3.Distance(placementPos, placementPos2);
|
||
|
TwoPointMeshText.transform.position = placementPos2;
|
||
|
TwoPointMeshText.transform.Find("text").GetComponent<TextMesh>().text = Math.Round(distance, 2).ToString();
|
||
|
placementPos = new Vector3(0, 0, 0);
|
||
|
placementPos2 = new Vector3(0, 0, 0);
|
||
|
}
|
||
|
}
|
||
|
}
|