|
1 | 1 | # UnityEditorHelper |
2 | 2 | An organized bunch of scripts to make editor scripting in Unity easier - gathered from some of my projects and other free sources |
3 | 3 |
|
4 | | -# Samples |
| 4 | +## Samples |
5 | 5 |
|
6 | | -## HighlightBox |
| 6 | +### HighlightBox |
7 | 7 | A box with round edges that can be colored and used to highlight some components |
8 | 8 |
|
9 | | - |
| 9 | + |
10 | 10 |
|
11 | | - using (new HighlightBox()) |
12 | | - { |
13 | | - EditorGUILayout.Slider("Range property", 5, 0, 10); |
14 | | - EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); |
15 | | - EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true); |
16 | | - } |
17 | | - |
18 | | - using (new HighlightBox(Color.red)) |
19 | | - { |
20 | | - EditorGUILayout.Slider("Range property", 5, 0, 10); |
21 | | - EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); |
22 | | - EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true); |
23 | | - } |
24 | | - |
| 11 | +```csharp |
| 12 | + using (new HighlightBox()) |
| 13 | + { |
| 14 | + EditorGUILayout.Slider("Range property", 5, 0, 10); |
| 15 | + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); |
| 16 | + EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true); |
| 17 | + } |
| 18 | + |
| 19 | + using (new HighlightBox(Color.red)) |
| 20 | + { |
| 21 | + EditorGUILayout.Slider("Range property", 5, 0, 10); |
| 22 | + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); |
| 23 | + EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true); |
| 24 | + } |
| 25 | +``` |
| 26 | + |
| 27 | +### EditorBlock |
| 28 | +A wrapper for vertical and horizontal oriented blocks that also accepts and additional style. |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +```csharp |
| 33 | + using (new EditorBlock(EditorBlock.Orientation.Vertical, "Box")) |
| 34 | + { |
| 35 | + EditorGUILayout.Slider("Range property", 5, 0, 10); |
| 36 | + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); |
| 37 | + EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true); |
| 38 | + } |
| 39 | +``` |
| 40 | + |
| 41 | +### SwitchColor |
| 42 | +A wrapper to change the GUIColor automatically without manually caching it and switching it back |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +```csharp |
| 47 | + using (new SwitchColor(Color.cyan)) |
| 48 | + { |
| 49 | + EditorGUILayout.Slider("Range property", 5, 0, 10); |
| 50 | + } |
| 51 | + |
| 52 | + using (new SwitchColor(Color.green)) |
| 53 | + { |
| 54 | + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); |
| 55 | + } |
| 56 | + |
| 57 | + EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true); |
| 58 | +``` |
| 59 | + |
| 60 | +### IdentBlock |
| 61 | +A wrapper to indent controls |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +```csharp |
| 66 | + using (new IndentBlock()) |
| 67 | + { |
| 68 | + EditorGUILayout.Slider("Range property", 5, 0, 10); |
| 69 | + using (new IndentBlock()) |
| 70 | + { |
| 71 | + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); |
| 72 | + EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true); |
| 73 | + } |
| 74 | + } |
| 75 | +``` |
| 76 | + |
| 77 | +### FoldableBlock |
| 78 | +A simple foldable block with a header. Can have an optional icon. |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +```csharp |
| 83 | + using (new FoldableBlock(ref state, "Foldable Block")) |
| 84 | + { |
| 85 | + if(state) |
| 86 | + { |
| 87 | + EditorGUILayout.Slider("Range property", 5, 0, 10); |
| 88 | + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); |
| 89 | + EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true); |
| 90 | + } |
| 91 | + } |
| 92 | +``` |
0 commit comments