当前位置:网站首页>UI draw line
UI draw line
2022-06-22 07:36:00 【Liam666】
using System.Collections.Generic;
using UnityEngine;
public class UIDrawLine : MonoBehaviour
{
private List<RectTransform> _lineRect = new List<RectTransform>();
private Transform _lines;
// Draw a line
private void CreateLine()
{
for (int i = 0; i < _lineRect.Count; i++)
{
if (i == _lineRect.Count - 1) return;
Vector2 lineStart = _lineRect[i].anchoredPosition;
Vector2 lineEnd = _lineRect[i + 1].anchoredPosition;
GameObject line = PoolManager.instance.getItem("LiveCenterWindow", AssetBundleType.UI, "Line");
line.SetActive(true);
line.transform.SetParent(_lines);
line.transform.localScale = Vector3.one;
line.transform.SetSiblingIndex(0);
// Adjust height to proper sizing
RectTransform rectTrans = line.GetComponent<RectTransform>();
float tempHeight = Vector2.Distance(lineStart, lineEnd);
rectTrans.sizeDelta = new Vector2(rectTrans.rect.width, tempHeight);
// Adjust rotation and placement
rectTrans.rotation = HelperRotate2D(lineStart, lineEnd);
rectTrans.anchoredPosition = lineStart;
}
}
private static Quaternion HelperRotate2D (Vector3 start, Vector3 end)
{
Vector3 diff = start - end;
diff.Normalize();
float rotZ = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg;
return Quaternion.Euler(0f, 0f, rotZ - 90f);
}
}
边栏推荐
- EditText and Scrollview focus grabbing
- How to backup the treasures in the store and upload them to multiple stores
- Flutter gets the context, and flutter gets the DOM element location
- 【圖論常見模板題】4種最短路解法和2種最小生成樹解法
- Notes on algebra 10.1: understanding of symmetric polynomials and derivation of cubic resolvents
- antd 框架:点击链接重开浏览器页面——基础积累
- Application and problem solving of robotframework
- 微信小游戏(一)
- Taobao store backup one store upload to multiple stores precautions
- [multi thread programming] thread scheduling strategy and priority
猜你喜欢

Detailed explanation of capturing the whole store treasure and uploading it to multiple stores

Open source get through version - integral function

How to upload Taobao tmall products with one click

How to backup the treasures in the store and upload them to multiple stores

Tikz learning notes (IV) further exploration of circle and complex geometry

Antd - a-upload-dragger drag upload component - Basic accumulation

Remote Desktop Manager

Get through - coupons

A training summary of Intranet penetration test

Vue failed to connect to MySQL database
随机推荐
True MySQL interview question (19) -- Tiktok -- select the list of users who have logged in for two consecutive days every month
Open version - inventory description
C语言实现的简易考试系统
Crmeb open version 4.3
Kuangshi brain++ Tianyuan platform megstudio
Wechat applet service provider sub merchant payment order interface
Chromedriver所有版本下載
selenium防爬和模拟手机浏览器
3、 Stylesheet component
EditText and Scrollview focus grabbing
2 lines of text on the right of the left Avatar
Detr3d model source code Guide & mmdetection3d construction process
Crmeb mall distribution function
网站的排名对于网站很重要
Major enterprises are losing money one after another. Where will the environmental protection industry go?
Do you want to modify the title of the website
JS 数组扁平化 (递归写法)
JS native implementation for loop rendering array
Selenium anti crawl and analog mobile browser
DETR3D模型源码导读 & MMDetection3D构建流程