using UnityEngine;
using System.Collections.Generic;
using System;
/// <summary>
/// 划线面积,距离,角度
/// </summary>
public class UnderlinedMeasureTool : MonoBehaviour
{
/// <summary>
/// 相机
/// </summary>
public Camera _camera;
public int size = 30;//文字大小
//圆点的预制体
public GameObject aim;
public LineRenderer lineRender;
bool sb = false;
//GL 绘制的顶点数组 顺序是 0->1 2->3 4->5 取法 0 1 3 5 7 9
//参考UI界面
private List<Vector3> lv;//划线的点
private List<Vector3> lv1;//存坐标的点
public List<GameObject> aims;
public int type = 3;
void Start()
{
lv = new List<Vector3>();
lv1 = new List<Vector3>();
aims = new List<GameObject>();
}
void Update()
{
if (Input.GetMouseButtonDown(0))//绘制多边形
{
Ray ray = _camera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, Mathf.Infinity))
{
//创建圆点
GameObject go = Instantiate(aim, new Vector3(hit.point.x, hit.point.y, hit.point.z), Quaternion.Euler(90, 0, 0)) as GameObject;
aims.Add(go);
lv1.Add(hit.point);
if (type == 1)
{
if (lv.Count >= 2)
{
ClearLines();
GameObject go1 = Instantiate(aim, new Vector3(hit.point.x, hit.point.y, hit.point.z), Quaternion.Euler(90, 0, 0)) as G
unity C# 计算3D空间任意多边形面积,距离,角度using UnityEngine;using System.Collections;using System.Collections.Generic;using UnityEngine.UI;using System;/// /// 划线面积,距离,角度/// public class UnderlinedMeasureTool : MonoBehaviour{/// /// 相机/// public Camera _c