当前位置:网站首页>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 .
边栏推荐
- Wordcloud colormap color set and custom colors
- [translation] principle analysis of X Window Manager (I)
- 02个人研发的产品及推广-短信平台
- Guidelines for preparing for the 2022 soft exam information security engineer exam
- BearPi-HM_ Nano development environment
- MySQL Advanced (index, view, stored procedures, functions, Change password)
- C WinForm series button easy to use
- Redis quick start
- Run xv6 system
- 分布式(一致性协议)之领导人选举( DotNext.Net.Cluster 实现Raft 选举 )
猜你喜欢
EasyCVR平台通过接口编辑通道出现报错“ID不能为空”,是什么原因?
Development and practice of lightweight planning service tools
关于Selenium启动Chrome浏览器闪退问题
Solution qui ne peut pas être retournée après la mise à jour du navigateur Web flutter
The problem of "syntax error" when uipath executes insert statement is solved
学 SQL 必须了解的 10 个高级概念
Huawei certified cloud computing hica
2022年大厂Android面试题汇总(二)(含答案)
Display picture of DataGridView cell in C WinForm
05个人研发的产品及推广-数据同步工具
随机推荐
网络分层概念及基本知识
Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
Precipitated database operation class - version C (SQL Server)
Pyspark operator processing spatial data full parsing (4): let's talk about spatial operations first
Flink analysis (II): analysis of backpressure mechanism
Sqoop I have everything you want
02 personal developed products and promotion - SMS platform
[ASM] introduction and use of bytecode operation classwriter class
Application service configurator (regular, database backup, file backup, remote backup)
Solr appears write Lock, solrexception: could not get leader props in the log
微信小程序获取手机号
The most complete tcpdump and Wireshark packet capturing practice in the whole network
connection reset by peer
Single responsibility principle
Kali2021 installation and basic configuration
How does wechat prevent withdrawal come true?
Based on infragistics Document. Excel export table class
C# NanoFramework 点灯和按键 之 ESP32
C# WinForm系列-Button简单使用
C # nanoframework lighting and key esp32