当前位置:网站首页>Unity tips - draw aiming Center
Unity tips - draw aiming Center
2022-07-06 17:41:00 【sesame seeds】
- Click the jump =>《 Navigation post 》- Unity manual , Systematic practical learning
- Click the jump =>《 Navigation post 》- Android manual , Revisit mobile development
This article is about 2 Thousand characters , Novice reading needs 4 minute , Review needs 1 minute 【 Collect at any time, no longer get lost 】
About author
as everyone knows , Life is a long process , constantly overcome difficulties , Constantly reflect on the process of progress . In this process, there will be a lot of questions and thoughts about life , So I decided to put my thinking , Share all your experiences and stories , To find resonance !!!
Focus on Android/Unity And various game development skills , as well as Share various resources ( Website 、 Tools 、 material 、 Source code 、 Games etc. )
If you need anything, welcome me , Communication groups make learning No longer alone .
Practice process
Preview effect
In fact, it's very simple to implement , It only needs Rect Classes and DrawTexture The method can .
Let's see. Rect Parameter description inside ,
Rect(float x, float y, float width, float height)
Parameter one : At the top left corner of the rectangle x spot
Parameter two : At the top left corner of the rectangle y spot
Parameter 3 : At the top right corner of the rectangle x spot
Parameter 4 : At the top right corner of the rectangle y spot
This is a rectangle
We're looking DrawTexture Method , Pass two parameters , Parameter 1 is rectangle , The second parameter is the texture painted by the target .
public class Test : MonoBehaviour
{
public Texture texture;
void OnGUI()
{
// >>1 and /2 It's the same
// Draw centroid - This is the matrix size set according to the size of the texture
// Rect rect = new Rect(Input.mousePosition.x - (texture.width >> 1),
// Screen.height - Input.mousePosition.y - (texture.height >> 1), texture.width, texture.height);
// GUI.DrawTexture(rect, texture);
// This is the specified matrix size , No matter how big the texture , Will zoom in
int widthAndHeight = 10;
Rect rect = new Rect(Input.mousePosition.x - widthAndHeight / 2, Screen.height - Input.mousePosition.y - widthAndHeight / 2, widthAndHeight, widthAndHeight);
GUI.DrawTexture(rect, texture);
}
}
other
author : Xiaokong and Xiaozhi Xiaokong
Reprint note - Be sure to indicate the source :https://zhima.blog.csdn.net/
This Taoist friend, please Step back ️, I watch you Extraordinary bearing , There is a king's domineering spirit in his speech , There will be a great achievement in the future !!! There is give the thumbs-up Collection Today I tell you , Have you ordered it , Your success in the future ️, I don't take a penny , If it doesn't work ️, Or come back to me .
reminder : Click the card below to get more unexpected resources .
边栏推荐
- Xin'an Second Edition: Chapter 23 cloud computing security requirements analysis and security protection engineering learning notes
- About selenium starting Chrome browser flash back
- Flink parsing (VII): time window
- Optimization of middle alignment of loading style of device player in easycvr electronic map
- 04个人研发的产品及推广-数据推送工具
- Sqoop I have everything you want
- Flink parsing (IV): recovery mechanism
- Detailed explanation of data types of MySQL columns
- Flink parsing (III): memory management
- Flink parsing (V): state and state backend
猜你喜欢
[getting started with MySQL] fourth, explore operators in MySQL with Kiko
Application service configurator (regular, database backup, file backup, remote backup)
关于Selenium启动Chrome浏览器闪退问题
Re signal writeup
TCP连接不止用TCP协议沟通
04个人研发的产品及推广-数据推送工具
Interpretation of Flink source code (II): Interpretation of jobgraph source code
Uipath browser performs actions in the new tab
轻量级计划服务工具研发与实践
[reverse intermediate] eager to try
随机推荐
EasyRE WriteUp
基于LNMP部署flask项目
About selenium starting Chrome browser flash back
How does wechat prevent withdrawal come true?
应用服务配置器(定时,数据库备份,文件备份,异地备份)
EasyCVR电子地图中设备播放器loading样式的居中对齐优化
Vscode replaces commas, or specific characters with newlines
2022年大厂Android面试题汇总(一)(含答案)
[translation] principle analysis of X Window Manager (I)
TCP连接不止用TCP协议沟通
PyTorch 提取中间层特征?
Guidelines for preparing for the 2022 soft exam information security engineer exam
[VNCTF 2022]ezmath wp
03个人研发的产品及推广-计划服务配置器V3.0
Flink analysis (I): basic concept analysis
Kali2021 installation and basic configuration
Xin'an Second Edition: Chapter 24 industrial control safety demand analysis and safety protection engineering learning notes
How to submit data through post
The art of Engineering (3): do not rely on each other between functions of code robustness
PySpark算子处理空间数据全解析(4): 先说说空间运算