Merged ddreaper/unity-ui-extensions into default
commit
c2fa19fd68
|
@ -1,4 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c35f61edc180166489847c79f4b8ea46
|
||||
guid: e9a81748fac51154f8688d2e3c46fd56
|
||||
timeCreated: 1438724032
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
169
README.md
169
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.
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a7b682f292cfba6438971b2bc7e90705
|
||||
guid: f6cbd6c26357c6a40947224e172bfdf6
|
||||
timeCreated: 1438724032
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9001b012db436b1438e03cdda2954484
|
||||
guid: 9d40233b1c5add641bb2f4f7f12af05e
|
||||
folderAsset: yes
|
||||
timeCreated: 1438724032
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
|
@ -38,7 +38,8 @@ namespace UnityEngine.UI.Extensions
|
|||
this.m_LayoutElement = this.gameObject.GetComponent<LayoutElement>();
|
||||
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)
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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<T> 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<T> 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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<UIVertex> verts)
|
||||
{
|
||||
if (!this.IsActive ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Text foundtext = GetComponent<Text>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace UnityEngine.UI.Extensions
|
|||
}
|
||||
}
|
||||
|
||||
public void Awake()
|
||||
public void Start()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
@ -277,6 +277,8 @@ namespace UnityEngine.UI.Extensions
|
|||
/// <param name="directClick"> whether an item was directly clicked on</param>
|
||||
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)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,10 @@
|
|||
/// Credit Senshi
|
||||
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/ (uGUITools link)
|
||||
|
||||
/// Credit Senshi
|
||||
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/ (uGUITools link)
|
||||
|
||||
using UnityEditor;
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
public class uGUITools : MonoBehaviour
|
||||
public static class uGUITools
|
||||
{
|
||||
[MenuItem("uGUI/Anchors to Corners %[")]
|
||||
static void AnchorsToCorners()
|
||||
|
@ -112,4 +112,4 @@ namespace UnityEngine.UI.Extensions
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0a683473734705f4a81f6a4dbff1cb93
|
||||
guid: cbbc72115bdf3fe4a93d8566634c6e61
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
|
@ -0,0 +1,62 @@
|
|||
/// 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 ModifyMesh (Mesh mesh)
|
||||
{
|
||||
if (!this.IsActive ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<UIVertex> verts = new List<UIVertex>();
|
||||
using (var helper = new VertexHelper(mesh))
|
||||
{
|
||||
helper.GetUIVertexStream(verts);
|
||||
}
|
||||
|
||||
Text foundtext = GetComponent<Text>();
|
||||
|
||||
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.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, base.effectDistance.x*best_fit_adjustment, base.effectDistance.y*best_fit_adjustment);
|
||||
start = count;
|
||||
count = verts.Count;
|
||||
base.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, base.effectDistance.x*best_fit_adjustment, -base.effectDistance.y*best_fit_adjustment);
|
||||
start = count;
|
||||
count = verts.Count;
|
||||
base.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, -base.effectDistance.x*best_fit_adjustment, base.effectDistance.y*best_fit_adjustment);
|
||||
start = count;
|
||||
count = verts.Count;
|
||||
base.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, -base.effectDistance.x*best_fit_adjustment, -base.effectDistance.y*best_fit_adjustment);
|
||||
|
||||
using (var helper = new VertexHelper())
|
||||
{
|
||||
helper.AddUIVertexTriangleStream(verts);
|
||||
helper.FillMesh(mesh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
[RequireComponent(typeof(Text), typeof(RectTransform))]
|
||||
[AddComponentMenu("UI/Effects/Extensions/Curved Text")]
|
||||
public class CurvedText : BaseVertexEffect
|
||||
public class CurvedText : BaseMeshEffect
|
||||
{
|
||||
public AnimationCurve curveForText = AnimationCurve.Linear(0, 0, 1, 10);
|
||||
public float curveMultiplier = 1;
|
||||
|
@ -40,17 +40,19 @@ namespace UnityEngine.UI.Extensions
|
|||
rectTrans = GetComponent<RectTransform>();
|
||||
OnRectTransformDimensionsChange();
|
||||
}
|
||||
public override void ModifyVertices(System.Collections.Generic.List<UIVertex> verts)
|
||||
public override void ModifyMesh(VertexHelper vh)
|
||||
{
|
||||
if (!IsActive())
|
||||
return;
|
||||
|
||||
for (int index = 0; index < verts.Count; index++)
|
||||
int count = vh.currentVertCount;
|
||||
if (!IsActive() || count == 0)
|
||||
{
|
||||
var uiVertex = verts[index];
|
||||
//Debug.Log ();
|
||||
return;
|
||||
}
|
||||
for (int index = 0; index < vh.currentVertCount; index++)
|
||||
{
|
||||
UIVertex uiVertex = new UIVertex();
|
||||
vh.PopulateUIVertex(ref uiVertex, index);
|
||||
uiVertex.position.y += curveForText.Evaluate(rectTrans.rect.width * rectTrans.pivot.x + uiVertex.position.x) * curveMultiplier;
|
||||
verts[index] = uiVertex;
|
||||
vh.SetUIVertex(uiVertex, index);
|
||||
}
|
||||
}
|
||||
protected override void OnRectTransformDimensionsChange()
|
|
@ -0,0 +1,60 @@
|
|||
/// adaption for cylindrical bending by herbst
|
||||
/// Credit Breyer
|
||||
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/#post-1777407
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[RequireComponent(typeof(Text), typeof(RectTransform))]
|
||||
[AddComponentMenu("UI/Effects/Extensions/Cylinder Text")]
|
||||
public class CylinderText : BaseMeshEffect
|
||||
{
|
||||
public float radius;
|
||||
private RectTransform rectTrans;
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
if (rectTrans == null)
|
||||
rectTrans = GetComponent<RectTransform>();
|
||||
}
|
||||
#endif
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
rectTrans = GetComponent<RectTransform>();
|
||||
OnRectTransformDimensionsChange();
|
||||
}
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
rectTrans = GetComponent<RectTransform>();
|
||||
OnRectTransformDimensionsChange();
|
||||
}
|
||||
public override void ModifyMesh(VertexHelper vh)
|
||||
{
|
||||
if (! IsActive()) return;
|
||||
|
||||
int count = vh.currentVertCount;
|
||||
if (!IsActive() || count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int index = 0; index < vh.currentVertCount; index++)
|
||||
{
|
||||
UIVertex uiVertex = new UIVertex();
|
||||
vh.PopulateUIVertex(ref uiVertex, index);
|
||||
|
||||
// get x position
|
||||
var x = uiVertex.position.x;
|
||||
|
||||
// calculate bend based on pivot and radius
|
||||
uiVertex.position.z = -radius * Mathf.Cos(x / radius);
|
||||
uiVertex.position.x = radius * Mathf.Sin(x / radius);
|
||||
|
||||
vh.SetUIVertex(uiVertex, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f2e459a0f758bc947ace4872e13f1da0
|
||||
guid: 0ec526a95e7733b4396be80d3e1df80e
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
|||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("UI/Effects/Extensions/Gradient")]
|
||||
public class Gradient : BaseVertexEffect
|
||||
public class Gradient : BaseMeshEffect
|
||||
{
|
||||
public GradientMode gradientMode = GradientMode.Global;
|
||||
public GradientDir gradientDir = GradientDir.Vertical;
|
||||
|
@ -20,14 +20,16 @@ namespace UnityEngine.UI.Extensions
|
|||
targetGraphic = GetComponent<Graphic>();
|
||||
}
|
||||
|
||||
public override void ModifyVertices(List<UIVertex> vertexList)
|
||||
public override void ModifyMesh(VertexHelper vh)
|
||||
{
|
||||
if (!IsActive() || vertexList.Count == 0)
|
||||
int count = vh.currentVertCount;
|
||||
if (!IsActive() || count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int count = vertexList.Count;
|
||||
UIVertex uiVertex = vertexList[0];
|
||||
var vertexList = new List<UIVertex>();
|
||||
vh.GetUIVertexStream(vertexList);
|
||||
UIVertex uiVertex = new UIVertex();
|
||||
if (gradientMode == GradientMode.Global)
|
||||
{
|
||||
if (gradientDir == GradientDir.DiagonalLeftToRight || gradientDir == GradientDir.DiagonalRightToLeft)
|
||||
|
@ -44,18 +46,18 @@ namespace UnityEngine.UI.Extensions
|
|||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
uiVertex = vertexList[i];
|
||||
vh.PopulateUIVertex(ref uiVertex, i);
|
||||
if (!overwriteAllColor && uiVertex.color != targetGraphic.color)
|
||||
continue;
|
||||
uiVertex.color *= Color.Lerp(vertex2, vertex1, ((gradientDir == GradientDir.Vertical ? uiVertex.position.y : uiVertex.position.x) - bottomY) / uiElementHeight);
|
||||
vertexList[i] = uiVertex;
|
||||
vh.SetUIVertex(uiVertex, i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
uiVertex = vertexList[i];
|
||||
vh.PopulateUIVertex(ref uiVertex, i);
|
||||
if (!overwriteAllColor && !CompareCarefully(uiVertex.color, targetGraphic.color))
|
||||
continue;
|
||||
switch (gradientDir)
|
||||
|
@ -74,7 +76,7 @@ namespace UnityEngine.UI.Extensions
|
|||
break;
|
||||
|
||||
}
|
||||
vertexList[i] = uiVertex;
|
||||
vh.SetUIVertex(uiVertex, i);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 494907d85b5e56a49884a914adc358a5
|
||||
timeCreated: 1440851346
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -46,11 +46,13 @@ using System.Collections.Generic;
|
|||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("UI/Effects/Extensions/Letter Spacing")]
|
||||
public class LetterSpacing : BaseVertexEffect
|
||||
///Summary
|
||||
/// Note, Vertex Count has changed in 5.2.1+, is now 6 (two tris) instead of 4 (tri strip).
|
||||
public class LetterSpacing : BaseMeshEffect
|
||||
{
|
||||
[SerializeField]
|
||||
private float m_spacing = 0f;
|
||||
|
||||
|
||||
protected LetterSpacing() { }
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
@ -71,12 +73,15 @@ namespace UnityEngine.UI.Extensions
|
|||
if (graphic != null) graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override void ModifyVertices(List<UIVertex> verts)
|
||||
{
|
||||
if (! IsActive()) return;
|
||||
|
||||
Text text = GetComponent<Text>();
|
||||
|
||||
public override void ModifyMesh(VertexHelper vh)
|
||||
{
|
||||
if (! IsActive()) return;
|
||||
|
||||
List<UIVertex> verts = new List<UIVertex>();
|
||||
vh.GetUIVertexStream(verts);
|
||||
|
||||
Text text = GetComponent<Text>();
|
||||
if (text == null)
|
||||
{
|
||||
Debug.LogWarning("LetterSpacing: Missing Text component");
|
||||
|
@ -114,40 +119,50 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
string line = lines[lineIdx];
|
||||
float lineOffset = (line.Length -1) * letterOffset * alignmentFactor;
|
||||
|
||||
|
||||
for (int charIdx = 0; charIdx < line.Length; charIdx++)
|
||||
{
|
||||
int idx1 = glyphIdx * 4 + 0;
|
||||
int idx2 = glyphIdx * 4 + 1;
|
||||
int idx3 = glyphIdx * 4 + 2;
|
||||
int idx4 = glyphIdx * 4 + 3;
|
||||
|
||||
// Check for truncated text (doesn't generate verts for all characters)
|
||||
if (idx4 > verts.Count - 1) return;
|
||||
|
||||
UIVertex vert1 = verts[idx1];
|
||||
UIVertex vert2 = verts[idx2];
|
||||
UIVertex vert3 = verts[idx3];
|
||||
UIVertex vert4 = verts[idx4];
|
||||
|
||||
pos = Vector3.right * (letterOffset * charIdx - lineOffset);
|
||||
|
||||
vert1.position += pos;
|
||||
vert2.position += pos;
|
||||
vert3.position += pos;
|
||||
vert4.position += pos;
|
||||
|
||||
verts[idx1] = vert1;
|
||||
int idx1 = glyphIdx * 6 + 0;
|
||||
int idx2 = glyphIdx * 6 + 1;
|
||||
int idx3 = glyphIdx * 6 + 2;
|
||||
int idx4 = glyphIdx * 6 + 3;
|
||||
int idx5 = glyphIdx * 6 + 4;
|
||||
int idx6 = glyphIdx * 6 + 5;
|
||||
|
||||
// Check for truncated text (doesn't generate verts for all characters)
|
||||
if (idx6 > verts.Count - 1) return;
|
||||
|
||||
UIVertex vert1 = verts[idx1];
|
||||
UIVertex vert2 = verts[idx2];
|
||||
UIVertex vert3 = verts[idx3];
|
||||
UIVertex vert4 = verts[idx4];
|
||||
UIVertex vert5 = verts[idx5];
|
||||
UIVertex vert6 = verts[idx6];
|
||||
|
||||
pos = Vector3.right * (letterOffset * charIdx - lineOffset);
|
||||
|
||||
vert1.position += pos;
|
||||
vert2.position += pos;
|
||||
vert3.position += pos;
|
||||
vert4.position += pos;
|
||||
vert5.position += pos;
|
||||
vert6.position += pos;
|
||||
|
||||
verts[idx1] = vert1;
|
||||
verts[idx2] = vert2;
|
||||
verts[idx3] = vert3;
|
||||
verts[idx4] = vert4;
|
||||
|
||||
glyphIdx++;
|
||||
verts[idx5] = vert5;
|
||||
verts[idx6] = vert6;
|
||||
|
||||
glyphIdx++;
|
||||
}
|
||||
|
||||
// Offset for carriage return character that still generates verts
|
||||
glyphIdx++;
|
||||
}
|
||||
}
|
||||
vh.Clear();
|
||||
vh.AddUIVertexTriangleStream(verts);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
//An outline that looks a bit nicer than the default one. It has less "holes" in the outline by drawing more copies of the effect
|
||||
[AddComponentMenu("UI/Effects/Extensions/Nicer Outline")]
|
||||
public class NicerOutline : BaseVertexEffect
|
||||
public class NicerOutline : BaseMeshEffect
|
||||
{
|
||||
[SerializeField]
|
||||
private Color m_EffectColor = new Color (0f, 0f, 0f, 0.5f);
|
||||
|
@ -86,48 +86,52 @@ namespace UnityEngine.UI.Extensions
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
protected void ApplyShadow (List<UIVertex> verts, Color32 color, int start, int end, float x, float y)
|
||||
{
|
||||
//Debug.Log("verts count: "+verts.Count);
|
||||
int num = verts.Count * 2;
|
||||
if (verts.Capacity < num)
|
||||
{
|
||||
verts.Capacity = num;
|
||||
}
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
UIVertex uIVertex = verts [i];
|
||||
verts.Add (uIVertex);
|
||||
protected void ApplyShadowZeroAlloc(List<UIVertex> verts, Color32 color, int start, int end, float x, float y)
|
||||
{
|
||||
UIVertex vt;
|
||||
|
||||
Vector3 position = uIVertex.position;
|
||||
//Debug.Log("vertex pos: "+position);
|
||||
position.x += x;
|
||||
position.y += y;
|
||||
uIVertex.position = position;
|
||||
Color32 color2 = color;
|
||||
if (this.m_UseGraphicAlpha)
|
||||
{
|
||||
color2.a = (byte)(color2.a * verts [i].color.a / 255);
|
||||
}
|
||||
uIVertex.color = color2;
|
||||
//uIVertex.color = (Color32)Color.blue;
|
||||
verts [i] = uIVertex;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ModifyVertices (List<UIVertex> verts)
|
||||
{
|
||||
if (!this.IsActive ())
|
||||
var neededCpacity = verts.Count * 2;
|
||||
if (verts.Capacity < neededCpacity)
|
||||
verts.Capacity = neededCpacity;
|
||||
|
||||
for (int i = start; i < end; ++i)
|
||||
{
|
||||
vt = verts[i];
|
||||
verts.Add(vt);
|
||||
|
||||
Vector3 v = vt.position;
|
||||
v.x += x;
|
||||
v.y += y;
|
||||
vt.position = v;
|
||||
var newColor = color;
|
||||
if (m_UseGraphicAlpha)
|
||||
newColor.a = (byte)((newColor.a * verts[i].color.a) / 255);
|
||||
vt.color = newColor;
|
||||
verts[i] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
protected void ApplyShadow(List<UIVertex> verts, Color32 color, int start, int end, float x, float y)
|
||||
{
|
||||
var neededCpacity = verts.Count * 2;
|
||||
if (verts.Capacity < neededCpacity)
|
||||
verts.Capacity = neededCpacity;
|
||||
|
||||
ApplyShadowZeroAlloc(verts, color, start, end, x, y);
|
||||
}
|
||||
|
||||
|
||||
public override void ModifyMesh(VertexHelper vh)
|
||||
{
|
||||
if (!this.IsActive ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
List < UIVertex > verts = new List<UIVertex>();
|
||||
vh.GetUIVertexStream(verts);
|
||||
|
||||
Text foundtext = GetComponent<Text>();
|
||||
Text foundtext = GetComponent<Text>();
|
||||
|
||||
float best_fit_adjustment = 1f;
|
||||
|
||||
|
@ -166,12 +170,17 @@ namespace UnityEngine.UI.Extensions
|
|||
start = count;
|
||||
count = verts.Count;
|
||||
this.ApplyShadow (verts, this.effectColor, start, verts.Count, 0, -distanceY);
|
||||
}
|
||||
|
||||
|
||||
vh.Clear();
|
||||
vh.AddUIVertexTriangleStream(verts);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate ()
|
||||
{
|
||||
this.effectDistance = this.m_EffectDistance;
|
||||
base.OnValidate ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
/// Credit NemoKrad (aka Charles Humphrey)
|
||||
/// Sourced from - http://www.randomchaos.co.uk/SoftAlphaUIMask.aspx
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[AddComponentMenu("UI/Effects/Extensions/SoftMaskScript")]
|
||||
public class SoftMaskScript : MonoBehaviour
|
||||
{
|
||||
Material mat;
|
||||
Canvas canvas;
|
||||
|
||||
[Tooltip("The area that is to be used as the container.")]
|
||||
public RectTransform MaskArea;
|
||||
RectTransform myRect;
|
||||
|
||||
[Tooltip("A Rect Transform that can be used to scale and move the mask - Does not apply to Text UI Components being masked")]
|
||||
public RectTransform maskScalingRect;
|
||||
|
||||
[Tooltip("Texture to be used to do the soft alpha")]
|
||||
public Texture AlphaMask;
|
||||
|
||||
[Tooltip("At what point to apply the alpha min range 0-1")]
|
||||
[Range(0, 1)]
|
||||
public float CutOff = 0;
|
||||
|
||||
[Tooltip("Implement a hard blend based on the Cutoff")]
|
||||
public bool HardBlend = false;
|
||||
|
||||
[Tooltip("Flip the masks alpha value")]
|
||||
public bool FlipAlphaMask = false;
|
||||
|
||||
[Tooltip("If Mask Scals Rect is given, and this value is true, the area around the mask will not be clipped")]
|
||||
public bool DontClipMaskScalingRect = false;
|
||||
|
||||
Vector3[] worldCorners;
|
||||
|
||||
Vector2 AlphaUV;
|
||||
|
||||
Vector2 min;
|
||||
Vector2 max = Vector2.one;
|
||||
Vector2 p;
|
||||
Vector2 siz;
|
||||
|
||||
Rect maskRect;
|
||||
Rect contentRect;
|
||||
|
||||
Vector2 centre;
|
||||
|
||||
bool isText = false;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
myRect = GetComponent<RectTransform>();
|
||||
|
||||
if (!MaskArea)
|
||||
{
|
||||
MaskArea = myRect;
|
||||
}
|
||||
|
||||
if (GetComponent<Graphic>() != null)
|
||||
{
|
||||
mat = new Material(Shader.Find("UI Extensions/SoftMaskShader"));
|
||||
GetComponent<Graphic>().material = mat;
|
||||
}
|
||||
|
||||
if (GetComponent<Text>())
|
||||
{
|
||||
isText = true;
|
||||
mat = new Material(Shader.Find("UI Extensions/SoftMaskShaderText"));
|
||||
GetComponent<Text>().material = mat;
|
||||
|
||||
GetCanvas();
|
||||
|
||||
// For some reason, having the mask control on the parent and disabled stops the mouse interacting
|
||||
// with the texture layer that is not visible.. Not needed for the Image.
|
||||
if (transform.parent.GetComponent<Mask>() == null)
|
||||
transform.parent.gameObject.AddComponent<Mask>();
|
||||
|
||||
transform.parent.GetComponent<Mask>().enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
void GetCanvas()
|
||||
{
|
||||
Transform t = transform;
|
||||
|
||||
int lvlLimit = 100;
|
||||
int lvl = 0;
|
||||
|
||||
while (canvas == null && lvl < lvlLimit)
|
||||
{
|
||||
canvas = t.gameObject.GetComponent<Canvas>();
|
||||
if (canvas == null)
|
||||
t = GetParentTranform(t);
|
||||
|
||||
lvl++;
|
||||
}
|
||||
}
|
||||
|
||||
Transform GetParentTranform(Transform t)
|
||||
{
|
||||
return t.parent;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
SetMask();
|
||||
}
|
||||
|
||||
void SetMask()
|
||||
{
|
||||
// Get the two rectangle areas
|
||||
maskRect = MaskArea.rect;
|
||||
contentRect = myRect.rect;
|
||||
|
||||
if (isText) // Need to do our calculations in world for Text
|
||||
{
|
||||
maskScalingRect = null;
|
||||
if (canvas.renderMode == RenderMode.ScreenSpaceOverlay && Application.isPlaying)
|
||||
{
|
||||
p = canvas.transform.InverseTransformPoint(MaskArea.transform.position);
|
||||
siz = new Vector2(maskRect.width, maskRect.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldCorners = new Vector3[4];
|
||||
MaskArea.GetWorldCorners(worldCorners);
|
||||
siz = (worldCorners[2] - worldCorners[0]);
|
||||
p = MaskArea.transform.position;
|
||||
}
|
||||
|
||||
min = p - (new Vector2(siz.x, siz.y) * .5f);
|
||||
max = p + (new Vector2(siz.x, siz.y) * .5f);
|
||||
}
|
||||
else // Need to do our calculations in tex space for Image.
|
||||
{
|
||||
if (maskScalingRect != null)
|
||||
{
|
||||
maskRect = maskScalingRect.rect;
|
||||
}
|
||||
|
||||
// Get the centre offset
|
||||
centre = myRect.transform.InverseTransformPoint(MaskArea.transform.position);
|
||||
|
||||
if (maskScalingRect != null)
|
||||
{
|
||||
centre = myRect.transform.InverseTransformPoint(maskScalingRect.transform.position);
|
||||
}
|
||||
|
||||
// Set the scale for mapping texcoords mask
|
||||
AlphaUV = new Vector2(maskRect.width / contentRect.width, maskRect.height / contentRect.height);
|
||||
|
||||
// set my min and max to the centre offest
|
||||
min = centre;
|
||||
max = min;
|
||||
|
||||
siz = new Vector2(maskRect.width, maskRect.height) * .5f;
|
||||
// Move them out to the min max extreams
|
||||
min -= siz;
|
||||
max += siz;
|
||||
|
||||
// Now move these into texture space. 0 - 1
|
||||
min = new Vector2(min.x / contentRect.width, min.y / contentRect.height) + new Vector2(.5f, .5f);
|
||||
max = new Vector2(max.x / contentRect.width, max.y / contentRect.height) + new Vector2(.5f, .5f);
|
||||
|
||||
}
|
||||
|
||||
mat.SetFloat("_HardBlend", HardBlend ? 1 : 0);
|
||||
|
||||
// Pass the values to the shader
|
||||
mat.SetVector("_Min", min);
|
||||
mat.SetVector("_Max", max);
|
||||
|
||||
mat.SetTexture("_AlphaMask", AlphaMask);
|
||||
mat.SetInt("_FlipAlphaMask", FlipAlphaMask ? 1 : 0);
|
||||
|
||||
mat.SetInt("_NoOuterClip", DontClipMaskScalingRect && maskScalingRect != null ? 1 : 0);
|
||||
|
||||
if (!isText) // No mod needed for Text
|
||||
mat.SetVector("_AlphaUV", AlphaUV);
|
||||
|
||||
mat.SetFloat("_CutOff", CutOff);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b8ee60af491978345bc197ed4e1316bc
|
||||
timeCreated: 1448034177
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,13 +1,14 @@
|
|||
|
||||
using System;
|
||||
/// Credit ChoMPHi
|
||||
/// Sourced from - http://forum.unity3d.com/threads/script-flippable-for-ui-graphics.291711/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[RequireComponent(typeof(RectTransform), typeof(Graphic)), DisallowMultipleComponent]
|
||||
[AddComponentMenu("UI/Effects/Extensions/Flippable")]
|
||||
public class UIFlippable : MonoBehaviour, IVertexModifier
|
||||
public class UIFlippable : MonoBehaviour, IMeshModifier
|
||||
{
|
||||
[SerializeField] private bool m_Horizontal = false;
|
||||
[SerializeField] private bool m_Veritical = false;
|
||||
|
@ -37,24 +38,30 @@ namespace UnityEngine.UI.Extensions
|
|||
this.GetComponent<Graphic>().SetVerticesDirty();
|
||||
}
|
||||
|
||||
public void ModifyVertices(List<UIVertex> verts)
|
||||
public void ModifyMesh(VertexHelper verts)
|
||||
{
|
||||
RectTransform rt = this.transform as RectTransform;
|
||||
|
||||
for (int i = 0; i < verts.Count; ++i)
|
||||
for (int i = 0; i < verts.currentVertCount; ++i)
|
||||
{
|
||||
UIVertex v = verts[i];
|
||||
|
||||
UIVertex uiVertex = new UIVertex();
|
||||
verts.PopulateUIVertex(ref uiVertex,i);
|
||||
|
||||
// Modify positions
|
||||
v.position = new Vector3(
|
||||
(this.m_Horizontal ? (v.position.x + (rt.rect.center.x - v.position.x) * 2) : v.position.x),
|
||||
(this.m_Veritical ? (v.position.y + (rt.rect.center.y - v.position.y) * 2) : v.position.y),
|
||||
v.position.z
|
||||
uiVertex.position = new Vector3(
|
||||
(this.m_Horizontal ? (uiVertex.position.x + (rt.rect.center.x - uiVertex.position.x) * 2) : uiVertex.position.x),
|
||||
(this.m_Veritical ? (uiVertex.position.y + (rt.rect.center.y - uiVertex.position.y) * 2) : uiVertex.position.y),
|
||||
uiVertex.position.z
|
||||
);
|
||||
|
||||
|
||||
// Apply
|
||||
verts[i] = v;
|
||||
verts.SetUIVertex(uiVertex, i);
|
||||
}
|
||||
}
|
||||
|
||||
public void ModifyMesh(Mesh mesh)
|
||||
{
|
||||
//Obsolete member implementation
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/// Credit 00christian00
|
||||
/// Sourced from - http://forum.unity3d.com/threads/any-way-to-show-part-of-an-image-without-using-mask.360085/#post-2332030
|
||||
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("UI/Effects/Extensions/UIImageCrop")]
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
public class UIImageCrop : MonoBehaviour
|
||||
{
|
||||
MaskableGraphic mGraphic;
|
||||
Material mat;
|
||||
int XCropProperty, YCropProperty;
|
||||
public float XCrop = 0f;
|
||||
public float YCrop = 0f;
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
SetMaterial();
|
||||
}
|
||||
|
||||
public void SetMaterial()
|
||||
{
|
||||
mGraphic = this.GetComponent<MaskableGraphic>();
|
||||
XCropProperty = Shader.PropertyToID("_XCrop");
|
||||
YCropProperty = Shader.PropertyToID("_YCrop");
|
||||
if (mGraphic != null)
|
||||
{
|
||||
if (mGraphic.material == null || mGraphic.material.name == "Default UI Material")
|
||||
{
|
||||
//Applying default material with UI Image Crop shader
|
||||
mGraphic.material = new Material(Shader.Find("UI Extensions/UI Image Crop"));
|
||||
}
|
||||
mat = mGraphic.material;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Please attach component to a Graphical UI component");
|
||||
}
|
||||
}
|
||||
public void OnValidate()
|
||||
{
|
||||
SetMaterial();
|
||||
SetXCrop(XCrop);
|
||||
SetYCrop(YCrop);
|
||||
}
|
||||
/// <summary>
|
||||
/// Set the x crop factor, with x being a normalized value 0-1f.
|
||||
/// </summary>
|
||||
/// <param name="xcrop"></param>
|
||||
public void SetXCrop(float xcrop)
|
||||
{
|
||||
XCrop = Mathf.Clamp01(xcrop);
|
||||
mat.SetFloat(XCropProperty, XCrop);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the y crop factor, with y being a normalized value 0-1f.
|
||||
/// </summary>
|
||||
/// <param name="ycrop"></param>
|
||||
public void SetYCrop(float ycrop)
|
||||
{
|
||||
YCrop = Mathf.Clamp01(ycrop);
|
||||
mat.SetFloat(YCropProperty, YCrop);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 022c3983095dce44c9504739a8ed7324
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -5,15 +5,19 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
public class ColorPickerTester : MonoBehaviour
|
||||
{
|
||||
public Renderer renderer;
|
||||
public Renderer pickerRenderer;
|
||||
public HSVPicker picker;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
pickerRenderer = GetComponent<Renderer>();
|
||||
}
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
picker.onValueChanged.AddListener(color =>
|
||||
{
|
||||
renderer.material.color = color;
|
||||
pickerRenderer.material.color = color;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
///Credit judah4
|
||||
///Credit judah4
|
||||
///Sourced from - http://forum.unity3d.com/threads/color-picker.267043/
|
||||
|
||||
using UnityEngine.Events;
|
||||
|
@ -8,4 +8,4 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
public class HexRGB : MonoBehaviour
|
||||
{
|
||||
public Text textColor;
|
||||
// Unity 5.1/2 needs an InputFiled vs grabbing the text component
|
||||
public InputField hexInput;
|
||||
|
||||
public HSVPicker hsvpicker;
|
||||
|
||||
|
@ -15,7 +16,7 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
Color color = hsvpicker.currentColor;
|
||||
string hex = ColorToHex(color);
|
||||
textColor.text = hex;
|
||||
hexInput.text = hex;
|
||||
}
|
||||
|
||||
public static string ColorToHex(Color color)
|
||||
|
@ -28,8 +29,7 @@ namespace UnityEngine.UI.Extensions
|
|||
|
||||
public void ManipulateViaHex2RGB()
|
||||
{
|
||||
string hex = textColor.text;
|
||||
|
||||
string hex = hexInput.text;
|
||||
Vector3 rgb = Hex2RGB(hex);
|
||||
Color color = NormalizeVector4(rgb, 255f, 1f); print(rgb);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
///Credit judah4
|
||||
///Credit judah4
|
||||
///Sourced from - http://forum.unity3d.com/threads/color-picker.267043/
|
||||
|
||||
using UnityEngine.EventSystems;
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a0789c2f62bad6b4c800a3dc502fa18e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
|
@ -1,20 +1,16 @@
|
|||
/// Credit Chris Trueman
|
||||
/// Sourced from - http://forum.unity3d.com/threads/use-reticle-like-mouse-for-worldspace-uis.295271/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.EventSystems.Extensions
|
||||
{
|
||||
[RequireComponent(typeof(EventSystem))]
|
||||
[AddComponentMenu("UI/Extensions/Aimer Input Module")]
|
||||
[AddComponentMenu("Event/Extensions/Aimer Input Module")]
|
||||
public class AimerInputModule : PointerInputModule
|
||||
{
|
||||
/// <summary>
|
||||
/// The Input axis name used to activate the object under the reticle.
|
||||
/// </summary>
|
||||
public string activateAxis = "Interact";
|
||||
public string activateAxis = "Submit";
|
||||
|
||||
/// <summary>
|
||||
/// The aimer offset position. Aimer is center screen use this offset to change that.
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f7d3d69aa5226dc4493464d3b5e4ddc3
|
||||
guid: 08b9f423b73fdfb47b59e7de89863600
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
|
@ -0,0 +1,226 @@
|
|||
/// Credit Simon (darkside) Jackson
|
||||
/// Sourced from - UI SIM source and My Brain
|
||||
|
||||
namespace UnityEngine.EventSystems
|
||||
{
|
||||
[AddComponentMenu("Event/Extensions/GamePad Input Module")]
|
||||
public class GamePadInputModule : BaseInputModule
|
||||
{
|
||||
private float m_PrevActionTime;
|
||||
Vector2 m_LastMoveVector;
|
||||
int m_ConsecutiveMoveCount = 0;
|
||||
|
||||
protected GamePadInputModule()
|
||||
{}
|
||||
|
||||
[SerializeField]
|
||||
private string m_HorizontalAxis = "Horizontal";
|
||||
|
||||
/// <summary>
|
||||
/// Name of the vertical axis for movement (if axis events are used).
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private string m_VerticalAxis = "Vertical";
|
||||
|
||||
/// <summary>
|
||||
/// Name of the submit button.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private string m_SubmitButton = "Submit";
|
||||
|
||||
/// <summary>
|
||||
/// Name of the submit button.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private string m_CancelButton = "Cancel";
|
||||
|
||||
[SerializeField]
|
||||
private float m_InputActionsPerSecond = 10;
|
||||
|
||||
[SerializeField]
|
||||
private float m_RepeatDelay = 0.1f;
|
||||
|
||||
public float inputActionsPerSecond
|
||||
{
|
||||
get { return m_InputActionsPerSecond; }
|
||||
set { m_InputActionsPerSecond = value; }
|
||||
}
|
||||
|
||||
public float repeatDelay
|
||||
{
|
||||
get { return m_RepeatDelay; }
|
||||
set { m_RepeatDelay = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of the horizontal axis for movement (if axis events are used).
|
||||
/// </summary>
|
||||
public string horizontalAxis
|
||||
{
|
||||
get { return m_HorizontalAxis; }
|
||||
set { m_HorizontalAxis = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of the vertical axis for movement (if axis events are used).
|
||||
/// </summary>
|
||||
public string verticalAxis
|
||||
{
|
||||
get { return m_VerticalAxis; }
|
||||
set { m_VerticalAxis = value; }
|
||||
}
|
||||
|
||||
public string submitButton
|
||||
{
|
||||
get { return m_SubmitButton; }
|
||||
set { m_SubmitButton = value; }
|
||||
}
|
||||
|
||||
public string cancelButton
|
||||
{
|
||||
get { return m_CancelButton; }
|
||||
set { m_CancelButton = value; }
|
||||
}
|
||||
|
||||
public override bool ShouldActivateModule()
|
||||
{
|
||||
if (!base.ShouldActivateModule())
|
||||
return false;
|
||||
|
||||
var shouldActivate = true;
|
||||
shouldActivate |= Input.GetButtonDown(m_SubmitButton);
|
||||
shouldActivate |= Input.GetButtonDown(m_CancelButton);
|
||||
shouldActivate |= !Mathf.Approximately(Input.GetAxisRaw(m_HorizontalAxis), 0.0f);
|
||||
shouldActivate |= !Mathf.Approximately(Input.GetAxisRaw(m_VerticalAxis), 0.0f);
|
||||
return shouldActivate;
|
||||
}
|
||||
|
||||
public override void ActivateModule()
|
||||
{
|
||||
StandaloneInputModule StandAloneSystem = GetComponent<StandaloneInputModule>();
|
||||
|
||||
if (StandAloneSystem && StandAloneSystem.enabled)
|
||||
{
|
||||
Debug.LogError("StandAloneInputSystem should not be used with the GamePadInputModule, " +
|
||||
"please remove it from the Event System in this scene or disable it when this module is in use");
|
||||
}
|
||||
|
||||
base.ActivateModule();
|
||||
|
||||
var toSelect = eventSystem.currentSelectedGameObject;
|
||||
if (toSelect == null)
|
||||
toSelect = eventSystem.firstSelectedGameObject;
|
||||
|
||||
eventSystem.SetSelectedGameObject(toSelect, GetBaseEventData());
|
||||
}
|
||||
|
||||
public override void DeactivateModule()
|
||||
{
|
||||
base.DeactivateModule();
|
||||
}
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
bool usedEvent = SendUpdateEventToSelectedObject();
|
||||
|
||||
if (eventSystem.sendNavigationEvents)
|
||||
{
|
||||
if (!usedEvent)
|
||||
usedEvent |= SendMoveEventToSelectedObject();
|
||||
|
||||
if (!usedEvent)
|
||||
SendSubmitEventToSelectedObject();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process submit keys.
|
||||
/// </summary>
|
||||
protected bool SendSubmitEventToSelectedObject()
|
||||
{
|
||||
if (eventSystem.currentSelectedGameObject == null)
|
||||
return false;
|
||||
|
||||
var data = GetBaseEventData();
|
||||
if (Input.GetButtonDown(m_SubmitButton))
|
||||
ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler);
|
||||
|
||||
if (Input.GetButtonDown(m_CancelButton))
|
||||
ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.cancelHandler);
|
||||
return data.used;
|
||||
}
|
||||
|
||||
private Vector2 GetRawMoveVector()
|
||||
{
|
||||
Vector2 move = Vector2.zero;
|
||||
move.x = Input.GetAxisRaw(m_HorizontalAxis);
|
||||
move.y = Input.GetAxisRaw(m_VerticalAxis);
|
||||
|
||||
if (Input.GetButtonDown(m_HorizontalAxis))
|
||||
{
|
||||
if (move.x < 0)
|
||||
move.x = -1f;
|
||||
if (move.x > 0)
|
||||
move.x = 1f;
|
||||
}
|
||||
if (Input.GetButtonDown(m_VerticalAxis))
|
||||
{
|
||||
if (move.y < 0)
|
||||
move.y = -1f;
|
||||
if (move.y > 0)
|
||||
move.y = 1f;
|
||||
}
|
||||
return move;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process events.
|
||||
/// </summary>
|
||||
protected bool SendMoveEventToSelectedObject()
|
||||
{
|
||||
float time = Time.unscaledTime;
|
||||
|
||||
Vector2 movement = GetRawMoveVector();
|
||||
if (Mathf.Approximately(movement.x, 0f) && Mathf.Approximately(movement.y, 0f))
|
||||
{
|
||||
m_ConsecutiveMoveCount = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// If user pressed key again, always allow event
|
||||
bool allow = Input.GetButtonDown(m_HorizontalAxis) || Input.GetButtonDown(m_VerticalAxis);
|
||||
bool similarDir = (Vector2.Dot(movement, m_LastMoveVector) > 0);
|
||||
if (!allow)
|
||||
{
|
||||
// Otherwise, user held down key or axis.
|
||||
// If direction didn't change at least 90 degrees, wait for delay before allowing consequtive event.
|
||||
if (similarDir && m_ConsecutiveMoveCount == 1)
|
||||
allow = (time > m_PrevActionTime + m_RepeatDelay);
|
||||
// If direction changed at least 90 degree, or we already had the delay, repeat at repeat rate.
|
||||
else
|
||||
allow = (time > m_PrevActionTime + 1f / m_InputActionsPerSecond);
|
||||
}
|
||||
if (!allow)
|
||||
return false;
|
||||
|
||||
var axisEventData = GetAxisEventData(movement.x, movement.y, 0.6f);
|
||||
ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisEventData, ExecuteEvents.moveHandler);
|
||||
if (!similarDir)
|
||||
m_ConsecutiveMoveCount = 0;
|
||||
m_ConsecutiveMoveCount++;
|
||||
m_PrevActionTime = time;
|
||||
m_LastMoveVector = movement;
|
||||
return axisEventData.used;
|
||||
}
|
||||
|
||||
protected bool SendUpdateEventToSelectedObject()
|
||||
{
|
||||
if (eventSystem.currentSelectedGameObject == null)
|
||||
return false;
|
||||
|
||||
var data = GetBaseEventData();
|
||||
ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.updateSelectedHandler);
|
||||
return data.used;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 26158f38115d49a4a915f46c7eced4ab
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 759c961dc0e85a348ab9cd1278319ca0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
|
@ -1,7 +1,8 @@
|
|||
/// Credit Simie
|
||||
/// Sourced from - http://forum.unity3d.com/threads/flowlayoutgroup.296709/
|
||||
/// Example http://forum.unity3d.com/threads/flowlayoutgroup.296709/
|
||||
|
||||
/// Update by Martin Sharkbomb - http://forum.unity3d.com/threads/flowlayoutgroup.296709/#post-1977028
|
||||
/// Last item alignment fix by Vicente Russo - https://bitbucket.org/ddreaper/unity-ui-extensions/issues/22/flow-layout-group-align
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -13,80 +14,82 @@ namespace UnityEngine.UI.Extensions
|
|||
[AddComponentMenu("Layout/Extensions/Flow Layout Group")]
|
||||
public class FlowLayoutGroup : LayoutGroup
|
||||
{
|
||||
public float Spacing = 0f;
|
||||
|
||||
public float SpacingX = 0f;
|
||||
public float SpacingY = 0f;
|
||||
public bool ExpandHorizontalSpacing = false;
|
||||
|
||||
public bool ChildForceExpandWidth = false;
|
||||
public bool ChildForceExpandHeight = false;
|
||||
|
||||
|
||||
private float _layoutHeight;
|
||||
|
||||
|
||||
public override void CalculateLayoutInputHorizontal()
|
||||
{
|
||||
|
||||
|
||||
base.CalculateLayoutInputHorizontal();
|
||||
|
||||
|
||||
var minWidth = GetGreatestMinimumChildWidth() + padding.left + padding.right;
|
||||
|
||||
|
||||
SetLayoutInputForAxis(minWidth, -1, -1, 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void SetLayoutHorizontal()
|
||||
{
|
||||
SetLayout(rectTransform.rect.width, 0, false);
|
||||
}
|
||||
|
||||
|
||||
public override void SetLayoutVertical()
|
||||
{
|
||||
SetLayout(rectTransform.rect.width, 1, false);
|
||||
}
|
||||
|
||||
|
||||
public override void CalculateLayoutInputVertical()
|
||||
{
|
||||
_layoutHeight = SetLayout(rectTransform.rect.width, 1, true);
|
||||
}
|
||||
|
||||
|
||||
protected bool IsCenterAlign
|
||||
{
|
||||
get
|
||||
{
|
||||
return childAlignment == TextAnchor.LowerCenter || childAlignment == TextAnchor.MiddleCenter ||
|
||||
childAlignment == TextAnchor.UpperCenter;
|
||||
childAlignment == TextAnchor.UpperCenter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected bool IsRightAlign
|
||||
{
|
||||
get
|
||||
{
|
||||
return childAlignment == TextAnchor.LowerRight || childAlignment == TextAnchor.MiddleRight ||
|
||||
childAlignment == TextAnchor.UpperRight;
|
||||
childAlignment == TextAnchor.UpperRight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected bool IsMiddleAlign
|
||||
{
|
||||
get
|
||||
{
|
||||
return childAlignment == TextAnchor.MiddleLeft || childAlignment == TextAnchor.MiddleRight ||
|
||||
childAlignment == TextAnchor.MiddleCenter;
|
||||
childAlignment == TextAnchor.MiddleCenter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected bool IsLowerAlign
|
||||
{
|
||||
get
|
||||
{
|
||||
return childAlignment == TextAnchor.LowerLeft || childAlignment == TextAnchor.LowerRight ||
|
||||
childAlignment == TextAnchor.LowerCenter;
|
||||
childAlignment == TextAnchor.LowerCenter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Holds the rects that will make up the current row being processed
|
||||
/// </summary>
|
||||
private readonly IList<RectTransform> _rowList = new List<RectTransform>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Main layout method
|
||||
/// </summary>
|
||||
|
@ -96,93 +99,95 @@ namespace UnityEngine.UI.Extensions
|
|||
public float SetLayout(float width, int axis, bool layoutInput)
|
||||
{
|
||||
var groupHeight = rectTransform.rect.height;
|
||||
|
||||
|
||||
// Width that is available after padding is subtracted
|
||||
var workingWidth = rectTransform.rect.width - padding.left - padding.right;
|
||||
|
||||
|
||||
// Accumulates the total height of the rows, including spacing and padding.
|
||||
var yOffset = IsLowerAlign ? (float)padding.bottom : (float)padding.top;
|
||||
|
||||
|
||||
var currentRowWidth = 0f;
|
||||
var currentRowHeight = 0f;
|
||||
|
||||
|
||||
for (var i = 0; i < rectChildren.Count; i++) {
|
||||
|
||||
|
||||
// LowerAlign works from back to front
|
||||
var index = IsLowerAlign ? rectChildren.Count - 1 - i : i;
|
||||
|
||||
|
||||
var child = rectChildren[index];
|
||||
|
||||
|
||||
var childWidth = LayoutUtility.GetPreferredSize(child, 0);
|
||||
var childHeight = LayoutUtility.GetPreferredSize(child, 1);
|
||||
|
||||
// Max child width is layout group with - padding
|
||||
|
||||
// Max child width is layout group width - padding
|
||||
childWidth = Mathf.Min(childWidth, workingWidth);
|
||||
|
||||
|
||||
// If adding this element would exceed the bounds of the row,
|
||||
// go to a new line after processing the current row
|
||||
if (currentRowWidth + childWidth > workingWidth) {
|
||||
|
||||
currentRowWidth -= Spacing;
|
||||
|
||||
|
||||
currentRowWidth -= SpacingX;
|
||||
|
||||
// Process current row elements positioning
|
||||
if (!layoutInput) {
|
||||
|
||||
|
||||
var h = CalculateRowVerticalOffset(groupHeight, yOffset, currentRowHeight);
|
||||
LayoutRow(_rowList, currentRowWidth, currentRowHeight, workingWidth, padding.left, h, axis);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Clear existing row
|
||||
_rowList.Clear();
|
||||
|
||||
|
||||
// Add the current row height to total height accumulator, and reset to 0 for the next row
|
||||
yOffset += currentRowHeight;
|
||||
yOffset += Spacing;
|
||||
|
||||
yOffset += SpacingY;
|
||||
|
||||
currentRowHeight = 0;
|
||||
currentRowWidth = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
currentRowWidth += childWidth;
|
||||
_rowList.Add(child);
|
||||
|
||||
|
||||
// We need the largest element height to determine the starting position of the next line
|
||||
if (childHeight > currentRowHeight) {
|
||||
currentRowHeight = childHeight;
|
||||
}
|
||||
|
||||
currentRowWidth += Spacing;
|
||||
// Don't do this for the last one
|
||||
if (i < rectChildren.Count - 1 )
|
||||
currentRowWidth += SpacingX;
|
||||
}
|
||||
|
||||
|
||||
if (!layoutInput) {
|
||||
var h = CalculateRowVerticalOffset(groupHeight, yOffset, currentRowHeight);
|
||||
|
||||
currentRowWidth -= SpacingX;
|
||||
// Layout the final row
|
||||
LayoutRow(_rowList, currentRowWidth, currentRowHeight, workingWidth, padding.left, h, axis);
|
||||
LayoutRow(_rowList, currentRowWidth, currentRowHeight, workingWidth - (_rowList.Count > 1 ? SpacingX : 0), padding.left, h, axis);
|
||||
}
|
||||
|
||||
|
||||
_rowList.Clear();
|
||||
|
||||
|
||||
// Add the last rows height to the height accumulator
|
||||
yOffset += currentRowHeight;
|
||||
yOffset += IsLowerAlign ? padding.top : padding.bottom;
|
||||
|
||||
|
||||
if (layoutInput) {
|
||||
|
||||
|
||||
if(axis == 1)
|
||||
SetLayoutInputForAxis(yOffset, yOffset, -1, axis);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return yOffset;
|
||||
}
|
||||
|
||||
|
||||
private float CalculateRowVerticalOffset(float groupHeight, float yOffset, float currentRowHeight)
|
||||
{
|
||||
float h;
|
||||
|
||||
|
||||
if (IsLowerAlign) {
|
||||
h = groupHeight - yOffset - currentRowHeight;
|
||||
} else if (IsMiddleAlign) {
|
||||
|
@ -192,36 +197,46 @@ namespace UnityEngine.UI.Extensions
|
|||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
protected void LayoutRow(IList<RectTransform> contents, float rowWidth, float rowHeight, float maxWidth, float xOffset, float yOffset, int axis)
|
||||
{
|
||||
var xPos = xOffset;
|
||||
|
||||
|
||||
if (!ChildForceExpandWidth && IsCenterAlign)
|
||||
xPos += (maxWidth - rowWidth) * 0.5f;
|
||||
else if (!ChildForceExpandWidth && IsRightAlign)
|
||||
xPos += (maxWidth - rowWidth);
|
||||
|
||||
|
||||
var extraWidth = 0f;
|
||||
var extraSpacing = 0f;
|
||||
|
||||
if (ChildForceExpandWidth) {
|
||||
extraWidth = (maxWidth - rowWidth)/_rowList.Count;
|
||||
}
|
||||
|
||||
else if (ExpandHorizontalSpacing) {
|
||||
extraSpacing = (maxWidth - rowWidth)/(_rowList.Count - 1);
|
||||
if (_rowList.Count > 1) {
|
||||
if (IsCenterAlign)
|
||||
xPos -= extraSpacing * 0.5f * (_rowList.Count - 1);
|
||||
else if (IsRightAlign)
|
||||
xPos -= extraSpacing * (_rowList.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (var j = 0; j < _rowList.Count; j++) {
|
||||
|
||||
|
||||
var index = IsLowerAlign ? _rowList.Count - 1 - j : j;
|
||||
|
||||
|
||||
var rowChild = _rowList[index];
|
||||
|
||||
|
||||
var rowChildWidth = LayoutUtility.GetPreferredSize(rowChild, 0) + extraWidth;
|
||||
var rowChildHeight = LayoutUtility.GetPreferredSize(rowChild, 1);
|
||||
|
||||
|
||||
if (ChildForceExpandHeight)
|
||||
rowChildHeight = rowHeight;
|
||||
|
||||
|
||||
rowChildWidth = Mathf.Min(rowChildWidth, maxWidth);
|
||||
|
||||
|
||||
var yPos = yOffset;
|
||||
|
||||
if (IsMiddleAlign)
|
||||
|
@ -229,25 +244,31 @@ namespace UnityEngine.UI.Extensions
|
|||
else if (IsLowerAlign)
|
||||
yPos += (rowHeight - rowChildHeight);
|
||||
|
||||
//
|
||||
if (ExpandHorizontalSpacing && j > 0)
|
||||
xPos += extraSpacing;
|
||||
|
||||
if (axis == 0)
|
||||
SetChildAlongAxis(rowChild, 0, xPos, rowChildWidth);
|
||||
else
|
||||
SetChildAlongAxis(rowChild, 1, yPos, rowChildHeight);
|
||||
|
||||
xPos += rowChildWidth + Spacing;
|
||||
// Don't do horizontal spacing for the last one
|
||||
if (j < _rowList.Count - 1 )
|
||||
xPos += rowChildWidth + SpacingX;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public float GetGreatestMinimumChildWidth()
|
||||
{
|
||||
var max = 0f;
|
||||
|
||||
|
||||
for (var i = 0; i < rectChildren.Count; i++) {
|
||||
var w = LayoutUtility.GetMinWidth(rectChildren[i]);
|
||||
|
||||
|
||||
max = Mathf.Max(w, max);
|
||||
}
|
||||
|
||||
|
||||
return max;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ using UnityEngine.EventSystems;
|
|||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[RequireComponent(typeof(ScrollRect))]
|
||||
[AddComponentMenu("UI/Extensions/Horizontal Scroll Snap")]
|
||||
[AddComponentMenu("Layout/Extensions/Horizontal Scroll Snap")]
|
||||
public class HorizontalScrollSnap : MonoBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler
|
||||
{
|
||||
private Transform _screensContainer;
|
||||
|
@ -211,7 +211,7 @@ namespace UnityEngine.UI.Extensions
|
|||
RectTransform child = _screensContainer.transform.GetChild(i).gameObject.GetComponent<RectTransform>();
|
||||
currentXPosition = _offset + i * _step;
|
||||
child.anchoredPosition = new Vector2(currentXPosition, 0f);
|
||||
child.sizeDelta = new Vector2(gameObject.GetComponent<RectTransform>().sizeDelta.x, gameObject.GetComponent<RectTransform>().sizeDelta.y);
|
||||
child.sizeDelta = new Vector2(gameObject.GetComponent<RectTransform>().rect.width, gameObject.GetComponent<RectTransform>().rect.height);
|
||||
}
|
||||
|
||||
_dimension = currentXPosition + _offset * -1;
|
|
@ -0,0 +1,84 @@
|
|||
|
||||
/// Credit Danny Goodayle
|
||||
/// Sourced from - http://www.justapixel.co.uk/radial-layouts-nice-and-simple-in-unity3ds-ui-system/
|
||||
/// Updated by ddreaper - removed dependency on a custom ScrollRect script. Now implements drag interfaces and standard Scroll Rect.
|
||||
|
||||
/*
|
||||
Radial Layout Group by Just a Pixel (Danny Goodayle) - http://www.justapixel.co.uk
|
||||
Copyright (c) 2015
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("Layout/Extensions/Radial Layout")]
|
||||
public class RadialLayout : LayoutGroup
|
||||
{
|
||||
public float fDistance;
|
||||
[Range(0f, 360f)]
|
||||
public float MinAngle, MaxAngle, StartAngle;
|
||||
protected override void OnEnable() { base.OnEnable(); CalculateRadial(); }
|
||||
public override void SetLayoutHorizontal()
|
||||
{
|
||||
}
|
||||
public override void SetLayoutVertical()
|
||||
{
|
||||
}
|
||||
public override void CalculateLayoutInputVertical()
|
||||
{
|
||||
CalculateRadial();
|
||||
}
|
||||
public override void CalculateLayoutInputHorizontal()
|
||||
{
|
||||
CalculateRadial();
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
CalculateRadial();
|
||||
}
|
||||
#endif
|
||||
void CalculateRadial()
|
||||
{
|
||||
m_Tracker.Clear();
|
||||
if (transform.childCount == 0)
|
||||
return;
|
||||
float fOffsetAngle = ((MaxAngle - MinAngle)) / (transform.childCount - 1);
|
||||
|
||||
float fAngle = StartAngle;
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
RectTransform child = (RectTransform)transform.GetChild(i);
|
||||
if (child != null)
|
||||
{
|
||||
//Adding the elements to the tracker stops the user from modifiying their positions via the editor.
|
||||
m_Tracker.Add(this, child,
|
||||
DrivenTransformProperties.Anchors |
|
||||
DrivenTransformProperties.AnchoredPosition |
|
||||
DrivenTransformProperties.Pivot);
|
||||
Vector3 vPos = new Vector3(Mathf.Cos(fAngle * Mathf.Deg2Rad), Mathf.Sin(fAngle * Mathf.Deg2Rad), 0);
|
||||
child.localPosition = vPos * fDistance;
|
||||
//Force objects to be center aligned, this can be changed however I'd suggest you keep all of the objects with the same anchor points.
|
||||
child.anchorMin = child.anchorMax = child.pivot = new Vector2(0.5f, 0.5f);
|
||||
fAngle += fOffsetAngle;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1ebce7906e5d20a4fb26d8b510b81926
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,556 @@
|
|||
/// Credit BinaryX
|
||||
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/page-2#post-1945602
|
||||
/// Updated by ddreaper - removed dependency on a custom ScrollRect script. Now implements drag interfaces and standard Scroll Rect.
|
||||
/// Update by xesenix - rewrited almost entire code
|
||||
/// - configuration for direction move instead of 2 concurrent class (easiear to change direction in editor)
|
||||
/// - supports list layouted with horizontal or vertical layout need to match direction with type of layout used
|
||||
/// - dynamicly checks if scrolled list size changes and recalculates anchor positions
|
||||
/// and item size based on itemsVisibleAtOnce and size of root container
|
||||
/// if you dont wish to use this auto resize turn of autoLayoutItems
|
||||
/// - fixed current page made it independant from pivot
|
||||
/// - replaced pagination with delegate function
|
||||
using System;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(ScrollRect))]
|
||||
[AddComponentMenu("UI/Extensions/Scroll Snap")]
|
||||
public class ScrollSnap : MonoBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler
|
||||
{
|
||||
// needed becouse of reversed behavior of axis Y compared to X
|
||||
// (positions of children lower in children list in horizontal directions grows when in vertical it gets smaller)
|
||||
public enum ScrollDirection
|
||||
{
|
||||
Horizontal,
|
||||
Vertical
|
||||
}
|
||||
|
||||
public delegate void PageSnapChange(int page);
|
||||
|
||||
public event PageSnapChange onPageChange;
|
||||
|
||||
public ScrollDirection direction = ScrollDirection.Horizontal;
|
||||
|
||||
protected ScrollRect scrollRect;
|
||||
|
||||
protected RectTransform scrollRectTransform;
|
||||
|
||||
protected Transform listContainerTransform;
|
||||
|
||||
protected RectTransform rectTransform;
|
||||
|
||||
int pages;
|
||||
|
||||
protected int startingPage = 0;
|
||||
|
||||
// anchor points to lerp to to see child on certain indexes
|
||||
protected Vector3[] pageAnchorPositions;
|
||||
|
||||
protected Vector3 lerpTarget;
|
||||
|
||||
protected bool lerp;
|
||||
|
||||
// item list related
|
||||
protected float listContainerMinPosition;
|
||||
|
||||
protected float listContainerMaxPosition;
|
||||
|
||||
protected float listContainerSize;
|
||||
|
||||
protected RectTransform listContainerRectTransform;
|
||||
|
||||
protected Vector2 listContainerCachedSize;
|
||||
|
||||
protected float itemSize;
|
||||
|
||||
protected int itemsCount = 0;
|
||||
|
||||
[Tooltip("Button to go to the next page. (optional)")]
|
||||
public Button nextButton;
|
||||
|
||||
[Tooltip("Button to go to the previous page. (optional)")]
|
||||
public Button prevButton;
|
||||
|
||||
[Tooltip("Number of items visible in one page of scroll frame.")]
|
||||
[RangeAttribute(1, 100)]
|
||||
public int itemsVisibleAtOnce = 1;
|
||||
|
||||
[Tooltip("Sets minimum width of list items to 1/itemsVisibleAtOnce.")]
|
||||
public bool autoLayoutItems = true;
|
||||
|
||||
[Tooltip("If you wish to update scrollbar numberOfSteps to number of active children on list.")]
|
||||
public bool linkScrolbarSteps = false;
|
||||
|
||||
[Tooltip("If you wish to update scrollrect sensitivity to size of list element.")]
|
||||
public bool linkScrolrectScrollSensitivity = false;
|
||||
|
||||
public Boolean useFastSwipe = true;
|
||||
|
||||
public int fastSwipeThreshold = 100;
|
||||
|
||||
// drag related
|
||||
protected bool startDrag = true;
|
||||
|
||||
protected Vector3 positionOnDragStart = new Vector3();
|
||||
|
||||
protected int pageOnDragStart;
|
||||
|
||||
protected bool fastSwipeTimer = false;
|
||||
|
||||
protected int fastSwipeCounter = 0;
|
||||
|
||||
protected int fastSwipeTarget = 10;
|
||||
|
||||
// Use this for initialization
|
||||
void Awake()
|
||||
{
|
||||
lerp = false;
|
||||
|
||||
scrollRect = gameObject.GetComponent<ScrollRect>();
|
||||
scrollRectTransform = gameObject.GetComponent<RectTransform>();
|
||||
listContainerTransform = scrollRect.content;
|
||||
listContainerRectTransform = listContainerTransform.GetComponent<RectTransform>();
|
||||
|
||||
rectTransform = listContainerTransform.gameObject.GetComponent<RectTransform>();
|
||||
UpdateListItemsSize();
|
||||
UpdateListItemPositions();
|
||||
|
||||
PageChanged(CurrentPage());
|
||||
|
||||
if (nextButton)
|
||||
{
|
||||
nextButton.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
NextScreen();
|
||||
});
|
||||
}
|
||||
|
||||
if (prevButton)
|
||||
{
|
||||
prevButton.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
PreviousScreen();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
Awake();
|
||||
}
|
||||
|
||||
public void UpdateListItemsSize()
|
||||
{
|
||||
float size = 0;
|
||||
float currentSize = 0;
|
||||
if (direction == ScrollSnap.ScrollDirection.Horizontal)
|
||||
{
|
||||
size = scrollRectTransform.rect.width / itemsVisibleAtOnce;
|
||||
currentSize = listContainerRectTransform.rect.width / itemsCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = scrollRectTransform.rect.height / itemsVisibleAtOnce;
|
||||
currentSize = listContainerRectTransform.rect.height / itemsCount;
|
||||
}
|
||||
|
||||
itemSize = size;
|
||||
|
||||
if (linkScrolrectScrollSensitivity)
|
||||
{
|
||||
scrollRect.scrollSensitivity = itemSize;
|
||||
}
|
||||
|
||||
if (autoLayoutItems && currentSize != size && itemsCount > 0)
|
||||
{
|
||||
if (direction == ScrollSnap.ScrollDirection.Horizontal)
|
||||
{
|
||||
foreach (var tr in listContainerTransform)
|
||||
{
|
||||
GameObject child = ((Transform)tr).gameObject;
|
||||
if (child.activeInHierarchy)
|
||||
{
|
||||
var childLayout = child.GetComponent<LayoutElement>();
|
||||
|
||||
if (childLayout == null)
|
||||
{
|
||||
childLayout = child.AddComponent<LayoutElement>();
|
||||
}
|
||||
|
||||
childLayout.minWidth = itemSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var tr in listContainerTransform)
|
||||
{
|
||||
GameObject child = ((Transform)tr).gameObject;
|
||||
if (child.activeInHierarchy)
|
||||
{
|
||||
var childLayout = child.GetComponent<LayoutElement>();
|
||||
|
||||
if (childLayout == null)
|
||||
{
|
||||
childLayout = child.AddComponent<LayoutElement>();
|
||||
}
|
||||
|
||||
childLayout.minHeight = itemSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateListItemPositions()
|
||||
{
|
||||
if (!listContainerRectTransform.rect.size.Equals(listContainerCachedSize))
|
||||
{
|
||||
// checking how many children of list are active
|
||||
int activeCount = 0;
|
||||
|
||||
foreach (var tr in listContainerTransform)
|
||||
{
|
||||
if (((Transform)tr).gameObject.activeInHierarchy)
|
||||
{
|
||||
activeCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// if anything changed since last check reinitialize anchors list
|
||||
itemsCount = 0;
|
||||
Array.Resize(ref pageAnchorPositions, activeCount);
|
||||
|
||||
if (activeCount > 0)
|
||||
{
|
||||
pages = Mathf.Max(activeCount - itemsVisibleAtOnce + 1, 1);
|
||||
|
||||
if (direction == ScrollDirection.Horizontal)
|
||||
{
|
||||
// looking for list spanning range min/max
|
||||
scrollRect.horizontalNormalizedPosition = 0;
|
||||
listContainerMaxPosition = listContainerTransform.localPosition.x;
|
||||
scrollRect.horizontalNormalizedPosition = 1;
|
||||
listContainerMinPosition = listContainerTransform.localPosition.x;
|
||||
|
||||
listContainerSize = listContainerMaxPosition - listContainerMinPosition;
|
||||
|
||||
for (var i = 0; i < pages; i++)
|
||||
{
|
||||
pageAnchorPositions[i] = new Vector3(
|
||||
listContainerMaxPosition - itemSize * i,
|
||||
listContainerTransform.localPosition.y,
|
||||
listContainerTransform.localPosition.z
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log ("-------------looking for list spanning range----------------");
|
||||
// looking for list spanning range
|
||||
scrollRect.verticalNormalizedPosition = 1;
|
||||
listContainerMinPosition = listContainerTransform.localPosition.y;
|
||||
scrollRect.verticalNormalizedPosition = 0;
|
||||
listContainerMaxPosition = listContainerTransform.localPosition.y;
|
||||
|
||||
listContainerSize = listContainerMaxPosition - listContainerMinPosition;
|
||||
|
||||
for (var i = 0; i < pages; i++)
|
||||
{
|
||||
pageAnchorPositions[i] = new Vector3(
|
||||
listContainerTransform.localPosition.x,
|
||||
listContainerMinPosition + itemSize * i,
|
||||
listContainerTransform.localPosition.z
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateScrollbar(linkScrolbarSteps);
|
||||
startingPage = Mathf.Min(startingPage, pages);
|
||||
ResetPage();
|
||||
}
|
||||
|
||||
if (itemsCount != activeCount)
|
||||
{
|
||||
PageChanged(CurrentPage());
|
||||
}
|
||||
|
||||
itemsCount = activeCount;
|
||||
listContainerCachedSize.Set(listContainerRectTransform.rect.size.x, listContainerRectTransform.rect.size.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void ResetPage()
|
||||
{
|
||||
if (direction == ScrollDirection.Horizontal)
|
||||
{
|
||||
scrollRect.horizontalNormalizedPosition = pages > 1 ? (float)startingPage / (float)(pages - 1) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollRect.verticalNormalizedPosition = pages > 1 ? (float)(pages - startingPage - 1) / (float)(pages - 1) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateScrollbar(bool linkSteps)
|
||||
{
|
||||
if (linkSteps)
|
||||
{
|
||||
if (direction == ScrollDirection.Horizontal)
|
||||
{
|
||||
if (scrollRect.horizontalScrollbar != null)
|
||||
{
|
||||
scrollRect.horizontalScrollbar.numberOfSteps = pages;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (scrollRect.verticalScrollbar != null)
|
||||
{
|
||||
scrollRect.verticalScrollbar.numberOfSteps = pages;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (direction == ScrollDirection.Horizontal)
|
||||
{
|
||||
if (scrollRect.horizontalScrollbar != null)
|
||||
{
|
||||
scrollRect.horizontalScrollbar.numberOfSteps = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (scrollRect.verticalScrollbar != null)
|
||||
{
|
||||
scrollRect.verticalScrollbar.numberOfSteps = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
UpdateListItemsSize();
|
||||
UpdateListItemPositions();
|
||||
|
||||
if (lerp)
|
||||
{
|
||||
UpdateScrollbar(false);
|
||||
|
||||
listContainerTransform.localPosition = Vector3.Lerp(listContainerTransform.localPosition, lerpTarget, 7.5f * Time.deltaTime);
|
||||
|
||||
if (Vector3.Distance(listContainerTransform.localPosition, lerpTarget) < 0.001f)
|
||||
{
|
||||
listContainerTransform.localPosition = lerpTarget;
|
||||
lerp = false;
|
||||
|
||||
UpdateScrollbar(linkScrolbarSteps);
|
||||
}
|
||||
|
||||
//change the info bullets at the bottom of the screen. Just for visual effect
|
||||
if (Vector3.Distance(listContainerTransform.localPosition, lerpTarget) < 10f)
|
||||
{
|
||||
PageChanged(CurrentPage());
|
||||
}
|
||||
}
|
||||
|
||||
if (fastSwipeTimer)
|
||||
{
|
||||
fastSwipeCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
private bool fastSwipe = false; //to determine if a fast swipe was performed
|
||||
|
||||
|
||||
//Function for switching screens with buttons
|
||||
public void NextScreen()
|
||||
{
|
||||
UpdateListItemPositions();
|
||||
|
||||
if (CurrentPage() < pages - 1)
|
||||
{
|
||||
lerp = true;
|
||||
lerpTarget = pageAnchorPositions[CurrentPage() + 1];
|
||||
|
||||
PageChanged(CurrentPage() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
//Function for switching screens with buttons
|
||||
public void PreviousScreen()
|
||||
{
|
||||
UpdateListItemPositions();
|
||||
|
||||
if (CurrentPage() > 0)
|
||||
{
|
||||
lerp = true;
|
||||
lerpTarget = pageAnchorPositions[CurrentPage() - 1];
|
||||
|
||||
PageChanged(CurrentPage() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
//Because the CurrentScreen function is not so reliable, these are the functions used for swipes
|
||||
private void NextScreenCommand()
|
||||
{
|
||||
if (pageOnDragStart < pages - 1)
|
||||
{
|
||||
int targetPage = Mathf.Min(pages - 1, pageOnDragStart + itemsVisibleAtOnce);
|
||||
lerp = true;
|
||||
|
||||
lerpTarget = pageAnchorPositions[targetPage];
|
||||
|
||||
PageChanged(targetPage);
|
||||
}
|
||||
}
|
||||
|
||||
//Because the CurrentScreen function is not so reliable, these are the functions used for swipes
|
||||
private void PrevScreenCommand()
|
||||
{
|
||||
if (pageOnDragStart > 0)
|
||||
{
|
||||
int targetPage = Mathf.Max(0, pageOnDragStart - itemsVisibleAtOnce);
|
||||
lerp = true;
|
||||
|
||||
lerpTarget = pageAnchorPositions[targetPage];
|
||||
|
||||
PageChanged(targetPage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//returns the current screen that the is seeing
|
||||
public int CurrentPage()
|
||||
{
|
||||
float pos;
|
||||
|
||||
if (direction == ScrollDirection.Horizontal)
|
||||
{
|
||||
pos = listContainerMaxPosition - listContainerTransform.localPosition.x;
|
||||
pos = Mathf.Clamp(pos, 0, listContainerSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = listContainerTransform.localPosition.y - listContainerMinPosition;
|
||||
pos = Mathf.Clamp(pos, 0, listContainerSize);
|
||||
}
|
||||
|
||||
float page = pos / itemSize;
|
||||
|
||||
return Mathf.Clamp(Mathf.RoundToInt(page), 0, pages);
|
||||
}
|
||||
|
||||
public void ChangePage(int page)
|
||||
{
|
||||
if (0 <= page && page < pages)
|
||||
{
|
||||
lerp = true;
|
||||
|
||||
lerpTarget = pageAnchorPositions[page];
|
||||
|
||||
PageChanged(page);
|
||||
}
|
||||
}
|
||||
|
||||
//changes the bullets on the bottom of the page - pagination
|
||||
private void PageChanged(int currentPage)
|
||||
{
|
||||
startingPage = currentPage;
|
||||
|
||||
if (nextButton)
|
||||
{
|
||||
nextButton.interactable = currentPage < pages - 1;
|
||||
}
|
||||
|
||||
if (prevButton)
|
||||
{
|
||||
prevButton.interactable = currentPage > 0;
|
||||
}
|
||||
|
||||
if (onPageChange != null)
|
||||
{
|
||||
onPageChange(currentPage);
|
||||
}
|
||||
}
|
||||
|
||||
#region Interfaces
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
UpdateScrollbar(false);
|
||||
|
||||
fastSwipeCounter = 0;
|
||||
fastSwipeTimer = true;
|
||||
|
||||
positionOnDragStart = eventData.position;
|
||||
pageOnDragStart = CurrentPage();
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
startDrag = true;
|
||||
float change = 0;
|
||||
|
||||
if (direction == ScrollDirection.Horizontal)
|
||||
{
|
||||
change = positionOnDragStart.x - eventData.position.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
change = -positionOnDragStart.y + eventData.position.y;
|
||||
}
|
||||
|
||||
if (useFastSwipe)
|
||||
{
|
||||
fastSwipe = false;
|
||||
fastSwipeTimer = false;
|
||||
|
||||
if (fastSwipeCounter <= fastSwipeTarget)
|
||||
{
|
||||
if (Math.Abs(change) > fastSwipeThreshold)
|
||||
{
|
||||
fastSwipe = true;
|
||||
}
|
||||
}
|
||||
if (fastSwipe)
|
||||
{
|
||||
if (change > 0)
|
||||
{
|
||||
NextScreenCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
PrevScreenCommand();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lerp = true;
|
||||
lerpTarget = pageAnchorPositions[CurrentPage()];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lerp = true;
|
||||
lerpTarget = pageAnchorPositions[CurrentPage()];
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
lerp = false;
|
||||
|
||||
if (startDrag)
|
||||
{
|
||||
OnBeginDrag(eventData);
|
||||
startDrag = false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c598b387777d96643991be3f0b6c98c2
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,107 @@
|
|||
/// Credit Ges
|
||||
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/page-3#post-2280109
|
||||
|
||||
using System.Collections;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
[AddComponentMenu("Layout/Extensions/Tile Size Fitter")]
|
||||
public class TileSizeFitter : UIBehaviour, ILayoutSelfController
|
||||
{
|
||||
[SerializeField]
|
||||
private Vector2 m_Border = Vector2.zero;
|
||||
public Vector2 Border { get { return m_Border; } set { if (SetPropertyUtility.SetStruct(ref m_Border, value)) SetDirty(); } }
|
||||
|
||||
[SerializeField]
|
||||
private Vector2 m_TileSize = Vector2.zero;
|
||||
public Vector2 TileSize { get { return m_TileSize; } set { if (SetPropertyUtility.SetStruct(ref m_TileSize, value)) SetDirty(); } }
|
||||
|
||||
[System.NonSerialized]
|
||||
private RectTransform m_Rect;
|
||||
private RectTransform rectTransform { get { if (m_Rect == null) m_Rect = GetComponent<RectTransform>(); return m_Rect; } }
|
||||
|
||||
private DrivenRectTransformTracker m_Tracker;
|
||||
|
||||
#region Unity Lifetime calls
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
m_Tracker.Clear();
|
||||
LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
|
||||
base.OnDisable();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void OnRectTransformDimensionsChange()
|
||||
{
|
||||
UpdateRect();
|
||||
}
|
||||
|
||||
private void UpdateRect()
|
||||
{
|
||||
if (!IsActive())
|
||||
return;
|
||||
|
||||
m_Tracker.Clear();
|
||||
|
||||
m_Tracker.Add(this, rectTransform,
|
||||
DrivenTransformProperties.Anchors |
|
||||
DrivenTransformProperties.AnchoredPosition);
|
||||
rectTransform.anchorMin = Vector2.zero;
|
||||
rectTransform.anchorMax = Vector2.one;
|
||||
rectTransform.anchoredPosition = Vector2.zero;
|
||||
|
||||
m_Tracker.Add(this, rectTransform,
|
||||
DrivenTransformProperties.SizeDeltaX |
|
||||
DrivenTransformProperties.SizeDeltaY);
|
||||
Vector2 sizeDelta = GetParentSize() - Border;
|
||||
if (TileSize.x > 0.001f)
|
||||
sizeDelta.x -= Mathf.Floor(sizeDelta.x / TileSize.x) * TileSize.x;
|
||||
else
|
||||
sizeDelta.x = 0;
|
||||
if (TileSize.y > 0.001f)
|
||||
sizeDelta.y -= Mathf.Floor(sizeDelta.y / TileSize.y) * TileSize.y;
|
||||
else
|
||||
sizeDelta.y = 0;
|
||||
rectTransform.sizeDelta = -sizeDelta;
|
||||
}
|
||||
|
||||
private Vector2 GetParentSize()
|
||||
{
|
||||
RectTransform parent = rectTransform.parent as RectTransform;
|
||||
if (!parent)
|
||||
return Vector2.zero;
|
||||
return parent.rect.size;
|
||||
}
|
||||
|
||||
public virtual void SetLayoutHorizontal() { }
|
||||
public virtual void SetLayoutVertical() { }
|
||||
|
||||
protected void SetDirty()
|
||||
{
|
||||
if (!IsActive())
|
||||
return;
|
||||
|
||||
UpdateRect();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate()
|
||||
{
|
||||
m_TileSize.x = Mathf.Clamp(m_TileSize.x, 0.001f, 1000f);
|
||||
m_TileSize.y = Mathf.Clamp(m_TileSize.y, 0.001f, 1000f);
|
||||
SetDirty();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 614c629b8dffdb548b9bef9189606bb9
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -0,0 +1,188 @@
|
|||
/// Credit Mrs. YakaYocha
|
||||
/// Sourced from - https://www.youtube.com/channel/UCHp8LZ_0-iCvl-5pjHATsgw
|
||||
/// Please donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RJ8D9FRFQF9VS
|
||||
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[RequireComponent(typeof(ScrollRect))]
|
||||
[AddComponentMenu("Layout/Extensions/Vertical Scroller")]
|
||||
public class UIVerticalScroller : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Scrollable area (content of desired ScrollRect)")]
|
||||
public RectTransform _scrollingPanel;
|
||||
[Tooltip("Elements to populate inside the scroller")]
|
||||
public GameObject[] _arrayOfElements;
|
||||
[Tooltip("Center display area (position of zoomed content)")]
|
||||
public RectTransform _center;
|
||||
[Tooltip("Select the item to be in center on start. (optional)")]
|
||||
public int StartingIndex = -1;
|
||||
[Tooltip("Button to go to the next page. (optional)")]
|
||||
public GameObject ScrollUpButton;
|
||||
[Tooltip("Button to go to the previous page. (optional)")]
|
||||
public GameObject ScrollDownButton;
|
||||
[Tooltip("Event fired when a specific item is clicked, exposes index number of item. (optional)")]
|
||||
public UnityEvent<int> ButtonClicked;
|
||||
|
||||
|
||||
private float[] distReposition;
|
||||
private float[] distance;
|
||||
//private int elementsDistance;
|
||||
private int minElementsNum;
|
||||
private int elementLength;
|
||||
private int elementHalfLength;
|
||||
private float deltaY;
|
||||
private string result;
|
||||
|
||||
public UIVerticalScroller() { }
|
||||
|
||||
public UIVerticalScroller(RectTransform scrollingPanel, GameObject[] arrayOfElements, RectTransform center)
|
||||
{
|
||||
_scrollingPanel = scrollingPanel;
|
||||
_arrayOfElements = arrayOfElements;
|
||||
_center = center;
|
||||
}
|
||||
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
var scrollRect = GetComponent<ScrollRect>();
|
||||
if (!_scrollingPanel)
|
||||
{
|
||||
_scrollingPanel = scrollRect.content;
|
||||
}
|
||||
if (!_center)
|
||||
{
|
||||
Debug.LogError("Please define the RectTransform for the Center viewport of the scrollable area");
|
||||
}
|
||||
if (_arrayOfElements == null || _arrayOfElements.Length == 0)
|
||||
{
|
||||
var childCount = scrollRect.content.childCount;
|
||||
if (childCount > 0)
|
||||
{
|
||||
_arrayOfElements = new GameObject[childCount];
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
_arrayOfElements[i] = scrollRect.content.GetChild(i).gameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (_arrayOfElements.Length < 1)
|
||||
{
|
||||
Debug.Log("No child content found, exiting..");
|
||||
return;
|
||||
}
|
||||
|
||||
elementLength = _arrayOfElements.Length;
|
||||
distance = new float[elementLength];
|
||||
distReposition = new float[elementLength];
|
||||
|
||||
//get distance between buttons
|
||||
//elementsDistance = (int)Mathf.Abs(_arrayOfElements[1].GetComponent<RectTransform>().anchoredPosition.y - _arrayOfElements[0].GetComponent<RectTransform>().anchoredPosition.y);
|
||||
deltaY = _arrayOfElements[0].GetComponent<RectTransform>().rect.height * elementLength / 3 * 2;
|
||||
Vector2 startPosition = new Vector2(_scrollingPanel.anchoredPosition.x, -deltaY);
|
||||
_scrollingPanel.anchoredPosition = startPosition;
|
||||
|
||||
for (var i = 0; i < _arrayOfElements.Length; i++)
|
||||
{
|
||||
AddListener(_arrayOfElements[i], i);
|
||||
}
|
||||
|
||||
if (ScrollUpButton)
|
||||
ScrollUpButton.GetComponent<Button>().onClick.AddListener(() => { ScrollUp(); });
|
||||
|
||||
if (ScrollDownButton)
|
||||
ScrollDownButton.GetComponent<Button>().onClick.AddListener(() => { ScrollDown(); });
|
||||
|
||||
if (StartingIndex > -1)
|
||||
{
|
||||
StartingIndex = StartingIndex > _arrayOfElements.Length ? _arrayOfElements.Length - 1 : StartingIndex;
|
||||
SnapToElement(StartingIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddListener(GameObject button, int index)
|
||||
{
|
||||
button.GetComponent<Button>().onClick.AddListener(() => DoSomething(index));
|
||||
}
|
||||
|
||||
private void DoSomething(int index)
|
||||
{
|
||||
if (ButtonClicked != null)
|
||||
{
|
||||
ButtonClicked.Invoke(index);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (_arrayOfElements.Length < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < elementLength; i++)
|
||||
{
|
||||
distReposition[i] = _center.GetComponent<RectTransform>().position.y - _arrayOfElements[i].GetComponent<RectTransform>().position.y;
|
||||
distance[i] = Mathf.Abs(distReposition[i]);
|
||||
|
||||
//Magnifying effect
|
||||
float scale = Mathf.Max(0.7f, 1 / (1 + distance[i] / 200));
|
||||
_arrayOfElements[i].GetComponent<RectTransform>().transform.localScale = new Vector3(scale, scale, 1f);
|
||||
}
|
||||
float minDistance = Mathf.Min(distance);
|
||||
|
||||
for (var i = 0; i < elementLength; i++)
|
||||
{
|
||||
_arrayOfElements[i].GetComponent<CanvasGroup>().interactable = false;
|
||||
if (minDistance == distance[i])
|
||||
{
|
||||
minElementsNum = i;
|
||||
_arrayOfElements[i].GetComponent<CanvasGroup>().interactable = true;
|
||||
result = _arrayOfElements[i].GetComponentInChildren<Text>().text;
|
||||
}
|
||||
}
|
||||
|
||||
ScrollingElements(-_arrayOfElements[minElementsNum].GetComponent<RectTransform>().anchoredPosition.y);
|
||||
}
|
||||
|
||||
private void ScrollingElements(float position)
|
||||
{
|
||||
float newY = Mathf.Lerp(_scrollingPanel.anchoredPosition.y, position, Time.deltaTime * 1f);
|
||||
Vector2 newPosition = new Vector2(_scrollingPanel.anchoredPosition.x, newY);
|
||||
_scrollingPanel.anchoredPosition = newPosition;
|
||||
}
|
||||
|
||||
public string GetResults()
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
public void SnapToElement(int element)
|
||||
{
|
||||
float deltaElementPositionY = _arrayOfElements[0].GetComponent<RectTransform>().rect.height * element;
|
||||
Vector2 newPosition = new Vector2(_scrollingPanel.anchoredPosition.x, -deltaElementPositionY);
|
||||
_scrollingPanel.anchoredPosition = newPosition;
|
||||
|
||||
}
|
||||
|
||||
public void ScrollUp()
|
||||
{
|
||||
float deltaUp = _arrayOfElements[0].GetComponent<RectTransform>().rect.height / 1.2f;
|
||||
Vector2 newPositionUp = new Vector2(_scrollingPanel.anchoredPosition.x, _scrollingPanel.anchoredPosition.y - deltaUp);
|
||||
_scrollingPanel.anchoredPosition = Vector2.Lerp(_scrollingPanel.anchoredPosition, newPositionUp, 1);
|
||||
}
|
||||
|
||||
public void ScrollDown()
|
||||
{
|
||||
float deltaDown = _arrayOfElements[0].GetComponent<RectTransform>().rect.height / 1.2f;
|
||||
Vector2 newPositionDown = new Vector2(_scrollingPanel.anchoredPosition.x, _scrollingPanel.anchoredPosition.y + deltaDown);
|
||||
_scrollingPanel.anchoredPosition = newPositionDown;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b9f902652954d44beb3a916831d27435
|
||||
timeCreated: 1449409849
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c94ebd5b05e589d45b7d99b1dfb64135
|
||||
folderAsset: yes
|
||||
timeCreated: 1450872931
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6a0cecb173b794c3bb33e379defdeeb0
|
||||
folderAsset: yes
|
||||
timeCreated: 1449409914
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,207 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &137556
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22421816}
|
||||
- 222: {fileID: 22220394}
|
||||
- 114: {fileID: 11499114}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!1 &138598
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22453926}
|
||||
- 222: {fileID: 22252292}
|
||||
- 114: {fileID: 11415048}
|
||||
- 114: {fileID: 11471022}
|
||||
m_Layer: 5
|
||||
m_Name: DaysVertical
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &11415048
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 138598}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
--- !u!114 &11471022
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 138598}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: .960784316, g: .960784316, b: .960784316, a: 1}
|
||||
m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
|
||||
m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: .100000001
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 11415048}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
|
||||
Culture=neutral, PublicKeyToken=null
|
||||
--- !u!114 &11499114
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 137556}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: .196078435, g: .196078435, b: .196078435, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 14
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 1
|
||||
m_MinSize: 10
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Button
|
||||
--- !u!222 &22220394
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 137556}
|
||||
--- !u!222 &22252292
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 138598}
|
||||
--- !u!224 &22421816
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 137556}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 22453926}
|
||||
m_RootOrder: 0
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: .5, y: .5}
|
||||
--- !u!224 &22453926
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 138598}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 22421816}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_AnchorMin: {x: 0, y: .5}
|
||||
m_AnchorMax: {x: 1, y: .5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 80}
|
||||
m_Pivot: {x: .5, y: .5}
|
||||
--- !u!1001 &100100000
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 1
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 80
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 0}
|
||||
m_RootGameObject: {fileID: 138598}
|
||||
m_IsPrefabParent: 1
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ec6f9b1230e4a4896b7be2e60d3be758
|
||||
timeCreated: 1448815288
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,207 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &139176
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22488808}
|
||||
- 222: {fileID: 22208232}
|
||||
- 114: {fileID: 11466432}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!1 &194106
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22496698}
|
||||
- 222: {fileID: 22250104}
|
||||
- 114: {fileID: 11448172}
|
||||
- 114: {fileID: 11464628}
|
||||
m_Layer: 5
|
||||
m_Name: MonthsVertical
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &11448172
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 194106}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
--- !u!114 &11464628
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 194106}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: .960784316, g: .960784316, b: .960784316, a: 1}
|
||||
m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
|
||||
m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: .100000001
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 11448172}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
|
||||
Culture=neutral, PublicKeyToken=null
|
||||
--- !u!114 &11466432
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 139176}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: .196078435, g: .196078435, b: .196078435, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 14
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 1
|
||||
m_MinSize: 10
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Button
|
||||
--- !u!222 &22208232
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 139176}
|
||||
--- !u!222 &22250104
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 194106}
|
||||
--- !u!224 &22488808
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 139176}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 22496698}
|
||||
m_RootOrder: 0
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: .5, y: .5}
|
||||
--- !u!224 &22496698
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 194106}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 22488808}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_AnchorMin: {x: 0, y: .5}
|
||||
m_AnchorMax: {x: 1, y: .5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 80}
|
||||
m_Pivot: {x: .5, y: .5}
|
||||
--- !u!1001 &100100000
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 1
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 80
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 0}
|
||||
m_RootGameObject: {fileID: 194106}
|
||||
m_IsPrefabParent: 1
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6d45e8f0aa19044ffb3553ca52febef2
|
||||
timeCreated: 1448814882
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,207 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &118010
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22496654}
|
||||
- 222: {fileID: 22201990}
|
||||
- 114: {fileID: 11434666}
|
||||
- 114: {fileID: 11483478}
|
||||
m_Layer: 5
|
||||
m_Name: YearsVertical
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!1 &154304
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22441182}
|
||||
- 222: {fileID: 22293210}
|
||||
- 114: {fileID: 11490688}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &11434666
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 118010}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
--- !u!114 &11483478
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 118010}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: .960784316, g: .960784316, b: .960784316, a: 1}
|
||||
m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
|
||||
m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: .100000001
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 11434666}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
|
||||
Culture=neutral, PublicKeyToken=null
|
||||
--- !u!114 &11490688
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 154304}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: .196078435, g: .196078435, b: .196078435, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 14
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 1
|
||||
m_MinSize: 10
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Button
|
||||
--- !u!222 &22201990
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 118010}
|
||||
--- !u!222 &22293210
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 154304}
|
||||
--- !u!224 &22441182
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 154304}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 22496654}
|
||||
m_RootOrder: 0
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: .5, y: .5}
|
||||
--- !u!224 &22496654
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 118010}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 22441182}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_AnchorMin: {x: 0, y: .5}
|
||||
m_AnchorMax: {x: 1, y: .5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 80}
|
||||
m_Pivot: {x: .5, y: .5}
|
||||
--- !u!1001 &100100000
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 1
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 80
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 0}
|
||||
m_RootGameObject: {fileID: 118010}
|
||||
m_IsPrefabParent: 1
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 65ce75600991941569988ab4538a21a6
|
||||
timeCreated: 1448814778
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 573635efe02d54e20a59cd3023afa514
|
||||
folderAsset: yes
|
||||
timeCreated: 1449409946
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dc87f62a4e5c94019904b8b6037818b5
|
||||
timeCreated: 1449409834
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f1caec3cabf7c4eaaa5b2ad30cf018a9
|
||||
folderAsset: yes
|
||||
timeCreated: 1449409928
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,231 @@
|
|||
/// <summary>
|
||||
/// Brought you by Mrs. YakaYocha
|
||||
/// https://www.youtube.com/channel/UCHp8LZ_0-iCvl-5pjHATsgw
|
||||
///
|
||||
/// Please donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RJ8D9FRFQF9VS
|
||||
/// </summary>
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
using UnityEngine.UI.Extensions;
|
||||
|
||||
|
||||
|
||||
public class ScrollingCalendar : MonoBehaviour
|
||||
|
||||
{
|
||||
public RectTransform monthsScrollingPanel;
|
||||
public RectTransform yearsScrollingPanel;
|
||||
public RectTransform daysScrollingPanel;
|
||||
|
||||
public GameObject yearsButtonPrefab;
|
||||
public GameObject monthsButtonPrefab;
|
||||
public GameObject daysButtonPrefab;
|
||||
|
||||
private GameObject[] monthsButtons;
|
||||
private GameObject[] yearsButtons;
|
||||
private GameObject[] daysButtons;
|
||||
|
||||
public RectTransform monthCenter;
|
||||
public RectTransform yearsCenter;
|
||||
public RectTransform daysCenter;
|
||||
|
||||
UIVerticalScroller yearsVerticalScroller;
|
||||
UIVerticalScroller monthsVerticalScroller;
|
||||
UIVerticalScroller daysVerticalScroller;
|
||||
|
||||
public InputField inputFieldDays;
|
||||
public InputField inputFieldMonths;
|
||||
public InputField inputFieldYears;
|
||||
|
||||
public Text dateText;
|
||||
|
||||
private int daysSet;
|
||||
private int monthsSet;
|
||||
private int yearsSet;
|
||||
|
||||
private void InitializeYears()
|
||||
{
|
||||
int currentYear = int.Parse(System.DateTime.Now.ToString("yyyy"));
|
||||
|
||||
int[] arrayYears = new int[currentYear+1 - 1900];
|
||||
|
||||
yearsButtons = new GameObject[arrayYears.Length];
|
||||
|
||||
for (int i = 0; i < arrayYears.Length; i++)
|
||||
{
|
||||
arrayYears[i] = 1900 + i;
|
||||
|
||||
GameObject clone = (GameObject)Instantiate(yearsButtonPrefab, new Vector3(0, i*80, 0), Quaternion.Euler(new Vector3(0, 0, 0))) as GameObject;
|
||||
clone.transform.SetParent(yearsScrollingPanel);
|
||||
clone.transform.localScale = new Vector3(1, 1, 1);
|
||||
clone.GetComponentInChildren<Text>().text = "" + arrayYears[i];
|
||||
clone.name = "Year_" + arrayYears[i];
|
||||
clone.AddComponent<CanvasGroup>();
|
||||
yearsButtons[i] = clone;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Initialize Months
|
||||
private void InitializeMonths()
|
||||
{
|
||||
int[] months = new int[12];
|
||||
|
||||
monthsButtons = new GameObject[months.Length];
|
||||
for (int i = 0; i < months.Length; i++)
|
||||
{
|
||||
string month = "";
|
||||
months[i] = i;
|
||||
|
||||
GameObject clone = (GameObject)Instantiate(monthsButtonPrefab, new Vector3(0, i * 80, 0), Quaternion.Euler(new Vector3(0, 0, 0))) as GameObject;
|
||||
clone.transform.SetParent(monthsScrollingPanel);
|
||||
clone.transform.localScale = new Vector3(1, 1, 1);
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
month = "Jan";
|
||||
break;
|
||||
case 1:
|
||||
month = "Feb";
|
||||
break;
|
||||
case 2:
|
||||
month = "Mar";
|
||||
break;
|
||||
case 3:
|
||||
month = "Apr";
|
||||
break;
|
||||
case 4:
|
||||
month = "May";
|
||||
break;
|
||||
case 5:
|
||||
month = "Jun";
|
||||
break;
|
||||
case 6:
|
||||
month = "Jul";
|
||||
break;
|
||||
case 7:
|
||||
month = "Aug";
|
||||
break;
|
||||
case 8:
|
||||
month = "Sep";
|
||||
break;
|
||||
case 9:
|
||||
month = "Oct";
|
||||
break;
|
||||
case 10:
|
||||
month = "Nov";
|
||||
break;
|
||||
case 11:
|
||||
month = "Dec";
|
||||
break;
|
||||
}
|
||||
|
||||
clone.GetComponentInChildren<Text>().text = month;
|
||||
clone.name = "Month_" + months[i];
|
||||
clone.AddComponent<CanvasGroup>();
|
||||
monthsButtons[i] = clone;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeDays()
|
||||
{
|
||||
int[] days = new int[31];
|
||||
daysButtons = new GameObject[days.Length];
|
||||
|
||||
for (var i = 0; i < days.Length; i++)
|
||||
{
|
||||
days[i] = i+1;
|
||||
GameObject clone = (GameObject)Instantiate(daysButtonPrefab, new Vector3(0, i * 80, 0), Quaternion.Euler(new Vector3(0, 0, 0))) as GameObject;
|
||||
clone.transform.SetParent(daysScrollingPanel);
|
||||
clone.transform.localScale = new Vector3(1, 1, 1);
|
||||
clone.GetComponentInChildren<Text>().text = "" + days[i];
|
||||
clone.name = "Day_" + days[i];
|
||||
clone.AddComponent<CanvasGroup>();
|
||||
daysButtons[i] = clone;
|
||||
}
|
||||
}
|
||||
|
||||
// Use this for initialization
|
||||
public void Awake()
|
||||
{
|
||||
InitializeYears();
|
||||
InitializeMonths();
|
||||
InitializeDays();
|
||||
|
||||
//Yes Unity complains about this but it doesn't matter in this case.
|
||||
monthsVerticalScroller = new UIVerticalScroller(monthsScrollingPanel, monthsButtons, monthCenter);
|
||||
yearsVerticalScroller = new UIVerticalScroller (yearsScrollingPanel, yearsButtons, yearsCenter);
|
||||
daysVerticalScroller = new UIVerticalScroller (daysScrollingPanel, daysButtons, daysCenter);
|
||||
|
||||
monthsVerticalScroller.Start();
|
||||
yearsVerticalScroller.Start();
|
||||
daysVerticalScroller.Start();
|
||||
}
|
||||
|
||||
public void SetDate()
|
||||
{
|
||||
daysSet = int.Parse(inputFieldDays.text) - 1;
|
||||
monthsSet = int.Parse(inputFieldMonths.text) - 1;
|
||||
yearsSet = int.Parse(inputFieldYears.text) - 1900;
|
||||
|
||||
daysVerticalScroller.SnapToElement(daysSet);
|
||||
monthsVerticalScroller.SnapToElement(monthsSet);
|
||||
yearsVerticalScroller.SnapToElement(yearsSet);
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
monthsVerticalScroller.Update();
|
||||
yearsVerticalScroller.Update();
|
||||
daysVerticalScroller.Update();
|
||||
|
||||
string dayString = daysVerticalScroller.GetResults();
|
||||
string monthString = monthsVerticalScroller.GetResults();
|
||||
string yearsString = yearsVerticalScroller.GetResults();
|
||||
|
||||
if (dayString.EndsWith("1") && dayString != "11")
|
||||
dayString = dayString + "st";
|
||||
else if (dayString.EndsWith("2") && dayString != "12")
|
||||
dayString = dayString + "nd";
|
||||
else if (dayString.EndsWith("3") && dayString != "13")
|
||||
dayString = dayString + "rd";
|
||||
else
|
||||
dayString = dayString + "th";
|
||||
|
||||
dateText.text = monthString + " " + dayString + " " + yearsString;
|
||||
}
|
||||
|
||||
public void DaysScrollUp()
|
||||
{
|
||||
daysVerticalScroller.ScrollUp();
|
||||
}
|
||||
|
||||
public void DaysScrollDown()
|
||||
{
|
||||
daysVerticalScroller.ScrollDown();
|
||||
}
|
||||
|
||||
public void MonthsScrollUp()
|
||||
{
|
||||
monthsVerticalScroller.ScrollUp();
|
||||
}
|
||||
|
||||
public void MonthsScrollDown()
|
||||
{
|
||||
monthsVerticalScroller.ScrollDown();
|
||||
}
|
||||
|
||||
public void YearsScrollUp()
|
||||
{
|
||||
yearsVerticalScroller.ScrollUp();
|
||||
}
|
||||
|
||||
public void YearsScrollDown()
|
||||
{
|
||||
yearsVerticalScroller.ScrollDown();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e0185937f87604a7497a35019c125107
|
||||
timeCreated: 1449409849
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7ffd04bf6a590424fb623c185d6f6ec5
|
||||
folderAsset: yes
|
||||
timeCreated: 1450208395
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
|
@ -0,0 +1,56 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1e2d444ae9d5a4ff1b47ffec28d5165c
|
||||
timeCreated: 1450208403
|
||||
licenseType: Free
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
allowsAlphaSplitting: 0
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: 8
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,285 @@
|
|||
/// Credit BinaryX
|
||||
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/page-2#post-1945602
|
||||
/// Updated by ddreaper - removed dependency on a custom ScrollRect script. Now implements drag interfaces and standard Scroll Rect.
|
||||
|
||||
using System;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[RequireComponent(typeof(ScrollRect))]
|
||||
[AddComponentMenu("Layout/Extensions/Vertical Scroll Snap")]
|
||||
public class VerticalScrollSnap : MonoBehaviour, IBeginDragHandler, IEndDragHandler, IDragHandler
|
||||
{
|
||||
private Transform _screensContainer;
|
||||
|
||||
private int _screens = 1;
|
||||
private int _startingScreen = 1;
|
||||
|
||||
private bool _fastSwipeTimer = false;
|
||||
private int _fastSwipeCounter = 0;
|
||||
private int _fastSwipeTarget = 30;
|
||||
|
||||
|
||||
private System.Collections.Generic.List<Vector3> _positions;
|
||||
private ScrollRect _scroll_rect;
|
||||
private Vector3 _lerp_target;
|
||||
private bool _lerp;
|
||||
|
||||
private int _containerSize;
|
||||
|
||||
[Tooltip("The gameobject that contains toggles which suggest pagination. (optional)")]
|
||||
public GameObject Pagination;
|
||||
|
||||
[Tooltip("Button to go to the next page. (optional)")]
|
||||
public GameObject NextButton;
|
||||
[Tooltip("Button to go to the previous page. (optional)")]
|
||||
public GameObject PrevButton;
|
||||
|
||||
public Boolean UseFastSwipe = true;
|
||||
public int FastSwipeThreshold = 100;
|
||||
|
||||
private bool _startDrag = true;
|
||||
private Vector3 _startPosition = new Vector3();
|
||||
private int _currentScreen;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
_scroll_rect = gameObject.GetComponent<ScrollRect>();
|
||||
_screensContainer = _scroll_rect.content;
|
||||
DistributePages();
|
||||
|
||||
_screens = _screensContainer.childCount;
|
||||
|
||||
_lerp = false;
|
||||
|
||||
_positions = new System.Collections.Generic.List<Vector3>();
|
||||
|
||||
if (_screens > 0)
|
||||
{
|
||||
for (int i = 0; i < _screens; ++i)
|
||||
{
|
||||
_scroll_rect.verticalNormalizedPosition = (float)i / (float)(_screens - 1);
|
||||
_positions.Add(_screensContainer.localPosition);
|
||||
}
|
||||
}
|
||||
|
||||
_scroll_rect.verticalNormalizedPosition = (float)(_startingScreen - 1) / (float)(_screens - 1);
|
||||
|
||||
_containerSize = (int)_screensContainer.gameObject.GetComponent<RectTransform>().offsetMax.y;
|
||||
|
||||
ChangeBulletsInfo(CurrentScreen());
|
||||
|
||||
if (NextButton)
|
||||
NextButton.GetComponent<Button>().onClick.AddListener(() => { NextScreen(); });
|
||||
|
||||
if (PrevButton)
|
||||
PrevButton.GetComponent<Button>().onClick.AddListener(() => { PreviousScreen(); });
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (_lerp)
|
||||
{
|
||||
_screensContainer.localPosition = Vector3.Lerp(_screensContainer.localPosition, _lerp_target, 7.5f * Time.deltaTime);
|
||||
if (Vector3.Distance(_screensContainer.localPosition, _lerp_target) < 0.005f)
|
||||
{
|
||||
_lerp = false;
|
||||
}
|
||||
|
||||
//change the info bullets at the bottom of the screen. Just for visual effect
|
||||
if (Vector3.Distance(_screensContainer.localPosition, _lerp_target) < 10f)
|
||||
{
|
||||
ChangeBulletsInfo(CurrentScreen());
|
||||
}
|
||||
}
|
||||
|
||||
if (_fastSwipeTimer)
|
||||
{
|
||||
_fastSwipeCounter++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private bool fastSwipe = false; //to determine if a fast swipe was performed
|
||||
|
||||
|
||||
//Function for switching screens with buttons
|
||||
public void NextScreen()
|
||||
{
|
||||
if (CurrentScreen() < _screens - 1)
|
||||
{
|
||||
_lerp = true;
|
||||
_lerp_target = _positions[CurrentScreen() + 1];
|
||||
|
||||
ChangeBulletsInfo(CurrentScreen() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
//Function for switching screens with buttons
|
||||
public void PreviousScreen()
|
||||
{
|
||||
if (CurrentScreen() > 0)
|
||||
{
|
||||
_lerp = true;
|
||||
_lerp_target = _positions[CurrentScreen() - 1];
|
||||
|
||||
ChangeBulletsInfo(CurrentScreen() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
//Because the CurrentScreen function is not so reliable, these are the functions used for swipes
|
||||
private void NextScreenCommand()
|
||||
{
|
||||
if (_currentScreen < _screens - 1)
|
||||
{
|
||||
_lerp = true;
|
||||
_lerp_target = _positions[_currentScreen + 1];
|
||||
|
||||
ChangeBulletsInfo(_currentScreen + 1);
|
||||
}
|
||||
}
|
||||
|
||||
//Because the CurrentScreen function is not so reliable, these are the functions used for swipes
|
||||
private void PrevScreenCommand()
|
||||
{
|
||||
if (_currentScreen > 0)
|
||||
{
|
||||
_lerp = true;
|
||||
_lerp_target = _positions[_currentScreen - 1];
|
||||
|
||||
ChangeBulletsInfo(_currentScreen - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//find the closest registered point to the releasing point
|
||||
private Vector3 FindClosestFrom(Vector3 start, System.Collections.Generic.List<Vector3> positions)
|
||||
{
|
||||
Vector3 closest = Vector3.zero;
|
||||
float distance = Mathf.Infinity;
|
||||
|
||||
foreach (Vector3 position in _positions)
|
||||
{
|
||||
if (Vector3.Distance(start, position) < distance)
|
||||
{
|
||||
distance = Vector3.Distance(start, position);
|
||||
closest = position;
|
||||
}
|
||||
}
|
||||
|
||||
return closest;
|
||||
}
|
||||
|
||||
|
||||
//returns the current screen that the is seeing
|
||||
public int CurrentScreen()
|
||||
{
|
||||
float absPoz = Math.Abs(_screensContainer.gameObject.GetComponent<RectTransform>().offsetMin.y);
|
||||
|
||||
absPoz = Mathf.Clamp(absPoz, 1, _containerSize - 1);
|
||||
|
||||
float calc = (absPoz / _containerSize) * _screens;
|
||||
|
||||
return (int)calc;
|
||||
}
|
||||
|
||||
//changes the bullets on the bottom of the page - pagination
|
||||
private void ChangeBulletsInfo(int currentScreen)
|
||||
{
|
||||
if (Pagination)
|
||||
for (int i = 0; i < Pagination.transform.childCount; i++)
|
||||
{
|
||||
Pagination.transform.GetChild(i).GetComponent<Toggle>().isOn = (currentScreen == i)
|
||||
? true
|
||||
: false;
|
||||
}
|
||||
}
|
||||
|
||||
//used for changing between screen resolutions
|
||||
private void DistributePages()
|
||||
{
|
||||
float _offset = 0;
|
||||
float _step = Screen.height;
|
||||
float _dimension = 0;
|
||||
|
||||
Vector2 panelDimensions = gameObject.GetComponent<RectTransform>().sizeDelta;
|
||||
|
||||
float currentYPosition = 0;
|
||||
|
||||
for (int i = 0; i < _screensContainer.transform.childCount; i++)
|
||||
{
|
||||
RectTransform child = _screensContainer.transform.GetChild(i).gameObject.GetComponent<RectTransform>();
|
||||
currentYPosition = _offset + i * _step;
|
||||
child.sizeDelta = new Vector2(panelDimensions.x, panelDimensions.y);
|
||||
child.anchoredPosition = new Vector2(0f - panelDimensions.x / 2, currentYPosition + panelDimensions.y / 2);
|
||||
}
|
||||
|
||||
_dimension = currentYPosition + _offset * -1;
|
||||
|
||||
_screensContainer.GetComponent<RectTransform>().offsetMax = new Vector2(0f,_dimension);
|
||||
}
|
||||
|
||||
#region Interfaces
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
_startPosition = _screensContainer.localPosition;
|
||||
_fastSwipeCounter = 0;
|
||||
_fastSwipeTimer = true;
|
||||
_currentScreen = CurrentScreen();
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
_startDrag = true;
|
||||
if (_scroll_rect.vertical)
|
||||
{
|
||||
if (UseFastSwipe)
|
||||
{
|
||||
fastSwipe = false;
|
||||
_fastSwipeTimer = false;
|
||||
if (_fastSwipeCounter <= _fastSwipeTarget)
|
||||
{
|
||||
if (Math.Abs(_startPosition.y - _screensContainer.localPosition.y) > FastSwipeThreshold)
|
||||
{
|
||||
fastSwipe = true;
|
||||
}
|
||||
}
|
||||
if (fastSwipe)
|
||||
{
|
||||
if (_startPosition.y - _screensContainer.localPosition.y > 0)
|
||||
{
|
||||
NextScreenCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
PrevScreenCommand();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_lerp = true;
|
||||
_lerp_target = FindClosestFrom(_screensContainer.localPosition, _positions);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_lerp = true;
|
||||
_lerp_target = FindClosestFrom(_screensContainer.localPosition, _positions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
_lerp = false;
|
||||
if (_startDrag)
|
||||
{
|
||||
OnBeginDrag(eventData);
|
||||
_startDrag = false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e9dccd2761b104249a8eb0636b550188
|
||||
timeCreated: 1440928417
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3b6b8774345aa954fb85ec83184b9095
|
||||
folderAsset: yes
|
||||
timeCreated: 1445521682
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,38 @@
|
|||
/// Credit koohddang
|
||||
/// Sourced from - http://forum.unity3d.com/threads/onfillvbo-to-onpopulatemesh-help.353977/#post-2299311
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[AddComponentMenu("UI/Extensions/Primitives/Diamond Graph")]
|
||||
public class DiamondGraph : Graphic
|
||||
{
|
||||
public float a = 1;
|
||||
public float b = 1;
|
||||
public float c = 1;
|
||||
public float d = 1;
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
vh.Clear();
|
||||
float wHalf = rectTransform.rect.width / 2;
|
||||
//float hHalf = rectTransform.rect.height / 2;
|
||||
a = Math.Min(1, Math.Max(0, a));
|
||||
b = Math.Min(1, Math.Max(0, b));
|
||||
c = Math.Min(1, Math.Max(0, c));
|
||||
d = Math.Min(1, Math.Max(0, d));
|
||||
|
||||
Color32 color32 = color;
|
||||
vh.AddVert(new Vector3(-wHalf * a, 0), color32, new Vector2(0f, 0f));
|
||||
vh.AddVert(new Vector3(0, wHalf * b), color32, new Vector2(0f, 1f));
|
||||
vh.AddVert(new Vector3(wHalf * c, 0), color32, new Vector2(1f, 1f));
|
||||
vh.AddVert(new Vector3(0, -wHalf * d), color32, new Vector2(1f, 0f));
|
||||
|
||||
vh.AddTriangle(0, 1, 2);
|
||||
vh.AddTriangle(2, 3, 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 891530df3841c0041ab9982359e02e0f
|
||||
timeCreated: 1442708993
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,126 @@
|
|||
/// Credit zge
|
||||
/// Sourced from - http://forum.unity3d.com/threads/draw-circles-or-primitives-on-the-new-ui-canvas.272488/#post-2293224
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("UI/Extensions/Primitives/UI Circle")]
|
||||
public class UICircle : MaskableGraphic
|
||||
{
|
||||
[SerializeField]
|
||||
Texture m_Texture;
|
||||
[Range(0, 100)]
|
||||
public int fillPercent = 100;
|
||||
public bool fill = true;
|
||||
public float thickness = 5;
|
||||
[Range(0, 360)]
|
||||
public int segments = 360;
|
||||
|
||||
public override Texture mainTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Texture == null ? s_WhiteTexture : m_Texture;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Texture to be used.
|
||||
/// </summary>
|
||||
public Texture texture
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Texture;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Texture == value)
|
||||
return;
|
||||
|
||||
m_Texture = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
this.thickness = (float)Mathf.Clamp(this.thickness, 0, rectTransform.rect.width / 2);
|
||||
}
|
||||
|
||||
protected UIVertex[] SetVbo(Vector2[] vertices, Vector2[] uvs)
|
||||
{
|
||||
UIVertex[] vbo = new UIVertex[4];
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
var vert = UIVertex.simpleVert;
|
||||
vert.color = color;
|
||||
vert.position = vertices[i];
|
||||
vert.uv0 = uvs[i];
|
||||
vbo[i] = vert;
|
||||
}
|
||||
return vbo;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
float outer = -rectTransform.pivot.x * rectTransform.rect.width;
|
||||
float inner = -rectTransform.pivot.x * rectTransform.rect.width + this.thickness;
|
||||
|
||||
vh.Clear();
|
||||
|
||||
Vector2 prevX = Vector2.zero;
|
||||
Vector2 prevY = Vector2.zero;
|
||||
Vector2 uv0 = new Vector2(0, 0);
|
||||
Vector2 uv1 = new Vector2(0, 1);
|
||||
Vector2 uv2 = new Vector2(1, 1);
|
||||
Vector2 uv3 = new Vector2(1, 0);
|
||||
Vector2 pos0;
|
||||
Vector2 pos1;
|
||||
Vector2 pos2;
|
||||
Vector2 pos3;
|
||||
|
||||
float f = (this.fillPercent / 100f);
|
||||
float degrees = 360f / segments;
|
||||
int fa = (int)((segments + 1) * f);
|
||||
|
||||
|
||||
for (int i = 0; i < fa; i++)
|
||||
{
|
||||
float rad = Mathf.Deg2Rad * (i * degrees);
|
||||
float c = Mathf.Cos(rad);
|
||||
float s = Mathf.Sin(rad);
|
||||
|
||||
uv0 = new Vector2(0, 1);
|
||||
uv1 = new Vector2(1, 1);
|
||||
uv2 = new Vector2(1, 0);
|
||||
uv3 = new Vector2(0, 0);
|
||||
|
||||
pos0 = prevX;
|
||||
pos1 = new Vector2(outer * c, outer * s);
|
||||
|
||||
if (fill)
|
||||
{
|
||||
pos2 = Vector2.zero;
|
||||
pos3 = Vector2.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos2 = new Vector2(inner * c, inner * s);
|
||||
pos3 = prevY;
|
||||
}
|
||||
|
||||
prevX = pos1;
|
||||
prevY = pos2;
|
||||
|
||||
vh.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 }));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8185cad1aa202d04ebb9e14ffa533a87
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
|
@ -1,156 +1,159 @@
|
|||
/// <summary>
|
||||
/// Created by Freezy - ElicitIce.nl
|
||||
/// Posted on Unity Forums http://forum.unity3d.com/threads/cut-corners-primative.359494/
|
||||
///
|
||||
/// Free for any use and alteration, source code may not be sold without my permission.
|
||||
/// If you make improvements on this script please share them with the community.
|
||||
///
|
||||
///
|
||||
/// Here is a script that will take a rectangular TransformRect and cut off some corners based on the corner size.
|
||||
/// This is great for when you need a quick and easy non-square panel/image.
|
||||
/// Enjoy!
|
||||
/// It adds an additional square if the relevant side has a corner cut, it then offsets the ends to simulate a cut corner.
|
||||
/// UVs are being set, but might be skewed when a texture is applied.
|
||||
/// You could hide the additional colors by using the following:
|
||||
/// http://rumorgames.com/hide-in-inspector/
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
namespace UnityEngine.UI.Extensions {
|
||||
[ExecuteInEditMode]
|
||||
[AddComponentMenu("UI/Extensions/Primitives/Cut Corners")]
|
||||
public class UICornerCut : MaskableGraphic {
|
||||
|
||||
public Vector2 cornerSize = new Vector2(16, 16);
|
||||
|
||||
[Header("Corners to cut")]
|
||||
public bool cutUL = true;
|
||||
public bool cutUR;
|
||||
public bool cutLL;
|
||||
public bool cutLR;
|
||||
|
||||
[Tooltip("Up-Down colors become Left-Right colors")]
|
||||
public bool makeColumns = false;
|
||||
|
||||
[Header("Color the cut bars differently")]
|
||||
public bool useColorUp;
|
||||
// [HideUnless("useColorUp")]
|
||||
public Color32 colorUp = Color.blue;
|
||||
|
||||
public bool useColorDown;
|
||||
// [HideUnless("useColorDown")]
|
||||
public Color32 colorDown = Color.green;
|
||||
|
||||
protected override void OnPopulateMesh(Mesh m) {
|
||||
var rect = rectTransform.rect;
|
||||
var rectNew = rect;
|
||||
|
||||
Color32 color32 = color;
|
||||
using (var vh = new VertexHelper()) {
|
||||
bool up = cutUL | cutUR;
|
||||
bool down = cutLL | cutLR;
|
||||
bool left = cutLL | cutUL;
|
||||
bool right = cutLR | cutUR;
|
||||
bool any = up | down;
|
||||
|
||||
if (any && cornerSize.sqrMagnitude > 0) {
|
||||
//nibble off the sides
|
||||
|
||||
if (left)
|
||||
rectNew.xMin += cornerSize.x;
|
||||
if (down)
|
||||
rectNew.yMin += cornerSize.y;
|
||||
if (up)
|
||||
rectNew.yMax -= cornerSize.y;
|
||||
if (right)
|
||||
rectNew.xMax -= cornerSize.x;
|
||||
|
||||
//add two squares to the main square
|
||||
Vector2 ul, ur, ll, lr;
|
||||
|
||||
if (makeColumns) {
|
||||
ul = new Vector2(rect.xMin, cutUL ? rectNew.yMax : rect.yMax);
|
||||
ur = new Vector2(rect.xMax, cutUR ? rectNew.yMax : rect.yMax);
|
||||
ll = new Vector2(rect.xMin, cutLL ? rectNew.yMin : rect.yMin);
|
||||
lr = new Vector2(rect.xMax, cutLR ? rectNew.yMin : rect.yMin);
|
||||
|
||||
if (left)
|
||||
AddSquare(
|
||||
ll, ul,
|
||||
new Vector2(rectNew.xMin, rect.yMax),
|
||||
new Vector2(rectNew.xMin, rect.yMin),
|
||||
rect, useColorUp ? colorUp : color32, vh);
|
||||
if (right)
|
||||
AddSquare(
|
||||
ur, lr,
|
||||
new Vector2(rectNew.xMax, rect.yMin),
|
||||
new Vector2(rectNew.xMax, rect.yMax),
|
||||
rect, useColorDown ? colorDown : color32, vh);
|
||||
} else {
|
||||
ul = new Vector2(cutUL ? rectNew.xMin : rect.xMin, rect.yMax);
|
||||
ur = new Vector2(cutUR ? rectNew.xMax : rect.xMax, rect.yMax);
|
||||
ll = new Vector2(cutLL ? rectNew.xMin : rect.xMin, rect.yMin);
|
||||
lr = new Vector2(cutLR ? rectNew.xMax : rect.xMax, rect.yMin);
|
||||
if (down)
|
||||
AddSquare(
|
||||
lr, ll,
|
||||
new Vector2(rect.xMin, rectNew.yMin),
|
||||
new Vector2(rect.xMax, rectNew.yMin),
|
||||
rect, useColorDown ? colorDown : color32, vh);
|
||||
if (up)
|
||||
AddSquare(
|
||||
ul, ur,
|
||||
new Vector2(rect.xMax, rectNew.yMax),
|
||||
new Vector2(rect.xMin, rectNew.yMax),
|
||||
rect, useColorUp ? colorUp : color32, vh);
|
||||
}
|
||||
}
|
||||
|
||||
//center
|
||||
if (makeColumns)
|
||||
AddSquare(new Rect(rectNew.xMin, rect.yMin, rectNew.width, rect.height), rect, color32, vh);
|
||||
else
|
||||
AddSquare(new Rect(rect.xMin, rectNew.yMin, rect.width, rectNew.height), rect, color32, vh);
|
||||
|
||||
vh.FillMesh(m);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddSquare(Rect rect, Rect rectUV, Color32 color32, VertexHelper vh) {
|
||||
int v0 = AddVert(rect.xMin, rect.yMin, rectUV, color32, vh);
|
||||
int v1 = AddVert(rect.xMin, rect.yMax, rectUV, color32, vh);
|
||||
int v2 = AddVert(rect.xMax, rect.yMax, rectUV, color32, vh);
|
||||
int v3 = AddVert(rect.xMax, rect.yMin, rectUV, color32, vh);
|
||||
|
||||
vh.AddTriangle(v0, v1, v2);
|
||||
vh.AddTriangle(v2, v3, v0);
|
||||
}
|
||||
|
||||
private static void AddSquare(Vector2 a, Vector2 b, Vector2 c, Vector2 d, Rect rectUV, Color32 color32, VertexHelper vh) {
|
||||
int v0 = AddVert(a.x, a.y, rectUV, color32, vh);
|
||||
int v1 = AddVert(b.x, b.y, rectUV, color32, vh);
|
||||
int v2 = AddVert(c.x, c.y, rectUV, color32, vh);
|
||||
int v3 = AddVert(d.x, d.y, rectUV, color32, vh);
|
||||
|
||||
vh.AddTriangle(v0, v1, v2);
|
||||
vh.AddTriangle(v2, v3, v0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Auto UV handler within the assigned area
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="area"></param>
|
||||
/// <param name="color32"></param>
|
||||
/// <param name="vh"></param>
|
||||
private static int AddVert(float x, float y, Rect area, Color32 color32, VertexHelper vh) {
|
||||
var uv = new Vector2(
|
||||
Mathf.InverseLerp(area.xMin, area.xMax, x),
|
||||
Mathf.InverseLerp(area.yMin, area.yMax, y)
|
||||
);
|
||||
vh.AddVert(new Vector3(x, y), color32, uv);
|
||||
return vh.currentVertCount - 1;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Created by Freezy - ElicitIce.nl
|
||||
/// Posted on Unity Forums http://forum.unity3d.com/threads/cut-corners-primative.359494/
|
||||
///
|
||||
/// Free for any use and alteration, source code may not be sold without my permission.
|
||||
/// If you make improvements on this script please share them with the community.
|
||||
///
|
||||
///
|
||||
/// Here is a script that will take a rectangular TransformRect and cut off some corners based on the corner size.
|
||||
/// This is great for when you need a quick and easy non-square panel/image.
|
||||
/// Enjoy!
|
||||
/// It adds an additional square if the relevant side has a corner cut, it then offsets the ends to simulate a cut corner.
|
||||
/// UVs are being set, but might be skewed when a texture is applied.
|
||||
/// You could hide the additional colors by using the following:
|
||||
/// http://rumorgames.com/hide-in-inspector/
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
namespace UnityEngine.UI.Extensions {
|
||||
[ExecuteInEditMode]
|
||||
[AddComponentMenu("UI/Extensions/Primitives/Cut Corners")]
|
||||
public class UICornerCut : MaskableGraphic {
|
||||
|
||||
public Vector2 cornerSize = new Vector2(16, 16);
|
||||
|
||||
[Header("Corners to cut")]
|
||||
public bool cutUL = true;
|
||||
public bool cutUR;
|
||||
public bool cutLL;
|
||||
public bool cutLR;
|
||||
|
||||
[Tooltip("Up-Down colors become Left-Right colors")]
|
||||
public bool makeColumns = false;
|
||||
|
||||
[Header("Color the cut bars differently")]
|
||||
public bool useColorUp;
|
||||
// [HideUnless("useColorUp")]
|
||||
public Color32 colorUp = Color.blue;
|
||||
|
||||
public bool useColorDown;
|
||||
// [HideUnless("useColorDown")]
|
||||
public Color32 colorDown = Color.green;
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
var rect = rectTransform.rect;
|
||||
var rectNew = rect;
|
||||
|
||||
Color32 color32 = color;
|
||||
bool up = cutUL | cutUR;
|
||||
bool down = cutLL | cutLR;
|
||||
bool left = cutLL | cutUL;
|
||||
bool right = cutLR | cutUR;
|
||||
bool any = up | down;
|
||||
|
||||
if (any && cornerSize.sqrMagnitude > 0)
|
||||
{
|
||||
|
||||
//nibble off the sides
|
||||
vh.Clear();
|
||||
if (left)
|
||||
rectNew.xMin += cornerSize.x;
|
||||
if (down)
|
||||
rectNew.yMin += cornerSize.y;
|
||||
if (up)
|
||||
rectNew.yMax -= cornerSize.y;
|
||||
if (right)
|
||||
rectNew.xMax -= cornerSize.x;
|
||||
|
||||
//add two squares to the main square
|
||||
Vector2 ul, ur, ll, lr;
|
||||
|
||||
if (makeColumns)
|
||||
{
|
||||
ul = new Vector2(rect.xMin, cutUL ? rectNew.yMax : rect.yMax);
|
||||
ur = new Vector2(rect.xMax, cutUR ? rectNew.yMax : rect.yMax);
|
||||
ll = new Vector2(rect.xMin, cutLL ? rectNew.yMin : rect.yMin);
|
||||
lr = new Vector2(rect.xMax, cutLR ? rectNew.yMin : rect.yMin);
|
||||
|
||||
if (left)
|
||||
AddSquare(
|
||||
ll, ul,
|
||||
new Vector2(rectNew.xMin, rect.yMax),
|
||||
new Vector2(rectNew.xMin, rect.yMin),
|
||||
rect, useColorUp ? colorUp : color32, vh);
|
||||
if (right)
|
||||
AddSquare(
|
||||
ur, lr,
|
||||
new Vector2(rectNew.xMax, rect.yMin),
|
||||
new Vector2(rectNew.xMax, rect.yMax),
|
||||
rect, useColorDown ? colorDown : color32, vh);
|
||||
}
|
||||
else
|
||||
{
|
||||
ul = new Vector2(cutUL ? rectNew.xMin : rect.xMin, rect.yMax);
|
||||
ur = new Vector2(cutUR ? rectNew.xMax : rect.xMax, rect.yMax);
|
||||
ll = new Vector2(cutLL ? rectNew.xMin : rect.xMin, rect.yMin);
|
||||
lr = new Vector2(cutLR ? rectNew.xMax : rect.xMax, rect.yMin);
|
||||
if (down)
|
||||
AddSquare(
|
||||
lr, ll,
|
||||
new Vector2(rect.xMin, rectNew.yMin),
|
||||
new Vector2(rect.xMax, rectNew.yMin),
|
||||
rect, useColorDown ? colorDown : color32, vh);
|
||||
if (up)
|
||||
AddSquare(
|
||||
ul, ur,
|
||||
new Vector2(rect.xMax, rectNew.yMax),
|
||||
new Vector2(rect.xMin, rectNew.yMax),
|
||||
rect, useColorUp ? colorUp : color32, vh);
|
||||
}
|
||||
|
||||
//center
|
||||
if (makeColumns)
|
||||
AddSquare(new Rect(rectNew.xMin, rect.yMin, rectNew.width, rect.height), rect, color32, vh);
|
||||
else
|
||||
AddSquare(new Rect(rect.xMin, rectNew.yMin, rect.width, rectNew.height), rect, color32, vh);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddSquare(Rect rect, Rect rectUV, Color32 color32, VertexHelper vh) {
|
||||
int v0 = AddVert(rect.xMin, rect.yMin, rectUV, color32, vh);
|
||||
int v1 = AddVert(rect.xMin, rect.yMax, rectUV, color32, vh);
|
||||
int v2 = AddVert(rect.xMax, rect.yMax, rectUV, color32, vh);
|
||||
int v3 = AddVert(rect.xMax, rect.yMin, rectUV, color32, vh);
|
||||
|
||||
vh.AddTriangle(v0, v1, v2);
|
||||
vh.AddTriangle(v2, v3, v0);
|
||||
}
|
||||
|
||||
private static void AddSquare(Vector2 a, Vector2 b, Vector2 c, Vector2 d, Rect rectUV, Color32 color32, VertexHelper vh) {
|
||||
int v0 = AddVert(a.x, a.y, rectUV, color32, vh);
|
||||
int v1 = AddVert(b.x, b.y, rectUV, color32, vh);
|
||||
int v2 = AddVert(c.x, c.y, rectUV, color32, vh);
|
||||
int v3 = AddVert(d.x, d.y, rectUV, color32, vh);
|
||||
|
||||
vh.AddTriangle(v0, v1, v2);
|
||||
vh.AddTriangle(v2, v3, v0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Auto UV handler within the assigned area
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <param name="area"></param>
|
||||
/// <param name="color32"></param>
|
||||
/// <param name="vh"></param>
|
||||
private static int AddVert(float x, float y, Rect area, Color32 color32, VertexHelper vh) {
|
||||
var uv = new Vector2(
|
||||
Mathf.InverseLerp(area.xMin, area.xMax, x),
|
||||
Mathf.InverseLerp(area.yMin, area.yMax, y)
|
||||
);
|
||||
vh.AddVert(new Vector3(x, y), color32, uv);
|
||||
return vh.currentVertCount - 1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7a6e620ffa5a4e64b8875761130d0139
|
||||
timeCreated: 1444419848
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,183 @@
|
|||
/// Credit jack.sydorenko
|
||||
/// Sourced from - http://forum.unity3d.com/threads/new-ui-and-line-drawing.253772/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("UI/Extensions/Primitives/UILineRenderer")]
|
||||
public class UILineRenderer : MaskableGraphic
|
||||
{
|
||||
[SerializeField]
|
||||
Texture m_Texture;
|
||||
[SerializeField]
|
||||
Rect m_UVRect = new Rect(0f, 0f, 1f, 1f);
|
||||
|
||||
public float LineThickness = 2;
|
||||
public bool UseMargins;
|
||||
public Vector2 Margin;
|
||||
public Vector2[] Points;
|
||||
public bool relativeSize;
|
||||
|
||||
public override Texture mainTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Texture == null ? s_WhiteTexture : m_Texture;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Texture to be used.
|
||||
/// </summary>
|
||||
public Texture texture
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Texture;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Texture == value)
|
||||
return;
|
||||
|
||||
m_Texture = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UV rectangle used by the texture.
|
||||
/// </summary>
|
||||
public Rect uvRect
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UVRect;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_UVRect == value)
|
||||
return;
|
||||
m_UVRect = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
// requires sets of quads
|
||||
if (Points == null || Points.Length < 2)
|
||||
Points = new[] { new Vector2(0, 0), new Vector2(1, 1) };
|
||||
var capSize = 24;
|
||||
var sizeX = rectTransform.rect.width;
|
||||
var sizeY = rectTransform.rect.height;
|
||||
var offsetX = -rectTransform.pivot.x * rectTransform.rect.width;
|
||||
var offsetY = -rectTransform.pivot.y * rectTransform.rect.height;
|
||||
|
||||
// don't want to scale based on the size of the rect, so this is switchable now
|
||||
if (!relativeSize)
|
||||
{
|
||||
sizeX = 1;
|
||||
sizeY = 1;
|
||||
}
|
||||
// build a new set of points taking into account the cap sizes.
|
||||
// would be cool to support corners too, but that might be a bit tough :)
|
||||
var pointList = new List<Vector2>();
|
||||
pointList.Add(Points[0]);
|
||||
var capPoint = Points[0] + (Points[1] - Points[0]).normalized * capSize;
|
||||
pointList.Add(capPoint);
|
||||
|
||||
// should bail before the last point to add another cap point
|
||||
for (int i = 1; i < Points.Length - 1; i++)
|
||||
{
|
||||
pointList.Add(Points[i]);
|
||||
}
|
||||
capPoint = Points[Points.Length - 1] - (Points[Points.Length - 1] - Points[Points.Length - 2]).normalized * capSize;
|
||||
pointList.Add(capPoint);
|
||||
pointList.Add(Points[Points.Length - 1]);
|
||||
|
||||
var TempPoints = pointList.ToArray();
|
||||
if (UseMargins)
|
||||
{
|
||||
sizeX -= Margin.x;
|
||||
sizeY -= Margin.y;
|
||||
offsetX += Margin.x / 2f;
|
||||
offsetY += Margin.y / 2f;
|
||||
}
|
||||
|
||||
vh.Clear();
|
||||
|
||||
Vector2 prevV1 = Vector2.zero;
|
||||
Vector2 prevV2 = Vector2.zero;
|
||||
|
||||
for (int i = 1; i < TempPoints.Length; i++)
|
||||
{
|
||||
var prev = TempPoints[i - 1];
|
||||
var cur = TempPoints[i];
|
||||
prev = new Vector2(prev.x * sizeX + offsetX, prev.y * sizeY + offsetY);
|
||||
cur = new Vector2(cur.x * sizeX + offsetX, cur.y * sizeY + offsetY);
|
||||
|
||||
float angle = Mathf.Atan2(cur.y - prev.y, cur.x - prev.x) * 180f / Mathf.PI;
|
||||
|
||||
var v1 = prev + new Vector2(0, -LineThickness / 2);
|
||||
var v2 = prev + new Vector2(0, +LineThickness / 2);
|
||||
var v3 = cur + new Vector2(0, +LineThickness / 2);
|
||||
var v4 = cur + new Vector2(0, -LineThickness / 2);
|
||||
|
||||
v1 = RotatePointAroundPivot(v1, prev, new Vector3(0, 0, angle));
|
||||
v2 = RotatePointAroundPivot(v2, prev, new Vector3(0, 0, angle));
|
||||
v3 = RotatePointAroundPivot(v3, cur, new Vector3(0, 0, angle));
|
||||
v4 = RotatePointAroundPivot(v4, cur, new Vector3(0, 0, angle));
|
||||
|
||||
Vector2 uvTopLeft = Vector2.zero;
|
||||
Vector2 uvBottomLeft = new Vector2(0, 1);
|
||||
|
||||
Vector2 uvTopCenter = new Vector2(0.5f, 0);
|
||||
Vector2 uvBottomCenter = new Vector2(0.5f, 1);
|
||||
|
||||
Vector2 uvTopRight = new Vector2(1, 0);
|
||||
Vector2 uvBottomRight = new Vector2(1, 1);
|
||||
|
||||
Vector2[] uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomCenter, uvTopCenter };
|
||||
|
||||
if (i > 1)
|
||||
vh.AddUIVertexQuad(SetVbo(new[] { prevV1, prevV2, v1, v2 }, uvs));
|
||||
|
||||
if (i == 1)
|
||||
uvs = new[] { uvTopLeft, uvBottomLeft, uvBottomCenter, uvTopCenter };
|
||||
else if (i == TempPoints.Length - 1)
|
||||
uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomRight, uvTopRight };
|
||||
|
||||
vh.AddUIVertexQuad(SetVbo(new[] { v1, v2, v3, v4 }, uvs));
|
||||
|
||||
|
||||
prevV1 = v3;
|
||||
prevV2 = v4;
|
||||
}
|
||||
}
|
||||
|
||||
protected UIVertex[] SetVbo(Vector2[] vertices, Vector2[] uvs)
|
||||
{
|
||||
UIVertex[] vbo = new UIVertex[4];
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
var vert = UIVertex.simpleVert;
|
||||
vert.color = color;
|
||||
vert.position = vertices[i];
|
||||
vert.uv0 = uvs[i];
|
||||
vbo[i] = vert;
|
||||
}
|
||||
return vbo;
|
||||
}
|
||||
|
||||
public Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles)
|
||||
{
|
||||
Vector3 dir = point - pivot; // get point direction relative to pivot
|
||||
dir = Quaternion.Euler(angles) * dir; // rotate it
|
||||
point = dir + pivot; // calculate rotated point
|
||||
return point; // return it
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5b33b2e663e78774c9f0c9af55018725
|
||||
timeCreated: 1440845580
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,184 @@
|
|||
/// Credit jonbro5556
|
||||
/// Based on original LineRender script by jack.sydorenko
|
||||
/// Sourced from - http://forum.unity3d.com/threads/new-ui-and-line-drawing.253772/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("UI/Extensions/Primitives/UILineTextureRenderer")]
|
||||
public class UILineTextureRenderer : MaskableGraphic
|
||||
{
|
||||
[SerializeField]
|
||||
Texture m_Texture;
|
||||
[SerializeField]
|
||||
Rect m_UVRect = new Rect(0f, 0f, 1f, 1f);
|
||||
|
||||
public float LineThickness = 2;
|
||||
public bool UseMargins;
|
||||
public Vector2 Margin;
|
||||
public Vector2[] Points;
|
||||
public bool relativeSize;
|
||||
|
||||
public override Texture mainTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Texture == null ? s_WhiteTexture : m_Texture;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Texture to be used.
|
||||
/// </summary>
|
||||
public Texture texture
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Texture;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Texture == value)
|
||||
return;
|
||||
|
||||
m_Texture = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UV rectangle used by the texture.
|
||||
/// </summary>
|
||||
public Rect uvRect
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UVRect;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_UVRect == value)
|
||||
return;
|
||||
m_UVRect = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
// requires sets of quads
|
||||
if (Points == null || Points.Length < 2)
|
||||
Points = new[] { new Vector2(0, 0), new Vector2(1, 1) };
|
||||
var capSize = 24;
|
||||
var sizeX = rectTransform.rect.width;
|
||||
var sizeY = rectTransform.rect.height;
|
||||
var offsetX = -rectTransform.pivot.x * rectTransform.rect.width;
|
||||
var offsetY = -rectTransform.pivot.y * rectTransform.rect.height;
|
||||
|
||||
// don't want to scale based on the size of the rect, so this is switchable now
|
||||
if (!relativeSize)
|
||||
{
|
||||
sizeX = 1;
|
||||
sizeY = 1;
|
||||
}
|
||||
// build a new set of points taking into account the cap sizes.
|
||||
// would be cool to support corners too, but that might be a bit tough :)
|
||||
var pointList = new List<Vector2>();
|
||||
pointList.Add(Points[0]);
|
||||
var capPoint = Points[0] + (Points[1] - Points[0]).normalized * capSize;
|
||||
pointList.Add(capPoint);
|
||||
|
||||
// should bail before the last point to add another cap point
|
||||
for (int i = 1; i < Points.Length - 1; i++)
|
||||
{
|
||||
pointList.Add(Points[i]);
|
||||
}
|
||||
capPoint = Points[Points.Length - 1] - (Points[Points.Length - 1] - Points[Points.Length - 2]).normalized * capSize;
|
||||
pointList.Add(capPoint);
|
||||
pointList.Add(Points[Points.Length - 1]);
|
||||
|
||||
var TempPoints = pointList.ToArray();
|
||||
if (UseMargins)
|
||||
{
|
||||
sizeX -= Margin.x;
|
||||
sizeY -= Margin.y;
|
||||
offsetX += Margin.x / 2f;
|
||||
offsetY += Margin.y / 2f;
|
||||
}
|
||||
|
||||
vh.Clear();
|
||||
|
||||
Vector2 prevV1 = Vector2.zero;
|
||||
Vector2 prevV2 = Vector2.zero;
|
||||
|
||||
for (int i = 1; i < TempPoints.Length; i++)
|
||||
{
|
||||
var prev = TempPoints[i - 1];
|
||||
var cur = TempPoints[i];
|
||||
prev = new Vector2(prev.x * sizeX + offsetX, prev.y * sizeY + offsetY);
|
||||
cur = new Vector2(cur.x * sizeX + offsetX, cur.y * sizeY + offsetY);
|
||||
|
||||
float angle = Mathf.Atan2(cur.y - prev.y, cur.x - prev.x) * 180f / Mathf.PI;
|
||||
|
||||
var v1 = prev + new Vector2(0, -LineThickness / 2);
|
||||
var v2 = prev + new Vector2(0, +LineThickness / 2);
|
||||
var v3 = cur + new Vector2(0, +LineThickness / 2);
|
||||
var v4 = cur + new Vector2(0, -LineThickness / 2);
|
||||
|
||||
v1 = RotatePointAroundPivot(v1, prev, new Vector3(0, 0, angle));
|
||||
v2 = RotatePointAroundPivot(v2, prev, new Vector3(0, 0, angle));
|
||||
v3 = RotatePointAroundPivot(v3, cur, new Vector3(0, 0, angle));
|
||||
v4 = RotatePointAroundPivot(v4, cur, new Vector3(0, 0, angle));
|
||||
|
||||
Vector2 uvTopLeft = Vector2.zero;
|
||||
Vector2 uvBottomLeft = new Vector2(0, 1);
|
||||
|
||||
Vector2 uvTopCenter = new Vector2(0.5f, 0);
|
||||
Vector2 uvBottomCenter = new Vector2(0.5f, 1);
|
||||
|
||||
Vector2 uvTopRight = new Vector2(1, 0);
|
||||
Vector2 uvBottomRight = new Vector2(1, 1);
|
||||
|
||||
Vector2[] uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomCenter, uvTopCenter };
|
||||
|
||||
if (i > 1)
|
||||
vh.AddUIVertexQuad(SetVbo(new[] { prevV1, prevV2, v1, v2 }, uvs));
|
||||
|
||||
if (i == 1)
|
||||
uvs = new[] { uvTopLeft, uvBottomLeft, uvBottomCenter, uvTopCenter };
|
||||
else if (i == TempPoints.Length - 1)
|
||||
uvs = new[] { uvTopCenter, uvBottomCenter, uvBottomRight, uvTopRight };
|
||||
|
||||
vh.AddUIVertexQuad(SetVbo(new[] { v1, v2, v3, v4 }, uvs));
|
||||
|
||||
|
||||
prevV1 = v3;
|
||||
prevV2 = v4;
|
||||
}
|
||||
}
|
||||
|
||||
protected UIVertex[] SetVbo(Vector2[] vertices, Vector2[] uvs)
|
||||
{
|
||||
UIVertex[] vbo = new UIVertex[4];
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
var vert = UIVertex.simpleVert;
|
||||
vert.color = color;
|
||||
vert.position = vertices[i];
|
||||
vert.uv0 = uvs[i];
|
||||
vbo[i] = vert;
|
||||
}
|
||||
return vbo;
|
||||
}
|
||||
|
||||
public Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles)
|
||||
{
|
||||
Vector3 dir = point - pivot; // get point direction relative to pivot
|
||||
dir = Quaternion.Euler(angles) * dir; // rotate it
|
||||
point = dir + pivot; // calculate rotated point
|
||||
return point; // return it
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b801876ddb189f94f905cd1646564fbf
|
||||
timeCreated: 1440845581
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,138 @@
|
|||
/// Credit CiaccoDavide
|
||||
/// Sourced from - http://ciaccodavi.de/unity/UIPolygon
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[AddComponentMenu("UI/Extensions/Primitives/UI Polygon")]
|
||||
public class UIPolygon : MaskableGraphic
|
||||
{
|
||||
[SerializeField]
|
||||
Texture m_Texture;
|
||||
public bool fill = true;
|
||||
public float thickness = 5;
|
||||
[Range(3, 360)]
|
||||
public int sides = 3;
|
||||
[Range(0, 360)]
|
||||
public float rotation = 0;
|
||||
[Range(0, 1)]
|
||||
public float[] VerticesDistances = new float[3];
|
||||
private float size = 0;
|
||||
|
||||
public override Texture mainTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Texture == null ? s_WhiteTexture : m_Texture;
|
||||
}
|
||||
}
|
||||
public Texture texture
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Texture;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Texture == value) return;
|
||||
m_Texture = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
public void DrawPolygon(int _sides)
|
||||
{
|
||||
sides = _sides;
|
||||
VerticesDistances = new float[_sides + 1];
|
||||
for (int i = 0; i < _sides; i++) VerticesDistances[i] = 1; ;
|
||||
rotation = 0;
|
||||
}
|
||||
public void DrawPolygon(int _sides, float[] _VerticesDistances)
|
||||
{
|
||||
sides = _sides;
|
||||
VerticesDistances = _VerticesDistances;
|
||||
rotation = 0;
|
||||
}
|
||||
public void DrawPolygon(int _sides, float[] _VerticesDistances, float _rotation)
|
||||
{
|
||||
sides = _sides;
|
||||
VerticesDistances = _VerticesDistances;
|
||||
rotation = _rotation;
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
size = rectTransform.rect.width;
|
||||
if (rectTransform.rect.width > rectTransform.rect.height)
|
||||
size = rectTransform.rect.height;
|
||||
else
|
||||
size = rectTransform.rect.width;
|
||||
thickness = (float)Mathf.Clamp(thickness, 0, size / 2);
|
||||
}
|
||||
protected UIVertex[] SetVbo(Vector2[] vertices, Vector2[] uvs)
|
||||
{
|
||||
UIVertex[] vbo = new UIVertex[4];
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
var vert = UIVertex.simpleVert;
|
||||
vert.color = color;
|
||||
vert.position = vertices[i];
|
||||
vert.uv0 = uvs[i];
|
||||
vbo[i] = vert;
|
||||
}
|
||||
return vbo;
|
||||
}
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
vh.Clear();
|
||||
|
||||
Vector2 prevX = Vector2.zero;
|
||||
Vector2 prevY = Vector2.zero;
|
||||
Vector2 uv0 = new Vector2(0, 0);
|
||||
Vector2 uv1 = new Vector2(0, 1);
|
||||
Vector2 uv2 = new Vector2(1, 1);
|
||||
Vector2 uv3 = new Vector2(1, 0);
|
||||
Vector2 pos0;
|
||||
Vector2 pos1;
|
||||
Vector2 pos2;
|
||||
Vector2 pos3;
|
||||
float degrees = 360f / sides;
|
||||
int vertices = sides + 1;
|
||||
if (VerticesDistances.Length != vertices)
|
||||
{
|
||||
VerticesDistances = new float[vertices];
|
||||
for (int i = 0; i < vertices - 1; i++) VerticesDistances[i] = 1;
|
||||
}
|
||||
// last vertex is also the first!
|
||||
VerticesDistances[vertices - 1] = VerticesDistances[0];
|
||||
for (int i = 0; i < vertices; i++)
|
||||
{
|
||||
float outer = -rectTransform.pivot.x * size * VerticesDistances[i];
|
||||
float inner = -rectTransform.pivot.x * size * VerticesDistances[i] + thickness;
|
||||
float rad = Mathf.Deg2Rad * (i * degrees + rotation);
|
||||
float c = Mathf.Cos(rad);
|
||||
float s = Mathf.Sin(rad);
|
||||
uv0 = new Vector2(0, 1);
|
||||
uv1 = new Vector2(1, 1);
|
||||
uv2 = new Vector2(1, 0);
|
||||
uv3 = new Vector2(0, 0);
|
||||
pos0 = prevX;
|
||||
pos1 = new Vector2(outer * c, outer * s);
|
||||
if (fill)
|
||||
{
|
||||
pos2 = Vector2.zero;
|
||||
pos3 = Vector2.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos2 = new Vector2(inner * c, inner * s);
|
||||
pos3 = prevY;
|
||||
}
|
||||
prevX = pos1;
|
||||
prevY = pos2;
|
||||
vh.AddUIVertexQuad(SetVbo(new[] { pos0, pos1, pos2, pos3 }, new[] { uv0, uv1, uv2, uv3 }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fcd1b8078a416f844b695454a4358409
|
||||
timeCreated: 1450200166
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 281614f4c0e3b7a4d9056bd377134172
|
||||
folderAsset: yes
|
||||
timeCreated: 1446117980
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,99 @@
|
|||
/// Credit Ziboo
|
||||
/// Sourced from - http://forum.unity3d.com/threads/free-reorderable-list.364600/
|
||||
|
||||
using System;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace UnityEngine.UI.Extensions
|
||||
{
|
||||
[RequireComponent(typeof(RectTransform)), DisallowMultipleComponent]
|
||||
[AddComponentMenu("UI/Extensions/Re-orderable list")]
|
||||
public class ReorderableList : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Child container with re-orderable items in a layout group")]
|
||||
public LayoutGroup ContentLayout;
|
||||
[Tooltip("Parent area to draw the dragged element on top of containers. Defaults to the root Canvas")]
|
||||
public RectTransform DraggableArea;
|
||||
|
||||
[Tooltip("Can items be dragged from the container?")]
|
||||
public bool IsDraggable = true;
|
||||
[Tooltip("Should the draggable components be removed or cloned?")]
|
||||
public bool CloneDraggedObject = false;
|
||||
|
||||
[Tooltip("Can new draggable items be dropped in to the container?")]
|
||||
public bool IsDropable = true;
|
||||
|
||||
|
||||
[Header("UI Re-orderable Events")]
|
||||
public ReorderableListHandler OnElementDropped = new ReorderableListHandler();
|
||||
public ReorderableListHandler OnElementGrabbed = new ReorderableListHandler();
|
||||
public ReorderableListHandler OnElementRemoved = new ReorderableListHandler();
|
||||
|
||||
private RectTransform _content;
|
||||
private ReorderableListContent _listContent;
|
||||
|
||||
public RectTransform Content
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_content == null)
|
||||
{
|
||||
_content = ContentLayout.GetComponent<RectTransform>();
|
||||
}
|
||||
return _content;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
||||
if (ContentLayout == null)
|
||||
{
|
||||
Debug.LogError("You need to have a child LayoutGroup content set for the list: " + name, gameObject);
|
||||
return;
|
||||
}
|
||||
if (DraggableArea == null)
|
||||
{
|
||||
DraggableArea = transform.root.GetComponentInChildren<Canvas>().GetComponent<RectTransform>();
|
||||
}
|
||||
if (IsDropable && !GetComponent<Graphic>())
|
||||
{
|
||||
Debug.LogError("You need to have a Graphic control (such as an Image) for the list [" + name + "] to be droppable", gameObject);
|
||||
return;
|
||||
}
|
||||
_listContent = ContentLayout.gameObject.AddComponent<ReorderableListContent>();
|
||||
_listContent.Init(this);
|
||||
}
|
||||
|
||||
#region Nested type: ReorderableListEventStruct
|
||||
|
||||
[Serializable]
|
||||
public struct ReorderableListEventStruct
|
||||
{
|
||||
public GameObject DroppedObject;
|
||||
public int FromIndex;
|
||||
public ReorderableList FromList;
|
||||
public bool IsAClone;
|
||||
public GameObject SourceObject;
|
||||
public int ToIndex;
|
||||
public ReorderableList ToList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: ReorderableListHandler
|
||||
|
||||
[Serializable]
|
||||
public class ReorderableListHandler : UnityEvent<ReorderableListEventStruct>
|
||||
{
|
||||
}
|
||||
|
||||
public void TestReOrderableListTarget(ReorderableListEventStruct item)
|
||||
{
|
||||
Debug.Log("Event Received");
|
||||
Debug.Log("Hello World, is my item a clone? [" + item.IsAClone + "]");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6b333d67eb08d464d823874f6a1666c2
|
||||
timeCreated: 1446072130
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue