using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
public GameObject obj1;
public GameObject obj2;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
drawCylinder(obj1.transform.position,obj2.transform.position);
}
private Dictionary<int, Mesh> _meshMap = new Dictionary<int, Mesh>();
private void drawCylinder(Vector3 a, Vector3 b)
{
float length = (a - b).magnitude;
Graphics.DrawMesh(getCylinderMesh(length),
Matrix4x4.TRS(a, Quaternion.LookRotation(b - a), Vector3.one),obj1.GetComponent<MeshRenderer>().material
,
gameObject.layer);
}//通过obj1.GetComponent<MeshRenderer>().material改圆柱材质
private Mesh getCylinderMesh(float length)
{
int lengthKey = Mathf.RoundToI