diff --git a/README.md b/README.md index 261e120..1fee5f2 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,13 @@ You can either download / fork the project to access the scripts, or you can dow ### [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") @@ -36,6 +36,7 @@ To get started with the project, here's a little guide: 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. @@ -43,6 +44,7 @@ Few minor fixes and a couple of additional scripts. Predominately created the n * 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: ## @@ -114,6 +116,7 @@ Effect | Description | Component Command | Notes | Donate | Credits **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## diff --git a/Scripts/Effects/CylinderText.cs b/Scripts/Effects/CylinderText.cs new file mode 100644 index 0000000..27b2277 --- /dev/null +++ b/Scripts/Effects/CylinderText.cs @@ -0,0 +1,62 @@ +/// 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 = 360; + private RectTransform rectTrans; + + +#if UNITY_EDITOR + protected override void OnValidate() + { + base.OnValidate(); + if (rectTrans == null) + rectTrans = GetComponent(); + } +#endif + protected override void Awake() + { + base.Awake(); + rectTrans = GetComponent(); + OnRectTransformDimensionsChange(); + } + protected override void OnEnable() + { + base.OnEnable(); + rectTrans = GetComponent(); + OnRectTransformDimensionsChange(); + } + public override void ModifyMesh(Mesh mesh) + { + if (!IsActive()) + return; + Vector3[] verts = mesh.vertices; + + int count = verts.Length; + if (!IsActive() || count == 0) + { + return; + } + for (int index = 0; index < count; index++) + { + var uiVertex = verts[index]; + + // get x position + var x = uiVertex.x; + + // calculate bend based on pivot and radius + uiVertex.z = -radius * Mathf.Cos(x / radius); + uiVertex.x = radius * Mathf.Sin(x / radius); + + verts[index] = uiVertex; + } + mesh.vertices = verts; + } + } +} diff --git a/Scripts/Effects/CylinderText.cs.meta b/Scripts/Effects/CylinderText.cs.meta new file mode 100644 index 0000000..96a5281 --- /dev/null +++ b/Scripts/Effects/CylinderText.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0ec526a95e7733b4396be80d3e1df80e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Scripts/Effects/SoftMaskScript.cs b/Scripts/Effects/SoftMaskScript.cs index 57b9ed5..4eae262 100644 --- a/Scripts/Effects/SoftMaskScript.cs +++ b/Scripts/Effects/SoftMaskScript.cs @@ -14,6 +14,9 @@ namespace UnityEngine.UI.Extensions 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; @@ -24,6 +27,9 @@ namespace UnityEngine.UI.Extensions [Tooltip("Implement a hard blend based on the Cutoff")] public bool HardBlend = false; + [Tooltip("Flip the masks alpha value")] + public bool FlipAlphaMask = false; + Vector3[] worldCorners; Vector2 AlphaUV; @@ -108,6 +114,7 @@ namespace UnityEngine.UI.Extensions 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); @@ -126,9 +133,19 @@ namespace UnityEngine.UI.Extensions } 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); @@ -154,6 +171,7 @@ namespace UnityEngine.UI.Extensions mat.SetVector("_Max", max); mat.SetTexture("_AlphaMask", AlphaMask); + mat.SetInt("_FlipAlphaMask", FlipAlphaMask ? 1 : 0); if (!isText) // No mod needed for Text mat.SetVector("_AlphaUV", AlphaUV); diff --git a/Shaders/SoftMaskShader.shader b/Shaders/SoftMaskShader.shader index ad68915..bf44fb0 100644 --- a/Shaders/SoftMaskShader.shader +++ b/Shaders/SoftMaskShader.shader @@ -20,6 +20,7 @@ _CutOff("CutOff",Float) = 0 [MaterialToggle] _HardBlend("HardBlend",Float) = 0 + _FlipAlphaMask("Flip Alpha Mask",int) = 0 } SubShader @@ -90,6 +91,8 @@ float _Value; int _LeftToRight; + int _FlipAlphaMask = 0; + v2f vert(appdata_t IN) { v2f OUT; @@ -122,7 +125,6 @@ { half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color; - // Do we want to clip the image to the Mask Rectangle? if (IN.texcoord.x < _Min.x || IN.texcoord.x > _Max.x || IN.texcoord.y < _Min.y || IN.texcoord.y > _Max.y) // Yes we do color.a = 0; @@ -138,6 +140,9 @@ a = 1; } + if (_FlipAlphaMask == 1) + a = 1 - a; + color.a = a; } diff --git a/Shaders/SoftMaskShaderText.shader b/Shaders/SoftMaskShaderText.shader index 1522ef0..9f7eb13 100644 --- a/Shaders/SoftMaskShaderText.shader +++ b/Shaders/SoftMaskShaderText.shader @@ -19,6 +19,7 @@ _CutOff("CutOff",Float) = 0 [MaterialToggle] _HardBlend("HardBlend",Float) = 0 + _FlipAlphaMask("Flip Alpha Mask",int) = 0 } SubShader @@ -92,6 +93,8 @@ bool _HardBlend = false; + int _FlipAlphaMask = 0; + v2f vert(appdata_t IN) { v2f OUT; @@ -139,6 +142,9 @@ a = 1; } + if (_FlipAlphaMask == 1) + a = 1 - a; + color.a = a * color.a; } diff --git a/UnityUIExtensions-4.x.unitypackage b/UnityUIExtensions-4.x.unitypackage index ad1b509..3e4433c 100644 Binary files a/UnityUIExtensions-4.x.unitypackage and b/UnityUIExtensions-4.x.unitypackage differ diff --git a/UnityUIExtensions-5.1.unitypackage b/UnityUIExtensions-5.1.unitypackage index 7ffd9d4..8fb3a09 100644 Binary files a/UnityUIExtensions-5.1.unitypackage and b/UnityUIExtensions-5.1.unitypackage differ diff --git a/UnityUIExtensions-5.2.unitypackage b/UnityUIExtensions-5.2.unitypackage index 4d5e379..d4bfa9e 100644 Binary files a/UnityUIExtensions-5.2.unitypackage and b/UnityUIExtensions-5.2.unitypackage differ diff --git a/package.json b/package.json index 218f7e4..4ad9336 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Unity UI Extensions", - "version": "1.0.6", + "version": "1.0.6.1", "description": "An extension project for the Unity3D UI system, all crafted and contributed by the awesome Unity community", "author": "Simon darkside Jackson <@SimonDarksideJ>", "contributors": [{