- 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.
- Implementing Modern DevOps
- 青少年美育趣味課堂:XMind思維導(dǎo)圖制作
- Python機(jī)器學(xué)習(xí):手把手教你掌握150個(gè)精彩案例(微課視頻版)
- Scientific Computing with Scala
- Java語(yǔ)言程序設(shè)計(jì)教程
- HTML5開(kāi)發(fā)精要與實(shí)例詳解
- Hadoop 2.X HDFS源碼剖析
- Mastering Concurrency Programming with Java 9(Second Edition)
- Arduino Wearable Projects
- Python商務(wù)數(shù)據(jù)分析(微課版)
- Python大規(guī)模機(jī)器學(xué)習(xí)
- Java高并發(fā)編程詳解:深入理解并發(fā)核心庫(kù)
- JavaScript Concurrency
- Linux Networking Cookbook
- VB語(yǔ)言程序設(shè)計(jì)教程(第2版)