diff --git a/LICENSE.meta b/LICENSE.meta index c691be0..31a0259 100644 --- a/LICENSE.meta +++ b/LICENSE.meta @@ -1,4 +1,8 @@ fileFormatVersion: 2 -guid: c35f61edc180166489847c79f4b8ea46 +guid: e9a81748fac51154f8688d2e3c46fd56 +timeCreated: 1438724032 +licenseType: Free DefaultImporter: userData: + assetBundleName: + assetBundleVariant: diff --git a/README.md b/README.md index eeb809b..1fee5f2 100644 --- a/README.md +++ b/README.md @@ -3,68 +3,164 @@ This is an extension project for the new Unity UI system which can be found at: [Unity UI Source](https://bitbucket.org/Unity-Technologies/ui) +#For Unity 5.2.2+ - Use the new 5.3 package!# + + +##Intro## +For more info, here's a little introduction video for the project: + +[![View Intro Video](http://img.youtube.com/vi/njoIeE4akq0/0.jpg)](http://www.youtube.com/watch?v=njoIeE4akq0 "Unity UI Extensions intro video") + ### What is this repository for? ### In this repository is a collection of extension scripts to enhance your Unity UI experience. These scripts have been gathered from many sources and combined and improved over time. (The majority of the scripts came from the Scripts thread on the [Unity UI forum here](http://bit.ly/UnityUIScriptsForumPost)) You can either download / fork the project to access the scripts, or you can download this precompiled Unity Asset, chock full of goodness -### [Unity UI Extensions Unity Asset](https://bitbucket.org/ddreaper/unity-ui-extensions/downloads/UnityUIExtensions.unitypackage)### ---- +### [Unity UI Extensions Unity 4.x Asset](https://bitbucket.org/ddreaper/unity-ui-extensions/downloads/UnityUIExtensions-4.x.unitypackage)### +### [Unity UI Extensions Unity 5.1 Asset](https://bitbucket.org/ddreaper/unity-ui-extensions/downloads/UnityUIExtensions-5.1.unitypackage)### +### [Unity UI Extensions Unity 5.2 Asset](https://bitbucket.org/ddreaper/unity-ui-extensions/downloads/UnityUIExtensions-5.2.unitypackage)### <- 5.2.0 - 5.2.1 base releases ONLY +### [Unity UI Extensions Unity 5.3 (5.2.1P+) Asset](https://bitbucket.org/ddreaper/unity-ui-extensions/downloads/UnityUIExtensions-5.3.unitypackage) <- use this for 5.2.1P+ releases### +##Getting Started## +To get started with the project, here's a little guide: + +[![View Getting Started Video](http://img.youtube.com/vi/sVLeYmsNQAI/0.jpg)](http://www.youtube.com/watch?v=sVLeYmsNQAI "Unity UI getting started video") +--- +## Updates: ## + +###Update 1.0.4### + +[![View Getting Started Video](http://img.youtube.com/vi/oF48Qpaq3ls/0.jpg)](http://www.youtube.com/watch?v=oF48Qpaq3ls "Update 1.0.0.4 for the Unity UI Extensions Project") +--- +###Update 1.0.5### +Few minor fixes and a couple of additional scripts. Predominately created the new 5.3 branch to maintain the UI API changes from the 5.2.1 Patch releases. 5.3 package is 100% compatible with 5.2.1 Patch releases. + +###Update 1.0.6### + +[![View Getting Started Video](http://img.youtube.com/vi/jpyFiRvSmbg/0.jpg)](http://www.youtube.com/watch?v=jpyFiRvSmbg "Update 1.0.6 for the Unity UI Extensions Project") + +* Added the awesome ReOrderable List control, plus some other minor bugfixes / changes. +* Added a new version of the Scroll Snap control as an alternative to the fixed versions. +* New set of controls including some shader enhanced solutions +* I've added a donate column to the lists. If you are getting great use out of a control, help out the dev who created it. Optional of course. Will update with links as I get them. + +**1.0.6.1 - Minor update to enhance soft alpha mask and add cylinder text plus a fix to letter spacing** + +--- ## Controls and extensions listed in this project are: ## -## New Controls ## +## Controls ## ================ -Control | Description | Menu Command | Component Command | Notes | Credits ---------- | -------------- | ---------------------- | ---------------------------- | ------- | ---------- -**Accordion** | An Acordian style control with animated segments. Sourced from [here](http://forum.unity3d.com/threads/accordion-type-layout.271818/). For more details, [see this video demonstration](https://www.youtube.com/watch?v=YSOSVTU5klw) | N/A | Component / UI / Extensions / AccordionGroup | | ChoMPHi - | | | Component / UI / Extensions / AccordionItem | | ChoMPHi -**ComboBox** | A styled Combo Box control | UI / Extensions / Combobox | UI / Extensions / Combobox | Still being improved by author | perchik -**HSVPicker** | A colour picker UI | N/A | UI / Extensions / HSVPicker | Project folder includes prefab | judah4 -**SelectionBox** | An RTS style selection box control | UI / Extensions / Selection Box | UI / Extensions / Selection Box | Needs documentation on use, selection area defines the area on screen that is selectable. Uses script on selectable items on screen | Korindian, BenZed -**HorizontalScrollSnap** | A pages scroll rect that can work in steps / pages, includes button support | UI / Extensions / Horizontal Scroll Snap | UI / Extensions / Horizontal Scroll Snap | | BinaryX -**UIButton** | Improved Button control with additional events | UI / Extensions / UI Button | UI / Extensions / UI Button | | AriathTheWise -**UIWindowBase** | A draggable Window implementation | UI / Extensions / UI Window Base | UI / Extensions / UI Window Base | | GXMark, alexzzzz, CaoMengde777, TroyDavis -**ComboBox** | A fixed combobox implementation for text | UI / Extensions / ComboBox | UI / Extensions / ComboBox | | Perchik -**AutoCompleteComboBox** | A text combobox with autocomplete selection | UI / Extensions / AutoComplete ComboBox | UI / Extensions / AutoComplete ComboBox | | Perchik -**DropDownList** | A basic drop down list with text and image support | UI / Extensions / Dropdown List | UI / Extensions / Dropdown List | | Perchik -**BoundToolTip** | An alternate Tooltip implementation with central listener | UI / Extensions / Bound Tooltip / Tooltip | UI / Extensions / Bound Tooltip / Tooltip Item | Offset and tooltip placement needs work | Martin Sharkbomb - | | | UI / Extensions / Bound Tooltip / Tooltip Trigger | | Martin Sharkbomb +Control | Description | Menu Command | Component Command | Notes | Donate | Credits +--------- | -------------- | ---------------------- | ---------------------------- | ------- | ---------- | ---------- +**Accordion** | An Acordian style control with animated segments. Sourced from [here]. | N/A | Component / UI / Extensions / AccordionGroup |[demo video](http://forum.unity3d.com/threads/accordion-type-layout.271818/)|| ChoMPHi + | | | Component / UI / Extensions / AccordionItem |[demo video](http://forum.unity3d.com/threads/accordion-type-layout.271818/)|| ChoMPHi +**HSVPicker** | A colour picker UI | N/A | UI / Extensions / HSVPicker | Project folder includes prefab and sample scene || judah4 +**SelectionBox** | An RTS style selection box control | UI / Extensions / Selection Box | UI / Extensions / Selection Box |[tutorial video](https://www.youtube.com/watch?v=UtM3HejKL5s)|| Korindian, BenZed +**UIButton** | Improved Button control with additional events (PointerDown, PointerUp, PointerClick and PointerHeld) | UI / Extensions / UI Button | UI / Extensions / UI Button |Will update video, this has now been updated to a more reusable Selectable extension|| AriathTheWise +**UIFlippable** | Improved Image control with image flipping options | UI / Extensions / UI Flippable | UI / Extensions / Flippable |[tutorial video](https://www.youtube.com/watch?v=Htt2RNa2qy0)|| ChoMPHi +**UIWindowBase** | A draggable Window implementation | UI / Extensions / UI Window Base | UI / Extensions / UI Window Base |[tutorial video](https://www.youtube.com/watch?v=Htt2RNa2qy0)|| GXMark, alexzzzz, CaoMengde777, TroyDavis +**ComboBox** | A fixed combobox implementation for text | UI / Extensions / ComboBox | UI / Extensions / ComboBox |[tutorial video](https://www.youtube.com/watch?v=JrEfs47FoOE)|| Perchik +**AutoCompleteComboBox** | A text combobox with autocomplete selection | UI / Extensions / AutoComplete ComboBox | UI / Extensions / AutoComplete ComboBox |[tutorial video](https://www.youtube.com/watch?v=JrEfs47FoOE)|| Perchik +**DropDownList** | A basic drop down list with text and image support | UI / Extensions / Dropdown List | UI / Extensions / Dropdown List |[tutorial video](https://www.youtube.com/watch?v=JrEfs47FoOE)|| Perchik +**BoundToolTip** | An alternate Tooltip implementation with central listener | UI / Extensions / Bound Tooltip / Tooltip | UI / Extensions / Bound Tooltip / Tooltip Item | Offset and tooltip placement needs work || Martin Sharkbomb + | | | UI / Extensions / Bound Tooltip / Tooltip Trigger ||| Martin Sharkbomb + + +## Primitives ## +================ + +Control | Description | Menu Command | Component Command | Notes | Donate | Credits +--------- | -------------- | ---------------------- | ---------------------------- | ------- | ---------- | ---------- +**LineRenderer** | Graphic control for drawing lines in the UI System | UI / Extensions / Primitives / UI Line Renderer | UI / Extensions / Primitives / UI Line Renderer |[tutorial video](https://www.youtube.com/watch?v=OElcWAZGHi0)|| jack.sydorenko +**UILineTextureRenderer** | Graphic control for drawing lines in the UI System | UI / Extensions / Primitives / UI Line Texture Renderer | UI / Extensions / Primitives / UI Line Texture Renderer |[tutorial video](https://www.youtube.com/watch?v=OElcWAZGHi0)|| jack.sydorenko, jonbro5556 +**UICircle** | Graphic control for drawing circles in the UI System | UI / Extensions / Primitives / UI Circle | UI / Extensions / Primitives / UI Circle |[tutorial video](https://www.youtube.com/watch?v=2KOnEKAVua0)|| zge +**DiamondGraph** | Graphic control for drawing a diamond in the UI System | UI / Extensions / Primitives / DiamondGraph | UI / Extensions / Primitives / DiamondGraph |5.2+ only [tutorial video](https://www.youtube.com/watch?v=2KOnEKAVua0)|| koohddang +**UICornerCut** | Graphic control for drawing a diamond in the UI System | UI/Extensions/Primitives/Cut Corners | UI/Extensions/Primitives/Cut Corners ||| Freezy + + +## Layouts ## +================ + +Layout | Description | Menu Command | Component Command | Notes | Donate | Credits +--------- | -------------- | ---------------------- | ---------------------------- | ------- | ---------- | ---------- +**HorizontalScrollSnap** | A pages scroll rect that can work in steps / pages, includes button support | UI / Extensions / Horizontal Scroll Snap | Layout / Extensions / Horizontal Scroll Snap |[tutorial video](https://www.youtube.com/watch?v=KJlIlWHlfMo)|| BinaryX +**VerticalScrollSnap** | A pages scroll rect that can work in steps / pages, includes button support | UI / Extensions / Vertical Scroll Snap | Layout / Extensions / Vertical Scroll Snap |[tutorial video](https://www.youtube.com/watch?v=KJlIlWHlfMo)|| BinaryX, Simon Darkside Jackson +**FlowLayoutGroup** | A more rugged grid style layout group || Layout / Extensions / Flow Layout Group | [Example Video](https://www.youtube.com/watch?v=tMe_3tJTZvc) || Simie +**RadialLayout** | A radial layout system || Layout / Extensions / Radial Layout |[tutorial video](https://www.youtube.com/watch?v=iUlk0d2RDMs)|| Danny Goodayle +**TileSizeFitter** | A fitter layout that will shink / expand content by tiles || Layout / Extensions / TileSizeFitter |[tutorial video](https://www.youtube.com/watch?v=AkQNWl8mnxg)|| Ges +**ScrollSnap** | An alternate scroll snap control supporting both Horizontal and Vertial layous in one control | UI / Extensions / Fixed Item Scroll / Snap Horizontal Single Item|||| xesenix +|| UI / Extensions / Fixed Item Scroll / Snap Horizontal Multiple Item|||| xesenix +|| UI / Extensions / Fixed Item Scroll / Snap Vertical Single Item|||| xesenix +|| UI / Extensions / Fixed Item Scroll / Snap Vertical Multiple Item|||| xesenix +**ReorderableList** | A dynamic control allowing drag and drop of child elements with reordering support | UI/Extensions/Re-orderable Lists/Re-orderable Vertical Scroll Rect|UI/Extensions/Re-orderable list|[Example](http://i.giphy.com/3o85xri0ARKKSfDHIQ.gif)|| Ziboo +|| UI/Extensions/Re-orderable Lists/Re-orderable Horizontal Scroll Rect|||| Ziboo +|| UI/Extensions/Re-orderable Lists/Re-orderable Grid Scroll Rect|||| Ziboo +|| UI/Extensions/Re-orderable Lists/Re-orderable Vertical List|||| Ziboo +|| UI/Extensions/Re-orderable Lists/Re-orderable Hirizontal List|||| Ziboo +|| UI/Extensions/Re-orderable Lists/Re-orderable Grid|||| Ziboo + ## Effect components ## ===================== -Effect | Description | Component Command | Notes | Credits ---------- | -------------- | ---------------------------- | ------- | ----------- -**BestFitOutline** | An improved outline effect | UI / Effects / Extensions / Best Fit Outline | | Melang -**CurvedText** | A Text vertex manipulator for those users NOT using TextMeshPro (why ever not?) | UI / Effects / Extensons / Curved Text | | Breyer -**Gradient** | Apply vertex colours in a gradient on any UI object | UI / Effects / Extensions / Gradient | | Breyer -**LetterSpacing** | Allows finers control of text spacing | UI / Effects / Extensions / Letter Spacing | | Deeperbeige -**NicerOutline** | Another outline control | UI / Effects / Extensions / Nicer Outline | | Melang -**RaycastMask** | An example of an enhanced mask component able to work with the image data. Enables picking on image parts and not just the Rect Transform | UI / Effects / Extensions / Raycast Mask | | senritsu -**UIFlippable** | Image component effect to flip the graphic | UI / Effects / Extensions / UI Flippable | | ChoMPHi +Effect | Description | Component Command | Notes | Donate | Credits +--------- | -------------- | ---------------------------- | ------- | ----------- | ---------- +**BestFitOutline** | An improved outline effect | UI / Effects / Extensions / Best Fit Outline ||| Melang +**CurvedText** | A Text vertex manipulator for those users NOT using TextMeshPro (why ever not?) | UI / Effects / Extensons / Curved Text ||| Breyer +**Gradient** | Apply vertex colours in a gradient on any UI object | UI / Effects / Extensions / Gradient ||| Breyer +**LetterSpacing** | Allows finers control of text spacing | UI / Effects / Extensions / Letter Spacing ||| Deeperbeige +**NicerOutline** | Another outline control | UI / Effects / Extensions / Nicer Outline ||| Melang +**RaycastMask** | An example of an enhanced mask component able to work with the image data. Enables picking on image parts and not just the Rect Transform | UI / Effects / Extensions / Raycast Mask ||| senritsu +**UIFlippable** | Image component effect to flip the graphic | UI / Effects / Extensions / UI Flippable ||| ChoMPHi +**UIImageCrop** | Shader based mask system which clips to specific ranges X&Y | UI / Effects / Extensions / UI Image Crop ||| 00christian00 +**SoftAlphaMask** | Shader based mask able to clip images using an alpha mask | UI / Effects / Extensions / Soft Mask Script ||| NemoKrad +**CylinderText** | Allows finers control of text spacing | UI / Effects / Extensions / Cylinder Text ||| Breyer +## VR Components## +======================= + +Component | Description | Component Command | Notes | Donate | Credits +--------- | -------------- | ---------------------------- | ------- | ------ | ---------- +**VRCursor** | Cursor script for VR use (requires VRInputModule) | UI / Extensions / VR Cursoe ||| Ralph Barbagallo +**VRInputModule** | Input module to support the VR Cursor | Event / Vr Input Module ||| Ralph Barbagallo + + +## Input Modules ## +======================= + +Component | Description | Component Command | Notes | Donate | Credits +--------- | -------------- | ---------------------------- | ------- | ------ | ---------- +**AimerInputModule** | Replacement Input module to allow for a reciclue to interace with WorldSpace canvas UI | Event / Extensions / Aimer Input Module ||| Chris Trueman +**GamePadInputModule** | Stripped down SIM Input module for just gamepad/keybord input | Event / Extensions / GamePad Input Module ||| Simon (darkside) Jackson + ## Additional Components## ======================= -Component | Description | Component Command | Notes | Credits ---------- | -------------- | ---------------------------- | ------- | ------ -**ReturnKeyTrigger** | Does something?? | UI / Extensions / ReturnKey Trigger | | Melang, ddreaper -**TabNavigation** | An example Tab navigation script | UI / Extensions / Tab Navigation | | Melang, omatase -**uGUITools** | | Menu / uGUI | | Senshi -**FlowLayoutGroup** | A more rugged grid style layout group | Layout / Extensions / Flow Layout Group | [Example Video](https://www.youtube.com/watch?v=tMe_3tJTZvc) | Simie +Component | Description | Component Command | Notes | Donate | Credits +--------- | -------------- | ---------------------------- | ------- | ------ | ---------- +**ReturnKeyTrigger** | Does something?? | UI / Extensions / ReturnKey Trigger ||| Melang, ddreaper +**TabNavigation** | An example Tab navigation script, updated to add manual navigation | UI / Extensions / Tab Navigation ||| Melang, omatase +**uGUITools** | | Menu / uGUI ||| Senshi +**ScrollRectTweener** | Tweening solution for ScrollRects, add smoothing automatically | UI / Extensions / ScrollRectTweener ||| Martin Sharkbomb +**ScrollRectLinker** | ScrollRect Linker script, enable multiple ScrollRects to move together | UI / Extensions / ScrollRectLinker ||| Martin Sharkbomb +**ScrollRectEx** | Improved ScrollRect control, enables support for Nested ScrollRects | UI / Extensions / ScrollRectEx ||| CaptainSchnittchen, GamesRUs +**InputFocus** | Enhanced InputField control for forms, enables Enter to submit and other features | UI / Extensions / InputFocus ||| Zelek +**ImageExtended** | Improved Image control with rotation support and use of filled type without an Image (useful for masks) | UI / Extensions / Image Extended ||| Ges +**UIScrollToSelection** | Enables a ScrollRect to scroll based on the selected child automatically | UI / Extensions / UIScrollToSelection ||| zero3growlithe +**UISelectableExtension** | Refactor of original UI Button control, can now add Press/Release and Hold events to any Selectable control | UI / Extensions / UI Selectable Extension ||| AriathTheWise / Simon Jackson +**switchToRectTransform** | RectTransform extension method to move one Rect to another | N/A ||| Izitmee *More to come* +======================= ### How do I get set up? ### - -Either clone / download this repository to your machine and then copy the scripts in, or use the pre-packaged .UnityPackage and import it as a custom package in to your project. +Either clone / download this repository to your machine and then copy the scripts in, or use the pre-packaged .UnityPackage for your version of Unity and import it as a custom package in to your project. ### Contribution guidelines ### - Got a script you want added, then just fork and submit a PR. All contributions accepted (including fixes) Just ensure * The header of the script matches the standard used in all scripts @@ -75,7 +171,6 @@ Just ensure All scripts conform to the BSD license and are free to use / distribute. See the [LICENSE](https://bitbucket.org/ddreaper/unity-ui-extensions/src/6d03f25b0150994afa97c6a55854d6ae696cad13/LICENSE?at=default) file for more information ### Like what you see? ### - All these scripts were put together for my latest book Unity3D UI Essentials Check out the [page on my blog](http://bit.ly/Unity3DUIEssentials) for more details and learn all about the inner workings of the new Unity UI System. diff --git a/README.md.meta b/README.md.meta index 462d66a..bd96daa 100644 --- a/README.md.meta +++ b/README.md.meta @@ -1,4 +1,8 @@ fileFormatVersion: 2 -guid: a7b682f292cfba6438971b2bc7e90705 +guid: f6cbd6c26357c6a40947224e172bfdf6 +timeCreated: 1438724032 +licenseType: Free DefaultImporter: userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts.meta b/Scripts.meta index 4b89cef..ffbad0d 100644 --- a/Scripts.meta +++ b/Scripts.meta @@ -1,5 +1,9 @@ fileFormatVersion: 2 -guid: 9001b012db436b1438e03cdda2954484 +guid: 9d40233b1c5add641bb2f4f7f12af05e folderAsset: yes +timeCreated: 1438724032 +licenseType: Free DefaultImporter: userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Accordion/AccordionElement.cs b/Scripts/Accordion/AccordionElement.cs index 3005e55..a2f7055 100644 --- a/Scripts/Accordion/AccordionElement.cs +++ b/Scripts/Accordion/AccordionElement.cs @@ -38,7 +38,8 @@ namespace UnityEngine.UI.Extensions this.m_LayoutElement = this.gameObject.GetComponent(); this.onValueChanged.AddListener(OnValueChanged); } - + +#if UNITY_EDITOR protected override void OnValidate() { base.OnValidate(); @@ -67,7 +68,8 @@ namespace UnityEngine.UI.Extensions } } } - +#endif + public void OnValueChanged(bool state) { if (this.m_LayoutElement == null) diff --git a/Scripts/Accordion/Editor/AccordionElementEditor.cs b/Scripts/Accordion/Editor/AccordionElementEditor.cs index 29e8d8e..92e53f4 100644 --- a/Scripts/Accordion/Editor/AccordionElementEditor.cs +++ b/Scripts/Accordion/Editor/AccordionElementEditor.cs @@ -1,23 +1,23 @@ -///Credit ChoMPHi +///Credit ChoMPHi ///Sourced from - http://forum.unity3d.com/threads/accordion-type-layout.271818/ -using UnityEngine.UI.Extensions; - -namespace UnityEditor.UI -{ - [CustomEditor(typeof(AccordionElement), true)] - public class AccordionElementEditor : ToggleEditor { - - public override void OnInspectorGUI() - { - this.serializedObject.Update(); - EditorGUILayout.PropertyField(this.serializedObject.FindProperty("m_MinHeight")); - this.serializedObject.ApplyModifiedProperties(); - - base.serializedObject.Update(); - EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_IsOn")); - EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_Interactable")); - base.serializedObject.ApplyModifiedProperties(); - } - } +using UnityEngine.UI.Extensions; + +namespace UnityEditor.UI +{ + [CustomEditor(typeof(AccordionElement), true)] + public class AccordionElementEditor : ToggleEditor { + + public override void OnInspectorGUI() + { + this.serializedObject.Update(); + EditorGUILayout.PropertyField(this.serializedObject.FindProperty("m_MinHeight")); + this.serializedObject.ApplyModifiedProperties(); + + base.serializedObject.Update(); + EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_IsOn")); + EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_Interactable")); + base.serializedObject.ApplyModifiedProperties(); + } + } } \ No newline at end of file diff --git a/Scripts/Accordion/Tweening/ITweenValue.cs b/Scripts/Accordion/Tweening/ITweenValue.cs index 7f09a75..25d135b 100644 --- a/Scripts/Accordion/Tweening/ITweenValue.cs +++ b/Scripts/Accordion/Tweening/ITweenValue.cs @@ -1,16 +1,16 @@ -///Credit ChoMPHi -///Sourced from - http://forum.unity3d.com/threads/accordion-type-layout.271818/ - +///Credit ChoMPHi +///Sourced from - http://forum.unity3d.com/threads/accordion-type-layout.271818/ + using System.Collections; namespace UnityEngine.UI.Extensions.Tweens -{ - internal interface ITweenValue - { - void TweenValue(float floatPercentage); - bool ignoreTimeScale { get; } - float duration { get; } - bool ValidTarget(); - void Finished(); - } +{ + internal interface ITweenValue + { + void TweenValue(float floatPercentage); + bool ignoreTimeScale { get; } + float duration { get; } + bool ValidTarget(); + void Finished(); + } } \ No newline at end of file diff --git a/Scripts/Accordion/Tweening/TweenRunner.cs b/Scripts/Accordion/Tweening/TweenRunner.cs index 3a0fe8f..8a3a8e3 100644 --- a/Scripts/Accordion/Tweening/TweenRunner.cs +++ b/Scripts/Accordion/Tweening/TweenRunner.cs @@ -1,63 +1,63 @@ -///Credit ChoMPHi -///Sourced from - http://forum.unity3d.com/threads/accordion-type-layout.271818/ - +///Credit ChoMPHi +///Sourced from - http://forum.unity3d.com/threads/accordion-type-layout.271818/ + using System.Collections; namespace UnityEngine.UI.Extensions.Tweens -{ - // Tween runner, executes the given tween. - // The coroutine will live within the given - // behaviour container. - internal class TweenRunner where T : struct, ITweenValue - { - protected MonoBehaviour m_CoroutineContainer; - protected IEnumerator m_Tween; - - // utility function for starting the tween - private static IEnumerator Start(T tweenInfo) - { - if (!tweenInfo.ValidTarget()) - yield break; - - float elapsedTime = 0.0f; - while (elapsedTime < tweenInfo.duration) - { - elapsedTime += tweenInfo.ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime; - var percentage = Mathf.Clamp01 (elapsedTime / tweenInfo.duration); - tweenInfo.TweenValue (percentage); - yield return null; - } - tweenInfo.TweenValue (1.0f); - tweenInfo.Finished(); - } - - public void Init(MonoBehaviour coroutineContainer) - { - m_CoroutineContainer = coroutineContainer; - } - - public void StartTween(T info) - { - if (m_CoroutineContainer == null) - { - Debug.LogWarning ("Coroutine container not configured... did you forget to call Init?"); - return; - } - - if (m_Tween != null) - { - m_CoroutineContainer.StopCoroutine (m_Tween); - m_Tween = null; - } - - if (!m_CoroutineContainer.gameObject.activeInHierarchy) - { - info.TweenValue(1.0f); - return; - } - - m_Tween = Start (info); - m_CoroutineContainer.StartCoroutine (m_Tween); - } - } +{ + // Tween runner, executes the given tween. + // The coroutine will live within the given + // behaviour container. + internal class TweenRunner where T : struct, ITweenValue + { + protected MonoBehaviour m_CoroutineContainer; + protected IEnumerator m_Tween; + + // utility function for starting the tween + private static IEnumerator Start(T tweenInfo) + { + if (!tweenInfo.ValidTarget()) + yield break; + + float elapsedTime = 0.0f; + while (elapsedTime < tweenInfo.duration) + { + elapsedTime += tweenInfo.ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime; + var percentage = Mathf.Clamp01 (elapsedTime / tweenInfo.duration); + tweenInfo.TweenValue (percentage); + yield return null; + } + tweenInfo.TweenValue (1.0f); + tweenInfo.Finished(); + } + + public void Init(MonoBehaviour coroutineContainer) + { + m_CoroutineContainer = coroutineContainer; + } + + public void StartTween(T info) + { + if (m_CoroutineContainer == null) + { + Debug.LogWarning ("Coroutine container not configured... did you forget to call Init?"); + return; + } + + if (m_Tween != null) + { + m_CoroutineContainer.StopCoroutine (m_Tween); + m_Tween = null; + } + + if (!m_CoroutineContainer.gameObject.activeInHierarchy) + { + info.TweenValue(1.0f); + return; + } + + m_Tween = Start (info); + m_CoroutineContainer.StartCoroutine (m_Tween); + } + } } \ No newline at end of file diff --git a/Scripts/BestFitOutline.cs b/Scripts/BestFitOutline.cs deleted file mode 100644 index ae202ed..0000000 --- a/Scripts/BestFitOutline.cs +++ /dev/null @@ -1,50 +0,0 @@ -/// Credit Melang -/// Sourced from - http://forum.unity3d.com/members/melang.593409/ - -using System.Collections.Generic; -namespace UnityEngine.UI.Extensions -{ - [AddComponentMenu("UI/Effects/Extensions/BestFit Outline")] - public class BestFitOutline : Shadow - { - // - // Constructors - // - protected BestFitOutline () - { - } - - // - // Methods - // - public override void ModifyVertices (List verts) - { - if (!this.IsActive ()) - { - return; - } - - Text foundtext = GetComponent(); - - float best_fit_adjustment = 1f; - - if (foundtext && foundtext.resizeTextForBestFit) - { - best_fit_adjustment = (float)foundtext.cachedTextGenerator.fontSizeUsedForBestFit / (foundtext.resizeTextMaxSize-1); //max size seems to be exclusive - } - - int start = 0; - int count = verts.Count; - base.ApplyShadow (verts, base.effectColor, start, verts.Count, base.effectDistance.x*best_fit_adjustment, base.effectDistance.y*best_fit_adjustment); - start = count; - count = verts.Count; - base.ApplyShadow (verts, base.effectColor, start, verts.Count, base.effectDistance.x*best_fit_adjustment, -base.effectDistance.y*best_fit_adjustment); - start = count; - count = verts.Count; - base.ApplyShadow (verts, base.effectColor, start, verts.Count, -base.effectDistance.x*best_fit_adjustment, base.effectDistance.y*best_fit_adjustment); - start = count; - count = verts.Count; - base.ApplyShadow (verts, base.effectColor, start, verts.Count, -base.effectDistance.x*best_fit_adjustment, -base.effectDistance.y*best_fit_adjustment); - } - } -} diff --git a/Scripts/BoundTooltip/BoundTooltipTrigger.cs b/Scripts/BoundTooltip/BoundTooltipTrigger.cs deleted file mode 100644 index 9776722..0000000 --- a/Scripts/BoundTooltip/BoundTooltipTrigger.cs +++ /dev/null @@ -1,39 +0,0 @@ -///Credit Martin Nerurkar // www.martin.nerurkar.de // www.sharkbombs.com -///Sourced from - http://www.sharkbombs.com/2015/02/10/tooltips-with-the-new-unity-ui-ugui/ - -using UnityEngine.EventSystems; - -namespace UnityEngine.UI.Extensions -{ - [AddComponentMenu("UI/Extensions/Bound Tooltip/Tooltip Trigger")] - public class BoundTooltipTrigger : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler - { - public string text; - - public void OnPointerEnter(PointerEventData eventData) - { - StartHover(new Vector3(eventData.position.x, eventData.position.y, 0f)); - } - public void OnSelect(BaseEventData eventData) - { - StartHover(transform.position); - } - public void OnPointerExit(PointerEventData eventData) - { - StopHover(); - } - public void OnDeselect(BaseEventData eventData) - { - StopHover(); - } - - void StartHover(Vector3 position) - { - BoundTooltipItem.Instance.ShowTooltip(text, position); - } - void StopHover() - { - BoundTooltipItem.Instance.HideTooltip(); - } - } -} diff --git a/Scripts/ComboBox/AutoCompleteComboBox.cs b/Scripts/ComboBox/AutoCompleteComboBox.cs index dfdc006..41642f0 100644 --- a/Scripts/ComboBox/AutoCompleteComboBox.cs +++ b/Scripts/ComboBox/AutoCompleteComboBox.cs @@ -60,7 +60,7 @@ namespace UnityEngine.UI.Extensions } // private int scrollOffset; //offset of the selected item - private int _selectedIndex = 0; + // private int _selectedIndex = 0; [SerializeField] private int _itemsToDisplay; @@ -122,7 +122,7 @@ namespace UnityEngine.UI.Extensions _panelItems = AvailableOptions.ToList(); RebuildPanel(); - RedrawPanel(); + //RedrawPanel(); - causes an initialisation failure in U5 return success; } diff --git a/Scripts/ComboBox/ComboBox.cs b/Scripts/ComboBox/ComboBox.cs index 6a4775b..0c80757 100644 --- a/Scripts/ComboBox/ComboBox.cs +++ b/Scripts/ComboBox/ComboBox.cs @@ -59,7 +59,7 @@ namespace UnityEngine.UI.Extensions } // private int scrollOffset; //offset of the selected item - private int _selectedIndex = 0; + // private int _selectedIndex = 0; [SerializeField] private int _itemsToDisplay; @@ -120,7 +120,7 @@ namespace UnityEngine.UI.Extensions _panelItems = AvailableOptions.ToList(); RebuildPanel(); - RedrawPanel(); + //RedrawPanel(); - causes an initialisation failure in U5 return success; } diff --git a/Scripts/ComboBox/DropDownList.cs b/Scripts/ComboBox/DropDownList.cs index dc7441a..66e7f6b 100644 --- a/Scripts/ComboBox/DropDownList.cs +++ b/Scripts/ComboBox/DropDownList.cs @@ -70,7 +70,7 @@ namespace UnityEngine.UI.Extensions } } - public void Awake() + public void Start() { Initialize(); } @@ -277,6 +277,8 @@ namespace UnityEngine.UI.Extensions /// whether an item was directly clicked on public void ToggleDropdownPanel(bool directClick) { + _overlayRT.transform.localScale = new Vector3(1, 1, 1); + _scrollBarRT.transform.localScale = new Vector3(1, 1, 1); _isPanelActive = !_isPanelActive; _overlayRT.gameObject.SetActive(_isPanelActive); if (_isPanelActive) diff --git a/Scripts/CanvasGroupActivator.cs b/Scripts/Editor/CanvasGroupActivator.cs similarity index 100% rename from Scripts/CanvasGroupActivator.cs rename to Scripts/Editor/CanvasGroupActivator.cs diff --git a/Scripts/CanvasGroupActivator.cs.meta b/Scripts/Editor/CanvasGroupActivator.cs.meta similarity index 100% rename from Scripts/CanvasGroupActivator.cs.meta rename to Scripts/Editor/CanvasGroupActivator.cs.meta diff --git a/Scripts/Editor/UIExtensionsMenuOptions.cs b/Scripts/Editor/UIExtensionsMenuOptions.cs index 33b34fb..eef2dd1 100644 --- a/Scripts/Editor/UIExtensionsMenuOptions.cs +++ b/Scripts/Editor/UIExtensionsMenuOptions.cs @@ -14,19 +14,19 @@ namespace UnityEditor.UI #region Unity Builder section - Do not change unless UI Source (Editor\MenuOptions) changes #region Unity Builder properties - Do not change unless UI Source (Editor\MenuOptions) changes private const string kUILayerName = "UI"; - private const float kWidth = 160f; - private const float kThickHeight = 30f; - private const float kThinHeight = 20f; - private const string kStandardSpritePath = "UI/Skin/UISprite.psd"; + private const float kWidth = 160f; + private const float kThickHeight = 30f; + private const float kThinHeight = 20f; + private const string kStandardSpritePath = "UI/Skin/UISprite.psd"; private const string kBackgroundSpriteResourcePath = "UI/Skin/Background.psd"; - private const string kInputFieldBackgroundPath = "UI/Skin/InputFieldBackground.psd"; - private const string kKnobPath = "UI/Skin/Knob.psd"; - private const string kCheckmarkPath = "UI/Skin/Checkmark.psd"; + private const string kInputFieldBackgroundPath = "UI/Skin/InputFieldBackground.psd"; + private const string kKnobPath = "UI/Skin/Knob.psd"; + private const string kCheckmarkPath = "UI/Skin/Checkmark.psd"; - private static Vector2 s_ThickGUIElementSize = new Vector2(kWidth, kThickHeight); - private static Vector2 s_ThinGUIElementSize = new Vector2(kWidth, kThinHeight); - private static Vector2 s_ImageGUIElementSize = new Vector2(100f, 100f); - private static Color s_DefaultSelectableColor = new Color(1f, 1f, 1f, 1f); + private static Vector2 s_ThickGUIElementSize = new Vector2(kWidth, kThickHeight); + private static Vector2 s_ThinGUIElementSize = new Vector2(kWidth, kThinHeight); + private static Vector2 s_ImageGUIElementSize = new Vector2(100f, 100f); + private static Color s_DefaultSelectableColor = new Color(1f, 1f, 1f, 1f); private static Color s_TextColor = new Color(50f / 255f, 50f / 255f, 50f / 255f, 1f); #endregion #region Unity Builder methods - Do not change unless UI Source (Editor\MenuOptions) changes @@ -97,7 +97,7 @@ namespace UnityEditor.UI Selection.activeGameObject = child; return child; } - + static GameObject CreateUIObject(string name, GameObject parent) { GameObject go = new GameObject(name); @@ -157,7 +157,6 @@ namespace UnityEditor.UI GameObjectUtility.SetParentAndAlign(eventSystem, parent); esys = eventSystem.AddComponent(); eventSystem.AddComponent(); - eventSystem.AddComponent(); Undo.RegisterCreatedObjectUndo(eventSystem, "Create " + eventSystem.name); } @@ -207,7 +206,8 @@ namespace UnityEditor.UI #region UI Extensions "Create" Menu items - [MenuItem("GameObject/UI/Extensions/Horizontal Scroll Snap", false)] + #region Scroll Snap controls + [MenuItem("GameObject/UI/Extensions/Horizontal Scroll Snap", false)] static public void AddHorizontalScrollSnap(MenuCommand menuCommand) { GameObject horizontalScrollSnapRoot = CreateUIElementRoot("Horizontal Scroll Snap", menuCommand, s_ThickGUIElementSize); @@ -224,7 +224,7 @@ namespace UnityEditor.UI rectTransformScrollSnapRoot.anchorMax = new Vector2(0.5f, 0.5f); rectTransformScrollSnapRoot.anchoredPosition = Vector2.zero; rectTransformScrollSnapRoot.sizeDelta = new Vector2(300f, 150f); - + Image image = horizontalScrollSnapRoot.AddComponent(); image.sprite = AssetDatabase.GetBuiltinExtraResource(kBackgroundSpriteResourcePath); @@ -233,10 +233,76 @@ namespace UnityEditor.UI ScrollRect sr = horizontalScrollSnapRoot.AddComponent(); sr.vertical = false; + sr.horizontal = true; horizontalScrollSnapRoot.AddComponent(); //Setup Content container - RectTransform rectTransformContent = childContent.AddComponent(); + RectTransform rectTransformContent = childContent.GetComponent(); + rectTransformContent.anchorMin = Vector2.zero; + rectTransformContent.anchorMax = new Vector2(1f, 1f); + rectTransformContent.sizeDelta = Vector2.zero; + + sr.content = rectTransformContent; + + //Setup 1st Child + Image pageImage = childPage01.AddComponent(); + pageImage.sprite = AssetDatabase.GetBuiltinExtraResource(kStandardSpritePath); + pageImage.type = Image.Type.Sliced; + pageImage.color = s_DefaultSelectableColor; + + RectTransform rectTransformPage01 = childPage01.GetComponent(); + rectTransformPage01.anchorMin = new Vector2(0f, 0.5f); + rectTransformPage01.anchorMax = new Vector2(0f, 0.5f); + rectTransformPage01.pivot = new Vector2(0f, 0.5f); + + //Setup Text on Page01 + Text text = childText.AddComponent(); + text.text = "Page_01"; + text.alignment = TextAnchor.MiddleCenter; + text.color = new Color(0.196f, 0.196f, 0.196f); + + //Setup Text 1st Child + RectTransform rectTransformPage01Text = childText.GetComponent(); + rectTransformPage01Text.anchorMin = new Vector2(0.5f, 0.5f); + rectTransformPage01Text.anchorMax = new Vector2(0.5f, 0.5f); + rectTransformPage01Text.pivot = new Vector2(0.5f, 0.5f); + + + //Need to add example child components like in the Asset (SJ) + Selection.activeGameObject = horizontalScrollSnapRoot; + } + + [MenuItem("GameObject/UI/Extensions/Vertical Scroll Snap", false)] + static public void AddVerticallScrollSnap(MenuCommand menuCommand) + { + GameObject verticalScrollSnapRoot = CreateUIElementRoot("Vertical Scroll Snap", menuCommand, s_ThickGUIElementSize); + + GameObject childContent = CreateUIObject("Content", verticalScrollSnapRoot); + + GameObject childPage01 = CreateUIObject("Page_01", childContent); + + GameObject childText = CreateUIObject("Text", childPage01); + + // Set RectTransform to stretch + RectTransform rectTransformScrollSnapRoot = verticalScrollSnapRoot.GetComponent(); + rectTransformScrollSnapRoot.anchorMin = new Vector2(0.5f, 0.5f); + rectTransformScrollSnapRoot.anchorMax = new Vector2(0.5f, 0.5f); + rectTransformScrollSnapRoot.anchoredPosition = Vector2.zero; + rectTransformScrollSnapRoot.sizeDelta = new Vector2(300f, 150f); + + + Image image = verticalScrollSnapRoot.AddComponent(); + image.sprite = AssetDatabase.GetBuiltinExtraResource(kBackgroundSpriteResourcePath); + image.type = Image.Type.Sliced; + image.color = new Color(1f, 1f, 1f, 0.392f); + + ScrollRect sr = verticalScrollSnapRoot.AddComponent(); + sr.vertical = true; + sr.horizontal = false; + verticalScrollSnapRoot.AddComponent(); + + //Setup Content container + RectTransform rectTransformContent = childContent.GetComponent(); rectTransformContent.anchorMin = Vector2.zero; rectTransformContent.anchorMax = new Vector2(1f, 1f); //rectTransformContent.anchoredPosition = Vector2.zero; @@ -248,15 +314,16 @@ namespace UnityEditor.UI Image pageImage = childPage01.AddComponent(); pageImage.sprite = AssetDatabase.GetBuiltinExtraResource(kStandardSpritePath); pageImage.type = Image.Type.Sliced; - pageImage.color = s_DefaultSelectableColor; - + pageImage.color = s_DefaultSelectableColor; + RectTransform rectTransformPage01 = childPage01.GetComponent(); - rectTransformPage01.anchorMin = new Vector2(0f, 0.5f); - rectTransformPage01.anchorMax = new Vector2(0f, 0.5f); + rectTransformPage01.anchorMin = new Vector2(0.5f, 0f); + rectTransformPage01.anchorMax = new Vector2(0.5f, 0f); + rectTransformPage01.anchoredPosition = new Vector2(-rectTransformPage01.sizeDelta.x / 2, rectTransformPage01.sizeDelta.y / 2); //rectTransformPage01.anchoredPosition = Vector2.zero; //rectTransformPage01.sizeDelta = Vector2.zero; - rectTransformPage01.pivot = new Vector2(0f, 0.5f); - + rectTransformPage01.pivot = new Vector2(0f, 0.5f); + //Setup Text on Page01 Text text = childText.AddComponent(); text.text = "Page_01"; @@ -274,9 +341,216 @@ namespace UnityEditor.UI //Need to add example child components like in the Asset (SJ) - Selection.activeGameObject = horizontalScrollSnapRoot; + Selection.activeGameObject = verticalScrollSnapRoot; } + #region New ScrollSnapCode + static public void FixedScrollSnapBase(MenuCommand menuCommand, string name, ScrollSnap.ScrollDirection direction, int itemVisible, int itemCount, Vector2 itemSize) + { + GameObject scrollSnapRoot = CreateUIElementRoot(name, menuCommand, s_ThickGUIElementSize); + GameObject itemList = CreateUIObject("List", scrollSnapRoot); + + // Set RectTransform to stretch + RectTransform rectTransformScrollSnapRoot = scrollSnapRoot.GetComponent(); + rectTransformScrollSnapRoot.anchorMin = new Vector2(0.5f, 0.5f); + rectTransformScrollSnapRoot.anchorMax = new Vector2(0.5f, 0.5f); + rectTransformScrollSnapRoot.anchoredPosition = Vector2.zero; + + if (direction == ScrollSnap.ScrollDirection.Horizontal) + { + rectTransformScrollSnapRoot.sizeDelta = new Vector2(itemVisible * itemSize.x, itemSize.y); + } + else + { + rectTransformScrollSnapRoot.sizeDelta = new Vector2(itemSize.x, itemVisible * itemSize.y); + } + + Image image = scrollSnapRoot.AddComponent(); + image.sprite = AssetDatabase.GetBuiltinExtraResource(kBackgroundSpriteResourcePath); + image.type = Image.Type.Sliced; + image.color = new Color(1f, 1f, 1f, 1f); + + Mask listMask = scrollSnapRoot.AddComponent(); + listMask.showMaskGraphic = false; + + ScrollRect scrollRect = scrollSnapRoot.AddComponent(); + scrollRect.vertical = direction == ScrollSnap.ScrollDirection.Vertical; + scrollRect.horizontal = direction == ScrollSnap.ScrollDirection.Horizontal; + + ScrollSnap scrollSnap = scrollSnapRoot.AddComponent(); + scrollSnap.direction = direction; + scrollSnap.itemsVisibleAtOnce = itemVisible; + + //Setup Content container + RectTransform rectTransformContent = itemList.GetComponent(); + rectTransformContent.anchorMin = Vector2.zero; + rectTransformContent.anchorMax = new Vector2(1f, 1f); + rectTransformContent.sizeDelta = Vector2.zero; + scrollRect.content = rectTransformContent; + + //Setup Item list container + if (direction == ScrollSnap.ScrollDirection.Horizontal) + { + itemList.AddComponent(); + ContentSizeFitter sizeFitter = itemList.AddComponent(); + sizeFitter.horizontalFit = ContentSizeFitter.FitMode.MinSize; + } + else + { + itemList.AddComponent(); + ContentSizeFitter sizeFitter = itemList.AddComponent(); + sizeFitter.verticalFit = ContentSizeFitter.FitMode.MinSize; + } + + //Setup children + for (var i = 0; i < itemCount; i++) + { + GameObject item = CreateUIObject(string.Format("Item_{0:00}", i), itemList); + GameObject childText = CreateUIObject("Text", item); + + Image pageImage = item.AddComponent(); + pageImage.sprite = AssetDatabase.GetBuiltinExtraResource(kStandardSpritePath); + pageImage.type = Image.Type.Sliced; + pageImage.color = s_DefaultSelectableColor; + + LayoutElement elementLayout = item.AddComponent(); + if (direction == ScrollSnap.ScrollDirection.Horizontal) + { + elementLayout.minWidth = itemSize.x; + } + else + { + elementLayout.minHeight = itemSize.y; + } + + RectTransform rectTransformPage01 = item.GetComponent(); + rectTransformPage01.anchorMin = new Vector2(0f, 0.5f); + rectTransformPage01.anchorMax = new Vector2(0f, 0.5f); + rectTransformPage01.pivot = new Vector2(0f, 0.5f); + + //Setup Text on Page01 + Text text = childText.AddComponent(); + text.text = item.name; + text.alignment = TextAnchor.MiddleCenter; + text.color = new Color(0.196f, 0.196f, 0.196f); + + //Setup Text 1st Child + RectTransform rectTransformPage01Text = childText.GetComponent(); + rectTransformPage01Text.anchorMin = new Vector2(0.5f, 0.5f); + rectTransformPage01Text.anchorMax = new Vector2(0.5f, 0.5f); + rectTransformPage01Text.pivot = new Vector2(0.5f, 0.5f); + } + Selection.activeGameObject = scrollSnapRoot; + } + + [MenuItem("GameObject/UI/Extensions/Fixed Item Scroll/Snap Horizontal Single Item", false)] + static public void AddFixedItemScrollSnapHorizontalSingle(MenuCommand menuCommand) + { + FixedScrollSnapBase(menuCommand, "Scroll Snap Horizontal Single", ScrollSnap.ScrollDirection.Horizontal, 1, 3, new Vector2(100, 100)); + } + + [MenuItem("GameObject/UI/Extensions/Fixed Item Scroll/Snap Horizontal Multiple Items", false)] + static public void AddFixedItemScrollSnapHorizontalMultiple(MenuCommand menuCommand) + { + FixedScrollSnapBase(menuCommand, "Scroll Snap Horizontal Multiple", ScrollSnap.ScrollDirection.Horizontal, 3, 15, new Vector2(100, 100)); + } + + [MenuItem("GameObject/UI/Extensions/Fixed Item Scroll/Snap Vertical Single Item", false)] + static public void AddFixedItemScrollSnapVerticalSingle(MenuCommand menuCommand) + { + FixedScrollSnapBase(menuCommand, "Scroll Snap Vertical Multiple", ScrollSnap.ScrollDirection.Vertical, 1, 3, new Vector2(100, 100)); + } + + [MenuItem("GameObject/UI/Extensions/Fixed Item Scroll/Snap Vertical Multiple Items", false)] + static public void AddFixedItemScrollSnapVerticalMultiple(MenuCommand menuCommand) + { + FixedScrollSnapBase(menuCommand, "Scroll Snap Vertical Multiple", ScrollSnap.ScrollDirection.Vertical, 3, 15, new Vector2(100, 100)); + } + #endregion + + #endregion + + #region UIVertical Scroller + [MenuItem("GameObject/UI/Extensions/UI Vertical Scroller", false)] + static public void AddUIVerticallScroller(MenuCommand menuCommand) + { + GameObject uiVerticalScrollerRoot = CreateUIElementRoot("UI Vertical Scroller", menuCommand, s_ThickGUIElementSize); + + GameObject uiScrollerCenter = CreateUIObject("Center", uiVerticalScrollerRoot); + + GameObject childContent = CreateUIObject("Content", uiVerticalScrollerRoot); + + // Set RectTransform to stretch + RectTransform rectTransformScrollSnapRoot = uiVerticalScrollerRoot.GetComponent(); + rectTransformScrollSnapRoot.anchorMin = new Vector2(0.5f, 0.5f); + rectTransformScrollSnapRoot.anchorMax = new Vector2(0.5f, 0.5f); + rectTransformScrollSnapRoot.anchoredPosition = Vector2.zero; + rectTransformScrollSnapRoot.sizeDelta = new Vector2(500f, 150f); + + // Add required ScrollRect + ScrollRect sr = uiVerticalScrollerRoot.AddComponent(); + sr.vertical = true; + sr.horizontal = false; + sr.movementType = ScrollRect.MovementType.Unrestricted; + var uiscr = uiVerticalScrollerRoot.AddComponent(); + + //Setup container center point + RectTransform rectTransformCenter = uiScrollerCenter.GetComponent(); + rectTransformCenter.anchorMin = new Vector2(0f, 0.3f); + rectTransformCenter.anchorMax = new Vector2(1f, 0.6f); + rectTransformCenter.sizeDelta = Vector2.zero; + + uiscr._center = uiScrollerCenter.GetComponent(); + + //Setup Content container + RectTransform rectTransformContent = childContent.GetComponent(); + rectTransformContent.anchorMin = Vector2.zero; + rectTransformContent.anchorMax = new Vector2(1f, 1f); + rectTransformContent.sizeDelta = Vector2.zero; + + sr.content = rectTransformContent; + + // Add sample children + for (int i = 0; i < 10; i++) + { + GameObject childPage = CreateUIObject("Page_" + i, childContent); + + GameObject childText = CreateUIObject("Text", childPage); + + //Setup 1st Child + Image pageImage = childPage.AddComponent(); + pageImage.sprite = AssetDatabase.GetBuiltinExtraResource(kStandardSpritePath); + pageImage.type = Image.Type.Sliced; + pageImage.color = s_DefaultSelectableColor; + + RectTransform rectTransformPage = childPage.GetComponent(); + rectTransformPage.anchorMin = new Vector2(0f, 0.5f); + rectTransformPage.anchorMax = new Vector2(1f, 0.5f); + rectTransformPage.sizeDelta = new Vector2(0f, 80f); + rectTransformPage.pivot = new Vector2(0.5f, 0.5f); + rectTransformPage.localPosition = new Vector3(0, 80 * i, 0); + childPage.AddComponent