当前位置:网站首页>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层)


边栏推荐
- How to identify fake reptiles?
- Redis综述篇:与面试官彻夜长谈Redis缓存、持久化、淘汰机制、哨兵、集群底层原理!...
- 高通cDSP简单编程例子(实现查询高通cDSP使用率、签名),RK3588 npu使用率查询
- 登录业务实现(单点登录+微信扫码+短信服务)
- Judging decimal points and rounding of decimal operations in Golang
- Realization of character makeup
- Short-circuit characteristics and protection of SiC MOSFETs
- Basic Grammar Introduction of Carbon Tutorial (Tutorial)
- Socket回顾与I/0模型
- 有一说一,外包公司到底值不值得去?
猜你喜欢

STM32 full series development firmware installation guide under Arduino framework

useragent online lookup

高效并发:Synchornized的锁优化详解

In Golang go-redis cluster mode, new connections are constantly created, and the problem of decreased efficiency is solved

Student management system on the first day: complete login PyQt5 + MySQL5.8 exit the operation logic

Efficient Concurrency: A Detailed Explanation of Synchornized's Lock Optimization

Count characters in UTF-8 string function

The whole network is on the verge of triggering, and the all-round assistant for content distribution from media people - Rongmeibao

Federated Learning: Multi-source Knowledge Graph Embedding in Federated Scenarios

Unity-LineRenderer显示一条线
随机推荐
Structure of the actual combat battalion module eight operations
find prime numbers up to n
useragent online lookup
A shortcut to search for specific character content in idea
cas and spin locks (is lightweight locks spin locks)
Niuke.com brush questions (1)
Write a database document management tool based on WPF repeating the wheel (1)
uniapp小程序检查、提示更新
HTC使用官方固件作为底包制作rom卡刷包教程
Shell script quick start to actual combat -02
focus on!Haitai Fangyuan joins the "Personal Information Protection Self-discipline Convention"
Several methods of mysql backup table
Realization of character makeup
Verilog implements a divide-by-9 with a duty cycle of 5/18
【Yugong Series】July 2022 Go Teaching Course 025-Recursive Function
linux view redis version command (linux view mysql version number)
spark reports an error OutOfMemory "recommended collection"
Implementing a Simple Framework for Managing Object Information Using Reflection
server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none failed
【AcWing】The 62nd Weekly Match 【2022.07.30】