LineRenderer实现一个画线组件
using System;
using UnityEngine; class UILine
{
GameObject targetObj;
LineRenderer lineRenderer; //LineRenderer渲染出的线段的两个端点是3D世界中的点
int index = ;
int poinCount = ; //线段的端点数
Vector3 position; public void Start(GameObject go, Color beginColor, Color endColor, float begineWidth, float endWidth)
{
targetObj = go;
if (null != targetObj)
{
targetObj.SetActive(true);
lineRenderer = targetObj.GetComponent<LineRenderer>(); if (null == lineRenderer)
lineRenderer = targetObj.AddComponent<LineRenderer>();
} if (null != lineRenderer)
{
//颜色
lineRenderer.startColor = beginColor;
lineRenderer.endColor = endColor; //宽度
lineRenderer.startWidth = begineWidth;
lineRenderer.endWidth = endWidth;
} index = poinCount = ;
} public void Update()
{
if (Input.GetMouseButton())
{
//屏幕坐标转换为世界坐标
position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 1.0f));
//端点数+1
poinCount++;
//设置线段的端点数
lineRenderer.positionCount = poinCount; //连续绘制线段
while (index < poinCount)
{
//两点确定一条直线,所以我们依次绘制点就可以形成线段了
lineRenderer.SetPosition(index, position);
index++;
}
}
} public static UILine BeginLine(GameObject go, Color beginColor, Color endColor, float beginWidth, float endWidth)
{
UILine line = new UILine();
line.Start(go, beginColor, endColor, beginWidth, endWidth);
return line;
}
}
LineRenderer实现一个画线组件的更多相关文章
- unity3d NavMeshAgent 寻路画线/画路径
今天在群里看见有个小伙在问Game视图寻路时怎么画线 正好前几天写了个寻路,而且自己也不知道具体怎么在寻路时画线,所以决定帮帮他,自己也好学习一下 在百度查了一下资料,直接搜寻路画路径.寻路画线... ...
- Java 从零开始实现一个画图板、以及图像处理功能,代码可复现
Java 从零开始实现一个画图板.以及图像处理功能,代码可复现 这是一个学习分享博客,带你从零开始实现一个画图板.图像处理的小项目,为了降低阅读难度,本博客将画图板的一步步迭代优化过程展示给读者,篇幅 ...
- MFC画线功能总结
本文仅用于学习交流,商业用途请支持正版!转载请注明:http://www.cnblogs.com/mxbs/p/6216464.html MFC画线功能要点有二:其一,鼠标按下时记录初始位置为线的起始 ...
- MFC消息映射机制以及画线功能实现
---此仅供用于学习交流,切勿用于商业用途,转载请注明http://www.cnblogs.com/mxbs/p/6213404.html. 利用VS2010创建一个单文档标准MFC工程,工程名为Dr ...
- CGContextRef 画线简单用法
CGContextRef CGContextMoveToPoint(context,150,50);//圆弧的起始点 CGContextAddArcToPoint(context,100,80,130 ...
- Android中Path类的lineTo方法和quadTo方法画线的区别
转载:http://blog.csdn.net/stevenhu_223/article/details/9229337 当我们需要在屏幕上形成画线时,Path类的应用是必不可少的,而Path类的li ...
- iOS小画板画线总结
一:基本画线: 使用贝赛尔曲线画: //创建路径 UIBezierPath* aPath = [UIBezierPath bezierPath]; //设置线宽 aPath.lineWidth = 5 ...
- [修复] Firemonkey 画线问题(Android & iOS 平台)
问题:官方 QC 的一个 Firemonkey 移动平台画线问题: RSP-14309: [iOS & Android] Delphi 10.1 Berlin - drawing proble ...
- WPF画线问题,几千条以后就有明显的延迟了。
我现在是这么画的,class A { private GeometryGroup _lines; private Path _path; public A() { _path.Data = ...
随机推荐
- GAITC 2019全球人工智能技术大会(南京)
2019年5月25日至26日,由中国人工智能学会主办,以“交叉.融合.相生.共赢”为主题的2019GAITC将在南京全新亮相. 2019 全球人工智能技术大会(2019 GAITC)以“前端引领.深度 ...
- C++ 自定义订单号
自定义订单号 #include<iostream> #include<stack> #include <time.h> #include <sys/timeb ...
- Zepto源码分析之二(新旧版本zepto.Z方法的区别)
在上一节中讲到Z()方法,是在初始化函数init中直接调用zepto.Z() zepto.Z = function(dom, selector) { dom = dom || [] dom.selec ...
- day13 python迭代器与生成器
迭代器 字符串.列表.元组.字典.集合都可以被for循环,说明他们都是可迭代的 可迭代协议 : 就是内部实现了__iter__方法 可以被for循环的都是可迭代的,要想可迭代,内部必须有一个__ite ...
- 解决多版本共存时,python/pip等命令失效
问题呈现: Windows环境下,多版本Python解释器共存时,由于未配置环境变量或者反复卸载重装解释器等原因,CMD交互下输入Python或者pip等命令时失效 解决方式: 1)配置各个解释器的环 ...
- 求方差分析与两样本T检验 区别
方差分析与两样本T检验. 1.首先可以看到方差分析(ANOVA)包含两样本T检验,把两样本T检验作为自己的特例.因为ANOVA可以比较多个总体的均值,当然包含两个总体作为特例.实际上,T的平方就是F统 ...
- Spring boot 源码分析(一)SpringApplication.run(上)
SpringApplication.run(Main.class, args); 从这个方法开始讲吧: public static ConfigurableApplicationContext run ...
- Simple Factory Pattern
Question: How do you achieve the functions of calculator by Object-Oriented ? Analysis: 1,The functi ...
- eclipse导出maven工程的可执行jar包
一.eclipse导出maven工程的可执行jar包 建立两个maven工程 ZKServer 和ZKClient 注意:用maven进行开发管理的话,默认的打出来的jar包是不能运行的,需要在pom ...
- Windows环境下IOS APP打包上传AppStore详细流程
我们知道在上架苹果应用过程中,申请发布证书需要用到钥匙串,上传ipa需要用到xcode或Application loader提交构建版本,这都需要Mac苹果机. 本文介绍如何在Windows环境下申请 ...