zoukankan      html  css  js  c++  java
  • 3D空间 圆柱体画线

    //添加一个圆柱体

    //添加多个Cube

    //切记:脚本不能绑定在圆柱体上,会因为不断调用自身而造成死循环。

    using UnityEngine;
    using System.Collections;
    
    public class StartDrawLine : MonoBehaviour
    {
        public GameObject Line;//圆柱体用于画线条;
        public Transform[] WayPoints;
        int i = 0;
    void Update() { if (i < WayPoints.Length - 1) { Vector3 tempPos = (WayPoints[i].position + WayPoints[i + 1].position) / 2;//计算两个点的中间点坐标 GameObject go = (GameObject)Instantiate(Line, tempPos, Quaternion.identity);//在物体的中点处实例化,物体的缩放从中间向两侧延伸 go.name = "" + i; go.transform.right = (go.transform.position - WayPoints[i].position).normalized;//改变线条的朝向 float distance = Vector3.Distance(WayPoints[i].position, WayPoints[i + 1].position);//计算两点间的距离 go.transform.localScale = new Vector3(distance, 0.01f, 0.01f);//延长线条连接两点 i++; Debug.Log(i); } } }
  • 相关阅读:
    windows下命令行
    利用border画三角形
    正则
    flex布局
    css笔记
    W3C标准
    SEO相关
    左边固定,右边自适应(解决方案)
    容错性测试的测试点
    Charles安装及使用教程
  • 原文地址:https://www.cnblogs.com/Cocomo/p/5755531.html
Copyright © 2011-2022 走看看