当前位置:网站首页>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层)
边栏推荐
- Socket回顾与I/0模型
- Go1.18 upgrade function - Fuzz test from scratch in Go language
- [QNX Hypervisor 2.2用户手册]9.14 set
- ThreadLocal
- 返回一个零长度的数组或者空的集合,不要返回null
- linux view redis version command (linux view mysql version number)
- AI automatic code writing plugin Copilot (co-pilot)
- PCB stackup design
- find prime numbers up to n
- Architecture Battalion Module 8 Homework
猜你喜欢
Architecture Battalion Module 8 Homework
idea中搜索具体的字符内容的快捷方式
Qualcomm cDSP simple programming example (to query Qualcomm cDSP usage, signature), RK3588 npu usage query
顺序表的实现
第六章
Flink_CDC construction and simple use
Student management system on the first day: complete login PyQt5 + MySQL5.8 exit the operation logic
Redis Overview: Talk to the interviewer all night long about Redis caching, persistence, elimination mechanism, sentinel, and the underlying principles of clusters!...
Apache EventMesh distributed event-driven multi-runtime
请问我的这段sql中sql语法哪里出了错
随机推荐
Socket回顾与I/0模型
Several methods of mysql backup table
cas and spin locks (is lightweight locks spin locks)
The whole network is on the verge of triggering, and the all-round assistant for content distribution from media people - Rongmeibao
请问我的这段sql中sql语法哪里出了错
The principle of ReentrantLock (to be continued)
Socket Review and I/0 Model
What's wrong with the sql syntax in my sql
PCB叠层设计
ReentrantLock原理(未完待续)
「APIO2010」巡逻 题解
The article you worked so hard to write may not be your original
Chapter Six
Mobile web development 02
统计UTF-8字符串中的字符函数
A shortcut to search for specific character content in idea
BM3 将链表中的节点每k个一组翻转
Verilog implements a divide-by-9 with a duty cycle of 5/18
One thing to say, is outsourcing company worth it?
Quick Start Tutorial for flyway