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 = ...
随机推荐
- Epplus DataTable一次性导出
public void Export() { string fileName = ""; if (string.IsNullOrEmpty(fileName) == true) { ...
- angular2--Tour of Heroes学习和分析--路由
引入路由模块时的一个报错 No base href set. Please provide a value for the APP_BASE_HREF token or add a base elem ...
- 论文阅读(Weilin Huang——【arXiv2016】Accurate Text Localization in Natural Image with Cascaded Convolutional Text Network)
Weilin Huang——[arXiv2016]Accurate Text Localization in Natural Image with Cascaded Convolutional Tex ...
- maven中target不能访问
原因是maven clean的时候已经把target文件夹删除 但是文件夹还存在页面中 所以我们看得到但是不能打开.正常操作是获得管理员权限删除后再重新clean,但是我电脑有360,直接360 ...
- Object类的wait方法带参数和notifyAll方法
相当于sleep( 5000 ) , 效果一样:
- Python-----多线程threading用法
threading模块是Python里面常用的线程模块,多线程处理任务对于提升效率非常重要,先说一下线程和进程的各种区别,如图 概括起来就是 IO密集型(不用CPU) 多线程计算密集型(用CPU) 多 ...
- Appium(二)---启动App+模拟滑动
环境搭建好了,就可以实现基本的操作,比如启动App和模拟滑动.这里我实现的是在真机(乐视1s)上启动抖音App,并滑动抖音的视频列表,代码如下: from appium import webdrive ...
- springmvc整合swagger
前言 Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参数和模型紧密集 ...
- C语言实例:结构体
结构体: #include <stdio.h> #include <stdlib.h> //#pragma pack(1) typedef struct{ short i; / ...
- C 语言多线程与锁机制
C 语言多线程与锁机制 多线程 #include <pthread.h> void *TrainModelThread(void *id) { ... pthread_exit(NULL) ...