当前位置:网站首页>Unity - LineRenderer show a line
Unity - LineRenderer show a line
2022-07-31 22:09:00 【Tiantian up UT】
01 新建一个line的控件
02 Add controls to scripts
03 Control the color of the lines via script,粗细,位置
using UnityEngine;
using System.Collections;
using System.Threading;
using UnityEngine.UI;
public class Demo : MonoBehaviour
{
//游戏对象,Here is the line segment object
public GameObject LineRenderGameObject;
//Line segment renderer
private LineRenderer lineRenderer;
//两个按钮
public Button btn1;
public Button btn2;
[System.Obsolete]
void Start()
{
//通过游戏对象,GetComponent方法 传入LineRenderer
//Just given beforelineRenderer properties added by game objects
//With this object it is possible to render line segments for the game world
lineRenderer = LineRenderGameObject.GetComponent("LineRenderer") as LineRenderer;
if (lineRenderer != null)
{
//设置线的颜色
lineRenderer.startColor = new Color(0, 0, 255, 1);
lineRenderer.endColor = new Color(0, 0, 255, 1);
//Sets the width of the line at the start and end of the line,值越大越宽
lineRenderer.startWidth = 0.05f;
lineRenderer.endWidth = 0.05f;
//Draw two lines,take the starting point(0)和终点(1),The position of the start and end points is that of the buttonposition,直接获取到了ugui的按钮位置,Convert it to world coordinateslineRenderer
lineRenderer.SetPosition(0, btn1.transform.position);
lineRenderer.SetPosition(1, btn2.transform.position);
Debug.Log("btn1.transform.position = "+ btn1.transform.position);
}
}
}
04 设置layer看linerender和canvasWho is in front and behind.(因为linerender不是2d物体,不在canvas层)
边栏推荐
- Chapter VII
- 财务盈利、偿债能力指标
- 全网一触即发,自媒体人的内容分发全能助手——融媒宝
- -xms -xmx(information value)
- Recognize anomalies (you will understand after reading this)
- Implementing a Simple Framework for Managing Object Information Using Reflection
- Mobile web development 02
- 基于STM32 环形队列来实现串口接收数据
- ECCV 2022 Huake & ETH propose OSFormer, the first one-stage Transformer framework for camouflaging instance segmentation!The code is open source!...
- find prime numbers up to n
猜你喜欢
In Golang go-redis cluster mode, new connections are constantly created, and the problem of decreased efficiency is solved
Judging decimal points and rounding of decimal operations in Golang
请问我的这段sql中sql语法哪里出了错
Quick Start Tutorial for flyway
PCB stackup design
flowable workflow all business concepts
第七章
Recognize anomalies (you will understand after reading this)
Flex layout in detail
ThreadLocal
随机推荐
multithreaded lock
Qualcomm cDSP simple programming example (to query Qualcomm cDSP usage, signature), RK3588 npu usage query
renderjs usage in uni-app
STM32 full series development firmware installation guide under Arduino framework
Bika LIMS open source LIMS set - use of SENAITE (detection process)
Arduino框架下STM32全系列开发固件安装指南
高通cDSP简单编程例子(实现查询高通cDSP使用率、签名),RK3588 npu使用率查询
Realize serial port receiving data based on STM32 ring queue
架构实战营模块 8 作业
hboot与recovery、boot.img、system.img
IDA PRO中汇编结构体识别
Introduction to Audio Types and Encoding Formats in Unity
"The core concept of" image classification and target detection in the positive and negative samples and understanding architecture
BM3 将链表中的节点每k个一组翻转
Flex layout in detail
请问我的这段sql中sql语法哪里出了错
【论文精读】iNeRF
[Code Hoof Set Novice Village 600 Questions] Merge two numbers without passing a character array
C language parsing json string (json object is converted to string)
Federated Learning: Multi-source Knowledge Graph Embedding in Federated Scenarios