博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【Unity】LineRenderer
阅读量:4087 次
发布时间:2019-05-25

本文共 1111 字,大约阅读时间需要 3 分钟。

using UnityEngine;using System.Collections;public class MyLine : MonoBehaviour{	private LineRenderer _line;	private Vector3 _mouse3Dpos;	private int _index= 0;	private int _lengthOfLineRenderer = 0;	void Start()	{		_line = GetComponent
(); _line.material = new Material(Shader.Find("Particles/Additive")); _line.SetColors (Color.red, Color.black); _line.SetWidth (0.02f, 0.02f); } void Update() {// if (Input.GetMouseButton(0)) { _mouse3Dpos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x,Input.mousePosition.y,1.0f)); // //// } transform.Translate (new Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"))); if (Input.GetAxis("Horizontal")!=0 || Input.GetAxis("Vertical")!=0 ) { LineSetVerterCount (); _mouse3Dpos = transform.position; } while (_index < _lengthOfLineRenderer) { _line.SetPosition (_index, _mouse3Dpos); _index++; } if (Input.GetKeyDown(KeyCode.Q)) { _lengthOfLineRenderer = 0; _index = 0; _line.SetVertexCount (0); } } void LineSetVerterCount() { _lengthOfLineRenderer++; _line.SetVertexCount (_lengthOfLineRenderer); }}

转载地址:http://gfkii.baihongyu.com/

你可能感兴趣的文章
Python - time库
查看>>
DL编程遇到的问题,记录下
查看>>
deeplearning.ai - 深度学习的实用层面
查看>>
Python - 程序的控制结构
查看>>
Python - random库
查看>>
Tensorflow 学习记录
查看>>
deeplearning.ai - 优化算法 (Optimization Algorithms)
查看>>
Python - 函数和代码复用
查看>>
deeplearning.ai - 超参数调试、Batch正则化、程序框架
查看>>
deeplearning.ai - 机器学习策略 (1)
查看>>
deeplearning.ai - 机器学习策略 (2)
查看>>
deeplearning.ai - 目标检测 Detection algorithms
查看>>
Python - 组合数据类型
查看>>
Python - 文件和数据格式化
查看>>
deeplearning.ai - 人脸识别和神经风格转换
查看>>
Python - 计算生态概览
查看>>
deeplearning.ai - 循环神经网络 (Recurrent Neural Networks)
查看>>
课后练习 - 测验2: Python基础语法(上) (第4周)
查看>>
课后练习 - 测验3: Python基础语法(下) (第7周)
查看>>
课后练习 - 测验4: 全课程综合测验 (考试周)
查看>>