Unity 注释小技巧
你只需要在字段上添加特效即可 [Header( " 注释 " )][Space( 20 )] public Vector3 test1; ===================================================================================== 自己抽时间写了一个中文显示小脚本.下次问问老大能不能加到项目中去 usin
你只需要在字段上添加特效即可
[Header(<span>"</span><span>注释</span><span>"</span><span>)] [Space(</span><span>20</span><span>)] </span><span>public</span> Vector3 test1;
=====================================================================================
自己抽时间写了一个中文显示小脚本.下次问问老大能不能加到项目中去
<span>using</span><span> UnityEngine; </span><span>using</span><span> System.Collections; </span><span>using</span><span> UnityEditor; </span><span>using</span><span> System; </span><span>using</span><span> System.Reflection; </span><span>using</span><span> System.Collections.Generic; [CustomEditor(</span><span>typeof</span><span>(MyCompoment))] </span><span>public</span> <span>class</span><span> MyCompomentEditor : Editor{ </span><span>public</span> MyCompomentEditor():<span>base</span><span>() { </span><span>//</span><span>Debug.Log("我初始化了");</span> <span> } </span><span>private</span> <span>static</span> <span>bool</span> isDevelop = <span>true</span><span>; </span><span>public</span> <span>override</span> <span>void</span><span> OnInspectorGUI() { </span><span>if</span><span> (isDevelop) { MyCompoment edit </span>=<span> (MyCompoment)target; Type t </span>=<span> edit.GetType(); </span><span>string</span> label = <span>string</span><span>.Empty; FieldInfo[] fieldInfs </span>=<span> t.GetFields(); System.Object[] atrrs </span>= <span>null</span><span>; </span><span>for</span> (<span>int</span> i = <span>0</span>; i ) { atrrs = fieldInfs[i].GetCustomAttributes(<span>false</span><span>); </span><span>for</span> (<span>int</span> k = <span>0</span>; k false).Length; k++<span>) { </span><span>if</span> (atrrs[k] <span>is</span><span> LabelAttribute) { label </span>=<span> ((LabelAttribute)atrrs[k]).Label; </span><span>switch</span><span> (fieldInfs[i].FieldType.Name) { </span><span>case</span> <span>"</span><span>String</span><span>"</span><span>: fieldInfs[i].SetValue(edit, EditorGUILayout.TextField(label, fieldInfs[i].GetValue(edit).ToString())); </span><span>break</span><span>; </span><span>case</span> <span>"</span><span>Float</span><span>"</span><span>: fieldInfs[i].SetValue(edit, EditorGUILayout.FloatField(label, (</span><span>float</span><span>)fieldInfs[i].GetValue(edit))); </span><span>break</span><span>; </span><span>//</span><span>case "Double": </span><span>//</span><span> fieldInfs[i].SetValue(edit, EditorGUILayout.Doube(label, (double)fieldInfs[i].GetValue(edit))); </span><span>//</span><span> break;</span> <span>case</span> <span>"</span><span>Int</span><span>"</span><span>: fieldInfs[i].SetValue(edit, EditorGUILayout.IntField(label, (</span><span>int</span><span>)fieldInfs[i].GetValue(edit))); </span><span>break</span><span>; </span><span>case</span> <span>"</span><span>Int32</span><span>"</span><span>: fieldInfs[i].SetValue(edit, EditorGUILayout.IntField(label, (</span><span>int</span><span>)fieldInfs[i].GetValue(edit))); </span><span>break</span><span>; </span><span>case</span> <span>"</span><span>Color</span><span>"</span><span>: fieldInfs[i].SetValue(edit, EditorGUILayout.ColorField(label, (UnityEngine.Color)fieldInfs[i].GetValue(edit))); </span><span>break</span><span>; </span><span>case</span> <span>"</span><span>GameObject</span><span>"</span><span>: fieldInfs[i].SetValue(edit, EditorGUILayout.ObjectField(label, (UnityEngine.Object)fieldInfs[i].GetValue(edit), </span><span>typeof</span><span>(GameObject))); </span><span>break</span><span>; </span><span>case</span> <span>"</span><span>Component</span><span>"</span><span>: Debug.Log(</span><span>"</span><span>运行过Component</span><span>"</span><span>); fieldInfs[i].SetValue(edit, EditorGUILayout.ObjectField(label, (UnityEngine.Object)fieldInfs[i].GetValue(edit), </span><span>typeof</span><span>(Component))); </span><span>break</span><span>; </span><span>case</span> <span>"</span><span>Vector2</span><span>"</span><span>: fieldInfs[i].SetValue(edit, EditorGUILayout.Vector2Field(label, (Vector2)fieldInfs[i].GetValue(edit))); </span><span>break</span><span>; </span><span>case</span> <span>"</span><span>Vector3</span><span>"</span><span>: fieldInfs[i].SetValue(edit, EditorGUILayout.Vector3Field(label, (Vector3)fieldInfs[i].GetValue(edit))); </span><span>break</span><span>; </span><span>case</span> <span>"</span><span>Vector4</span><span>"</span><span>: fieldInfs[i].SetValue(edit, EditorGUILayout.Vector4Field(label, (Vector4)fieldInfs[i].GetValue(edit))); </span><span>break</span><span>; </span><span>//</span><span>case "Test": </span><span>//</span><span> Debug.Log("运行过Component"); </span><span>//</span><span> fieldInfs[i].SetValue(edit, EditorGUILayout.ObjectField(label, (UnityEngine.Object)fieldInfs[i].GetValue(edit), typeof(Component))); </span><span>//</span><span> break;</span> <span>default</span><span>: </span><span>//</span><span>Debug.Log("fieldInfs[i].Name " + fieldInfs[i].FieldType.BaseType.Name);</span> <span>if</span> (fieldInfs[i].FieldType.BaseType.Name == <span>"</span><span>MonoBehaviour</span><span>"</span><span>) { fieldInfs[i].SetValue(edit, EditorGUILayout.ObjectField(label, (UnityEngine.Object)fieldInfs[i].GetValue(edit), fieldInfs[i].FieldType)); } </span><span>break</span><span>; } } } } } </span><span>else</span><span> { </span><span>base</span><span>.OnInspectorGUI(); } } </span><span>#region</span> 暂时没有用到的代码 <span>/*</span><span> /// <summary> /// 缓存实例的属性,下次就不需要使用循环了 /// </summary> public Dictionary<string string> dir; public void GetProrptes() { if (isDevelop) { MyCompoment edit = (MyCompoment)target; Type t = edit.GetType(); string label = string.Empty; FieldInfo[] fieldInfos = t.GetFields(); System.Object[] atrrs = null; GUIContent contextUI = null; for (int i = 0; i <span>*/</span> <span>#endregion</span><span> }</span></string></span>
MyCompoment:
<span>using</span><span> UnityEngine; </span><span>using</span><span> System.Collections; [SerializeField] </span><span>public</span> <span>class</span><span> MyCompoment : MonoBehaviour { [LabelAttribute(Label </span>= <span>"</span><span>名字</span><span>"</span><span>)] </span><span>public</span> <span>string</span> MyName = <span>"</span><span>123</span><span>"</span><span>; [LabelAttribute(Label </span>= <span>"</span><span>float数字</span><span>"</span><span>)] </span><span>public</span> <span>float</span> float1 = <span>100</span><span>; [LabelAttribute(Label </span>= <span>"</span><span>double数字</span><span>"</span><span>)] </span><span>public</span> <span>double</span> double1 = <span>100</span><span>; [LabelAttribute(Label </span>= <span>"</span><span>int数字</span><span>"</span><span>)] </span><span>public</span> <span>int</span> int1 = <span>100</span><span>; [LabelAttribute(Label </span>= <span>"</span><span>颜色</span><span>"</span><span>)] </span><span>public</span> Color color1 =<span> Color.red; [LabelAttribute(Label </span>= <span>"</span><span>游戏物体</span><span>"</span><span>)] </span><span>public</span><span> GameObject GameObject1; [LabelAttribute(Label </span>= <span>"</span><span>组件</span><span>"</span><span>)] </span><span>public</span><span> StartPanel Component1; [LabelAttribute(Label </span>= <span>"</span><span>2D</span><span>"</span><span>)] </span><span>public</span><span> Vector2 Vector2; [LabelAttribute(Label </span>= <span>"</span><span>3D</span><span>"</span><span>)] </span><span>public</span><span> Vector3 Vector3; [LabelAttribute(Label </span>= <span>"</span><span>4D</span><span>"</span><span>)] </span><span>public</span><span> Vector4 Vector4; }</span>
LabelAttribute特性:
<span>using</span><span> UnityEngine; </span><span>using</span><span> System.Collections; </span><span>using</span><span> System; </span><span>public</span> <span>class</span><span> LabelAttribute : Attribute { </span><span>public</span> <span>string</span><span> Label; }</span>
源代码: http://yunpan.cn/cJhp4tThyGauJ 访问密码 5789

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users are increasingly favoring the electronic ecosystem of Xiaomi smart home interconnection in modern life. After connecting to the Mijia APP, you can easily control the connected devices with your mobile phone. However, many users still don’t know how to add Mijia to their homes. app, then this tutorial guide will bring you the specific connection methods and steps, hoping to help everyone in need. 1. After downloading Mijia APP, create or log in to Xiaomi account. 2. Adding method: After the new device is powered on, bring the phone close to the device and turn on the Xiaomi TV. Under normal circumstances, a connection prompt will pop up. Select "OK" to enter the device connection process. If no prompt pops up, you can also add the device manually. The method is: after entering the smart home APP, click the 1st button on the lower left

Win11 Tips Sharing: One trick to skip Microsoft account login Windows 11 is the latest operating system launched by Microsoft, with a new design style and many practical functions. However, for some users, having to log in to their Microsoft account every time they boot up the system can be a bit annoying. If you are one of them, you might as well try the following tips, which will allow you to skip logging in with a Microsoft account and enter the desktop interface directly. First, we need to create a local account in the system to log in instead of a Microsoft account. The advantage of doing this is

We often create and edit tables in excel, but as a novice who has just come into contact with the software, how to use excel to create tables is not as easy as it is for us. Below, we will conduct some drills on some steps of table creation that novices, that is, beginners, need to master. We hope it will be helpful to those in need. A sample form for beginners is shown below: Let’s see how to complete it! 1. There are two methods to create a new excel document. You can right-click the mouse on a blank location on the [Desktop] - [New] - [xls] file. You can also [Start]-[All Programs]-[Microsoft Office]-[Microsoft Excel 20**] 2. Double-click our new ex

Tampermonkey Chrome extension is a user script management plug-in that improves user efficiency and browsing experience through scripts. So how does Tampermonkey add new scripts? How to delete the script? Let the editor give you the answer below! How to add a new script to Tampermonkey: 1. Take GreasyFork as an example. Open the GreasyFork web page and enter the script you want to follow. The editor here chooses one-click offline download. 2. Select a script. , after entering the script page, you can see the button to install this script. 3. Click to install this script to come to the installation interface. Just click here to install. 4. We can see the installed one-click in the installation script.

In C language, it represents a pointer, which stores the address of other variables; & represents the address operator, which returns the memory address of a variable. Tips for using pointers include defining pointers, dereferencing pointers, and ensuring that pointers point to valid addresses; tips for using address operators & include obtaining variable addresses, and returning the address of the first element of the array when obtaining the address of an array element. A practical example demonstrating the use of pointer and address operators to reverse a string.

VSCode (Visual Studio Code) is an open source code editor developed by Microsoft. It has powerful functions and rich plug-in support, making it one of the preferred tools for developers. This article will provide an introductory guide for beginners to help them quickly master the skills of using VSCode. In this article, we will introduce how to install VSCode, basic editing operations, shortcut keys, plug-in installation, etc., and provide readers with specific code examples. 1. Install VSCode first, we need
![Outlook stuck on adding account [Fixed]](https://img.php.cn/upload/article/000/887/227/171116770937641.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
When you encounter problems adding accounts in Outlook, you can try the following solutions to resolve it. Typically this can be caused by a faulty network connection, corrupted user profiles, or other temporary issues. Through the methods provided in this article, you can easily solve these problems and ensure that your Outlook can run normally. Outlook stuck on adding account If your Outlook is stuck on adding account, then use these fixes mentioned below: Disconnect and reconnect the internet Temporarily disable antivirus software Create a new Outlook profile Try adding account in safe mode Disable IPv6 Run Microsoft Support and Recovery Assistant Repair Office Application Outlook Add Account Required

Title: PHP Programming Tips: How to Jump to a Web Page within 3 Seconds In web development, we often encounter situations where we need to automatically jump to another page within a certain period of time. This article will introduce how to use PHP to implement programming techniques to jump to a page within 3 seconds, and provide specific code examples. First of all, the basic principle of page jump is realized through the Location field in the HTTP response header. By setting this field, the browser can automatically jump to the specified page. Below is a simple example demonstrating how to use P
