资源简介
基于Unity引擎编写的适合在3D场景中内画平滑线的脚本,无需修改可直接使用,仅供学习参考。
代码片段和文件信息
using System;
using System.Collections;
using System.Reflection;
using UnityEngine;
public class example : MonoBehaviour {
public Transform[] Target = new Transform[5];
public Vector3[] TargetV3 = new Vector3[5];
private LineRenderer lineRenderer;
private int SmoothSens = 20;
private int Targetlenght = 0;
void Start(){
Targetlenght = Target.Length;
}
void Update() {
Targetlenght = Target.Length;
for (int i = 0; i < Targetlenght; i++)
{
TargetV3[i] = Target[i].position;
}
DrawPathHelper(TargetV3Color.red);
}
public void DrawPathHelper(Vector3[] path Color color){
Targetlenght = Target.Length;
SmoothSens = 20;
lineRenderer = GetComponent();
lineRenderer.SetVertexCount(SmoothSens*Targetlenght+1);
lineRenderer.SetWidth(0.1f 0.1f);
Vector3[] vector3s = PathControlPointGenerator(path);
Vector3 prevPt = Interp(vector3s0);
Gizmos.color=color;
int SmoothAmount = path.Length*SmoothSens;
for (int i = 1; i <= SmoothAmount; i++) {
float pm = (float) i / SmoothAmount;
Vector3 currPt = Interp(vector3spm);
lineRenderer.SetPosition(i-1 currPt);
lineRenderer.SetPosition(i prevPt);
prevPt = currPt;
}
}
public Vector3[] PathControlPointGenerator(Vector3[] path){
Vector3[] suppliedPath;
Vector3[] vector3s;
//create and store path points:
suppliedPath = path;
//populate calculate path;
int offset = 2;
- 上一篇:网上购物系统的设计与实现源代码
- 下一篇:Unity Windows Speech
相关资源
- Unity Windows Speech
- 《Unity5实战使用C#和Unity开发多平台游
- Unity5麦克风录音Record MicroPhone Audio 更
- Unity麦克风录音Record MicroPhone Audio
- Unity测距脚本
- 一套类moba的教学视频百度云地址
- Unity网络正常状态下优先加载网络图片
- Unity3D虚拟现实开发之标签跟随功能
- Unity面试题30题含答案——C#基础.
- unity模型贴图滚动脚本
- 跑酷游戏源码
- unity3d 连接外置摄像头
-
Js to CSharp sc
ript converter - unity上传文件7牛云存储服务器
- 鱼类游动代码
- unity旋转,缩放,移动控制脚本
- unity旧粒子系统转换为新粒子系统
- MoveCamera.cs
- Unity3D场景中对模型旋转放大缩小脚本
- unity3d实现物体透明渐变效果
- 使用C#在Unity中制作VR游戏
- Unity项目对齐地面功能
- Unity5实战使用C#和Unity开发多平台游戏
- 可视化调节曲线运动Unity插件
- SwitchClick.cs
- c# 排序算法诠释排序过程
- Unity\“I18N.West\“
- c#开发,unity环境,计算器,支持四则
- unity3D简易计算器C#脚本代码
- LitJson.dll C# 与 unity 可用的Json处理插
评论
共有 条评论