当前位置:网站首页>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 .
边栏推荐
- Final review of information and network security (full version)
- Quick start of Hongmeng system
- Solid principle
- 02个人研发的产品及推广-短信平台
- [VNCTF 2022]ezmath wp
- 2021-03-22 "display login screen during recovery" can't be canceled. The appearance of lock screen interface leads to the solution that the remotely connected virtual machine can't work normally
- 基于LNMP部署flask项目
- 视频融合云平台EasyCVR增加多级分组,可灵活管理接入设备
- CTF reverse entry question - dice
- Huawei certified cloud computing hica
猜你喜欢

Development and practice of lightweight planning service tools

PyTorch 提取中间层特征?

Flink analysis (II): analysis of backpressure mechanism

C # nanoframework lighting and key esp32

分布式(一致性协议)之领导人选举( DotNext.Net.Cluster 实现Raft 选举 )

Start job: operation returned an invalid status code 'badrequst' or 'forbidden‘

Flink parsing (III): memory management

02 personal developed products and promotion - SMS platform

Huawei certified cloud computing hica

关于Selenium启动Chrome浏览器闪退问题
随机推荐
C# NanoFramework 点灯和按键 之 ESP32
C# WinForm中DataGridView单元格显示图片
OpenCV中如何使用滚动条动态调整参数
Single responsibility principle
The most complete tcpdump and Wireshark packet capturing practice in the whole network
The art of Engineering (2): the transformation from general type to specific type needs to be tested for legitimacy
Xin'an Second Edition: Chapter 23 cloud computing security requirements analysis and security protection engineering learning notes
Xin'an Second Edition: Chapter 24 industrial control safety demand analysis and safety protection engineering learning notes
远程代码执行渗透测试——B模块测试
Xin'an Second Edition: Chapter 12 network security audit technology principle and application learning notes
C#WinForm中的dataGridView滚动条定位
Xin'an Second Edition; Chapter 11 learning notes on the principle and application of network physical isolation technology
C # nanoframework lighting and key esp32
Xin'an Second Edition: Chapter 25 mobile application security requirements analysis and security protection engineering learning notes
Debug xv6
Flink parsing (III): memory management
Interpretation of Flink source code (I): Interpretation of streamgraph source code
DataGridView scroll bar positioning in C WinForm
C version selenium operation chrome full screen mode display (F11)
Flink analysis (I): basic concept analysis