Unity共通スキル経験

00テキストエリア 

「文字列」を使用して比較的長いテキストを入力すると、すべてのテキストが表示されないことがよくありますが、
「文字列」属性の文字列を使用してテキストエリアの柔軟性を編集できます。
 

01ヘッダー、ツールチップ、スペース  

属性フィールドをより適切に整理するために、「
インスペクター」パネルのプロンプトとして「ヘッダー」、「ツールチップ」、および「スペース」を使用できます。

 

03拡張方法 

拡張メソッドを使用して、カテゴリ、タイプ、構造などに既存の機能を追加できます。
 

04# カスタム プラットフォームを定義する 

独自の #defines カスタマイズされたプラットフォームをセットアップして、機能をすばやく追加または削除できます 


 

05インスペクターパネルの数値編集速度

特定の数値を編集する場合、「Shift」キーを押すと変更が早くなり、「Alt」キーを押すと変更が遅くなります。

 

06unity内蔵シェーダー 

すべての Unity 組み込みシェーダー (すべての cginc ファイル) は、アーカイブ ダウンロード ページにアクセスしてダウンロードできます。

 

07MinMaxプロパティ 

インスペクターパネルで MinMax 属性、ランダムベクトル 2

 
minmaxattribute.cs    minmaxattribute.cs を使用できます。
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

 

UnityEngine を使用する。

// どこにでも配置できますが、エディター フォルダーには配置できません

public class MinMaxAttribute : PropertyAttribute

{

    public float minLimit = 0;

    public float maxLimit = 1;

 

    public MinMaxAttribute(int min, int max)

    {

        minLimit = min;

        maxLimit = max;

    }

}



  MinMaxDrawer.cs   MinMaxDrawer.cs 
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

 

using UnityEngine;

using UnityEditor;

using UnityEngine.Rendering.PostProcessing;

 

// ! -> Put this in an Editor folder

// By @febucci : https://www.febucci.com/

[CustomPropertyDrawer(typeof(MinMaxAttribute))]

public class MinMaxDrawer : PropertyDrawer

{

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)

    {

        //Asserts that we're using the MinMax attribute on a Vector2

        UnityEngine.Assertions.Assert.IsTrue(property.propertyType == SerializedPropertyType.Vector2, "Devi usare un vector2 per MinMax");

 

        if (property.propertyType == SerializedPropertyType.Vector2)

        {

 

            MinMaxAttribute minMax = attribute as MinMaxAttribute;

 

            //Writes the variable name on the left

            Rect totalValueRect = EditorGUI.PrefixLabel(position, label);

 

            //The left value, after the variable name

            Rect leftRect = new Rect(totalValueRect.x, totalValueRect.y, 50, totalValueRect.height);

 

            //Rect of the slider

            Rect valueRect = new Rect(leftRect.xMax, totalValueRect.y, totalValueRect.width - leftRect.width * 2 - 4, totalValueRect.height);

 

            //The right value

            Rect rightRect = new Rect(totalValueRect.xMax - leftRect.width - 2, totalValueRect.y, leftRect.width, totalValueRect.height);

 

            float minValue = property.vector2Value.x; //Current x

            float maxValue = property.vector2Value.y; //Current y

 

            EditorGUI.MinMaxSlider(valueRect, ref minValue, ref maxValue, minMax.minLimit, minMax.maxLimit);

 

            //Assigns the value to the property

            property.vector2Value = new Vector2(minValue, maxValue);

 

            EditorGUI.LabelField(leftRect, minValue.ToString("F3")); //Writes the value on the left

            EditorGUI.LabelField(rightRect, maxValue.ToString("F3")); //Writes the value on the right

        }

        else

        {

            GUI.Label(position, "You can use MinMax only on a Vector2!");

        }

    }

}



  

08 Curves

可以使用动画曲线通过代码为对象创建炫酷效果。
查看更多关于 “Lerp/Easing”
 

09单独预览窗口 

可以将预览窗口和检验员的任何地方。( 右键单击它的顶部条)就可以单独窗口显示 


10层次组织 

你可以通过添加作为层级空游戏对象。
建议来制定自己的tag标签为 “EditorOnly”在build过程中,这样它们就不会保存。
 

11颗粒系统回放时间

可以控制颗粒的回放时间中的编辑器来编辑效果更好。

 


12EditorOnly标签 

可以使用“EditorOnly”Tag标记从最终构建中排除GameObject。
 

13分配的材料在创建着色器

当我们创建材质时,总忘了是哪一个自定义shader,然而
可以选中shader》鼠标右击》选择material,即可创建对应的shader材质
 

14插入数据在列表数组

当我们需要填一些数据时,有些是一样的数据,我们都是手动添加,其实
可以通过按快捷键“CTRL + D”(代表:“复制”)在Inspector中插入数组元素,而无需手动调整下一个元素。
 

15显示了多个文件夹的内容 

你能看到的内容的多个文件夹中选择它, 只需在 Project 窗口中。
 

16定制Unity 的C#脚本模板


可以自定义 Unity 中的模板通过改变 “81-C#” 中找到文件路径 : "%EDITOR_PATH%\Data\Resources\ScriptTemplates" 。
记得在修改前存储拷贝 !

P. s.# C - 81保存一份原始文件 , 我建议移动到另一文件夹

17控制台日志条目窗口


你可以自行调整线的每个日志显示在控制台窗口中 , 以读取更多 (或更少) 文本。
 

18OnValidate


脚本被修改了之后就会执行
在这里阅读更多。
 

19设置为预设默认编辑器


您可以设置预设编辑器的默认状态 , 然后按下 “复位”
 

 

 
 

21不一样的控制台输出 

打印不一样的样
    

22在项目窗口中搜索资源

     

23DisallowMultipleComponent & RequireComponent 

您可以使用DisallowMultipleComponent和RequireComponent属性来避免游戏对象中的设置错误。


    

24Graphy 

可以使用@ tayx94制作的这款精彩工具
直接从发布出来中监控游戏的性能。
GitHub repository 地址:https://github.com/Tayx94/graphy

    

  
  

25NaughtyAttributes

可以在GitHub上使用dbrizov制作的20多个属性扩展,比如ReorderableList,Slider或ResizableTextArea。


GitHub repository 地址:https://github.com/dbrizov/NaughtyAttributes
    

26Foldout属性显示管理 

可以使用Dimmpixeye在GitHub上创建的Foldout属性在Inspector中对变量进行分组。


GitHub Foldout地址:https://github.com/dimmpixeye/InspectorFoldoutGroup
    

  

27ContextMenu上下文菜单

使用ContextMenu属性从Inspector调用方法


    

28Inspector 面板数学计算

你可以在面板上面进行计算


    
 

29SerializeField & HideInInspector序列化

使用SerializeField和HideInInspector属性选择要显示和序列化的变量。


    

30FormerlySerializedAs

 

如果需要重命名变量,但又不能丢失其序列化值,则非常有用



    

31AddComponentMenu 

在Inspector的“AddComponent”菜单中组织脚本,使用AddComponentMenu属性。


    

32MenuItem 

方法调用的主菜单、上下文菜单。要注意 , 它只能在编辑的 , 所以你需要它 , 如果你想释放代码。(添加# if _ 统一编辑你就可以开始工作) 。

    

 

02-1.png

 

 

02.gif

おすすめ

転載: blog.csdn.net/qq_39741605/article/details/100072354