当前位置:网站首页>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 .
边栏推荐
- 05个人研发的产品及推广-数据同步工具
- TCP connection is more than communicating with TCP protocol
- 应用服务配置器(定时,数据库备份,文件备份,异地备份)
- EasyCVR平台通过接口编辑通道出现报错“ID不能为空”,是什么原因?
- Huawei certified cloud computing hica
- mysql高级(索引,视图,存储过程,函数,修改密码)
- [reverse primary] Unique
- C# NanoFramework 点灯和按键 之 ESP32
- 03 products and promotion developed by individuals - plan service configurator v3.0
- [ASM] introduction and use of bytecode operation classwriter class
猜你喜欢
Automatic operation and maintenance sharp weapon ansible Foundation
Spark accumulator and broadcast variables and beginners of sparksql
C WinForm series button easy to use
Kali2021 installation and basic configuration
在一台服务器上部署多个EasyCVR出现报错“Press any to exit”,如何解决?
Final review of information and network security (based on the key points given by the teacher)
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
TCP连接不止用TCP协议沟通
全网最全tcpdump和Wireshark抓包实践
Flink analysis (I): basic concept analysis
随机推荐
自动化运维利器-Ansible-Playbook
TCP connection is more than communicating with TCP protocol
Xin'an Second Edition: Chapter 24 industrial control safety demand analysis and safety protection engineering learning notes
yarn : 无法加载文件 D:\ProgramFiles\nodejs\yarn.ps1,因为在此系统上禁止运行脚本
Run xv6 system
EasyCVR授权到期页面无法登录,该如何解决?
List set data removal (list.sublist.clear)
connection reset by peer
mysql高級(索引,視圖,存儲過程,函數,修改密碼)
TCP连接不止用TCP协议沟通
Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
C # nanoframework lighting and key esp32
03 products and promotion developed by individuals - plan service configurator v3.0
2022年大厂Android面试题汇总(一)(含答案)
Spark calculation operator and some small details in liunx
Unity粒子特效系列-闪星星的宝箱
Pyspark operator processing spatial data full parsing (5): how to use spatial operation interface in pyspark
Solid principle
Binary search strategy
OpenCV中如何使用滚动条动态调整参数