From a1e7bf8c03d25d43285ff73d09a1a42d34a77cdc Mon Sep 17 00:00:00 2001 From: Thomas Hummes Date: Sun, 13 Mar 2016 13:09:24 +0100 Subject: [PATCH] Updated Readme and SampleFile --- Editor/Sample/ScreenshotTest.cs | 21 ++++--- README.md | 102 ++++++++++++++++++++++++++------ 2 files changed, 95 insertions(+), 28 deletions(-) diff --git a/Editor/Sample/ScreenshotTest.cs b/Editor/Sample/ScreenshotTest.cs index 93999dc..b0571cf 100644 --- a/Editor/Sample/ScreenshotTest.cs +++ b/Editor/Sample/ScreenshotTest.cs @@ -6,20 +6,19 @@ namespace UnityEditorHelper [CustomEditor(typeof (SampleScript))] public class ScreenshotTest : Editor { + public Vector2 _scrollPos; + private bool state; + public override void OnInspectorGUI() { - using (new HighlightBox()) - { - EditorGUILayout.Slider("Range property", 5, 0, 10); - EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); - EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true); - } - - using (new HighlightBox(Color.red)) + using (new FoldableBlock(ref state, "Foldable Block")) { - EditorGUILayout.Slider("Range property", 5, 0, 10); - EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); - EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true); + if(state) + { + EditorGUILayout.Slider("Range property", 5, 0, 10); + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); + EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true); + } } } } diff --git a/README.md b/README.md index 2a26262..51715c2 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,92 @@ # UnityEditorHelper An organized bunch of scripts to make editor scripting in Unity easier - gathered from some of my projects and other free sources -# Samples +## Samples -## HighlightBox +### HighlightBox A box with round edges that can be colored and used to highlight some components -![Alt Text](https://imgur.com/41b7dYL) +![Imgur](http://i.imgur.com/41b7dYL.png) - using (new HighlightBox()) - { - EditorGUILayout.Slider("Range property", 5, 0, 10); - EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); - EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true); - } - - using (new HighlightBox(Color.red)) - { - EditorGUILayout.Slider("Range property", 5, 0, 10); - EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); - EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true); - } - +```csharp + using (new HighlightBox()) + { + EditorGUILayout.Slider("Range property", 5, 0, 10); + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); + EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true); + } + + using (new HighlightBox(Color.red)) + { + EditorGUILayout.Slider("Range property", 5, 0, 10); + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); + EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true); + } +``` + +### EditorBlock +A wrapper for vertical and horizontal oriented blocks that also accepts and additional style. + +![Imgur](http://i.imgur.com/NhPueAu.png) + +```csharp + using (new EditorBlock(EditorBlock.Orientation.Vertical, "Box")) + { + EditorGUILayout.Slider("Range property", 5, 0, 10); + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); + EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true); + } +``` + +### SwitchColor +A wrapper to change the GUIColor automatically without manually caching it and switching it back + +![Imgur](http://i.imgur.com/VEBDzBi.png) + +```csharp + using (new SwitchColor(Color.cyan)) + { + EditorGUILayout.Slider("Range property", 5, 0, 10); + } + + using (new SwitchColor(Color.green)) + { + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); + } + + EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true); +``` + +### IdentBlock +A wrapper to indent controls + +![Imgur](http://i.imgur.com/Zf17FFg.png) + +```csharp + using (new IndentBlock()) + { + EditorGUILayout.Slider("Range property", 5, 0, 10); + using (new IndentBlock()) + { + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); + EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true); + } + } +``` + +### FoldableBlock +A simple foldable block with a header. Can have an optional icon. + +![Imgur](http://i.imgur.com/cyuogg2.png) + +```csharp + using (new FoldableBlock(ref state, "Foldable Block")) + { + if(state) + { + EditorGUILayout.Slider("Range property", 5, 0, 10); + EditorGUILayout.TextField("Sample Field", GUILayout.Height(150)); + EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true); + } + } +```