想做来在3D项目中做标记 直接上代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
[RequireComponent(typeof(MeshRenderer), typeof(MeshFilter))]
public class DrawTriangle : MonoBehaviour
{
public float length = 1;
public float width = 1;
public float height = 1;
private MeshFilter meshFilter;
void Start()
{
meshFilter = GetComponent<MeshFilter>();
meshFilter.mesh = CreateTriangle(length, width, height);
if (this.gameObject.AddComponent<MeshCollider>() == null)
this.gameObject.AddComponent<MeshCollider>();
// this.GetComponent<MeshRenderer>().enabled = false;
this.transform.DOMoveY(this.transform.position.y - 0.3f, 0.5f, false).SetLoops(int.MaxValue, LoopType.Yoyo);
}
private Mesh CreateTriangle(float length, float width, float height)
{
int verticesCount = 4 * 6;//3* 4