当前位置:网站首页>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 .
边栏推荐
- [reverse primary] Unique
- BearPi-HM_ Nano development board "flower protector" case
- [elastic] elastic lacks xpack and cannot create template unknown setting index lifecycle. name index. lifecycle. rollover_ alias
- 【MySQL入门】第三话 · MySQL中常见的数据类型
- 网络分层概念及基本知识
- connection reset by peer
- [getting started with MySQL] fourth, explore operators in MySQL with Kiko
- 自动答题 之 Selenium测试直接运行在浏览器中,就像真正的用户在操作一样。
- Flink analysis (I): basic concept analysis
- Pyspark operator processing spatial data full parsing (4): let's talk about spatial operations first
猜你喜欢
Vscode matches and replaces the brackets
02个人研发的产品及推广-短信平台
BearPi-HM_ Nano development environment
Huawei certified cloud computing hica
C# NanoFramework 点灯和按键 之 ESP32
Connect to LAN MySQL
当前系统缺少NTFS格式转换器(convert.exe)
【Elastic】Elastic缺少xpack无法创建模板 unknown setting index.lifecycle.name index.lifecycle.rollover_alias
Spark calculation operator and some small details in liunx
EasyCVR接入设备开启音频后,视频无法正常播放是什么原因?
随机推荐
Selenium test of automatic answer runs directly in the browser, just like real users.
网络分层概念及基本知识
MySQL advanced (index, view, stored procedure, function, password modification)
【Elastic】Elastic缺少xpack无法创建模板 unknown setting index.lifecycle.name index.lifecycle.rollover_alias
JUnit unit test
FlutterWeb浏览器刷新后无法回退的解决方案
RepPoints:可形变卷积的进阶
集成开发管理平台
Single responsibility principle
mysql高级(索引,视图,存储过程,函数,修改密码)
The most complete tcpdump and Wireshark packet capturing practice in the whole network
基于LNMP部署flask项目
The art of Engineering
灵活报表v1.0(简单版)
[mmdetection] solves the installation problem
How to submit data through post
Kali2021 installation and basic configuration
C# WinForm系列-Button简单使用
Debug xv6
Flink parsing (V): state and state backend