- Unity 2017 Mobile Game Development
- John P. Doran
- 182字
- 2021-07-02 22:27:44
The Tooltip attribute
If you've used Unity for a period of time, you may have noted that some components in the Inspector window, such as the Rigidbody, have a nice feature--if you move your mouse over a variable name, you'll see a description of what the variables are and/or how to use them. The first thing you'll learn is how we can get the same effect in our own components by making use of the Tooltip attribute. If we do this for the dodgeSpeed and rollSpeed variables, it will look something like this:
[Tooltip("How fast the ball moves left/right")]
public float dodgeSpeed = 5;
[Tooltip("How fast the ball moves forwards automatically")]
public float rollSpeed = 5;
Save the preceding script and return to the editor:

Now, when we highlight the variable using the mouse and leave it there, the text we placed will be displayed. This is a great habit to get into, as your teammates can always tell what it is that your variables are being used for.
For more information on the Tooltip attribute, check out, https://docs.unity3d.com/ScriptReference/TooltipAttribute.html.
- Spring Boot 2實(shí)戰(zhàn)之旅
- AngularJS Testing Cookbook
- Python自動(dòng)化運(yùn)維快速入門(mén)
- Rake Task Management Essentials
- 數(shù)據(jù)結(jié)構(gòu)(Java語(yǔ)言描述)
- Android NDK Beginner’s Guide
- 教孩子學(xué)編程:C++入門(mén)圖解
- 基于Swift語(yǔ)言的iOS App 商業(yè)實(shí)戰(zhàn)教程
- PostgreSQL Replication(Second Edition)
- iOS編程基礎(chǔ):Swift、Xcode和Cocoa入門(mén)指南
- Django實(shí)戰(zhàn):Python Web典型模塊與項(xiàng)目開(kāi)發(fā)
- Machine Learning for Developers
- SQL Server實(shí)例教程(2008版)
- XML程序設(shè)計(jì)(第二版)
- Java 7 Concurrency Cookbook