当前位置:网站首页>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 .
边栏推荐
- Kernel link script parsing
- mysql高级(索引,视图,存储过程,函数,修改密码)
- Error: Publish of Process project to Orchestrator failed. The operation has timed out.
- Total / statistics function of MySQL
- The art of Engineering (1): try to package things that do not need to be exposed
- Yarn: unable to load file d:\programfiles\nodejs\yarn PS1, because running scripts is prohibited on this system
- Grafana 9 正式发布,更易用,更酷炫了!
- [introduction to MySQL] third, common data types in MySQL
- Precipitated database operation class - version C (SQL Server)
- 2022年大厂Android面试题汇总(二)(含答案)
猜你喜欢
C WinForm series button easy to use
C version selenium operation chrome full screen mode display (F11)
EasyRE WriteUp
JUnit unit test
[getting started with MySQL] fourth, explore operators in MySQL with Kiko
Re signal writeup
学 SQL 必须了解的 10 个高级概念
Spark calculation operator and some small details in liunx
Vscode replaces commas, or specific characters with newlines
当前系统缺少NTFS格式转换器(convert.exe)
随机推荐
Grafana 9 is officially released, which is easier to use and more cool!
沉淀下来的数据库操作类-C#版(SQL Server)
CTF reverse entry question - dice
Spark accumulator and broadcast variables and beginners of sparksql
Display picture of DataGridView cell in C WinForm
Example of batch update statement combining update and inner join in SQL Server
Xin'an Second Edition: Chapter 12 network security audit technology principle and application learning notes
C# NanoFramework 点灯和按键 之 ESP32
BearPi-HM_ Nano development environment
Flink parsing (IV): recovery mechanism
mysql高级(索引,视图,存储过程,函数,修改密码)
Chrome prompts the solution of "your company management" (the startup page is bound to the company's official website and cannot be modified)
04 products and promotion developed by individuals - data push tool
07个人研发的产品及推广-人力资源信息管理系统
应用服务配置器(定时,数据库备份,文件备份,异地备份)
[rapid environment construction] openharmony 10 minute tutorial (cub pie)
Uipath browser performs actions in the new tab
Establishment of graphical monitoring grafana
06个人研发的产品及推广-代码统计工具
[ciscn 2021 South China]rsa writeup