diff --git a/.gitignore b/.gitignore index 9ff3127..e913e03 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,6 @@ sysinfo.txt # Packages -*.unitypackage build.app unity.log @@ -44,3 +43,4 @@ _WebGL/ _Standalone/ Assets/TextMesh Pro/ Assets/TextMesh Pro.meta +PackageTest diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/.gitignore b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/.gitignore new file mode 100644 index 0000000..a7dbd39 --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/.gitignore @@ -0,0 +1,45 @@ +[Ll]ibrary/ +[Tt]emp/ +[Oo]bj/ +[Bb]uild/ +/[Bb]uilds/ +/Assets/AssetStoreTools* + +# Autogenerated VS/MD solution and project files +ExportedObj/ +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd + + +# Unity3D generated meta files +*.pidb.meta + +# Unity3D Generated File On Crash Reports +sysinfo.txt + +# Mac +*.DS_Store + +# Builds +*.apk + + +# Packages +build.app +unity.log + +.vs/ +_Android/ +_iOS/ +_WebGL/ +_Standalone/ +Assets/TextMesh Pro/ +Assets/TextMesh Pro.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md deleted file mode 120000 index cd67e22..0000000 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -./../../../../CHANGELOG.md \ No newline at end of file diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md new file mode 100644 index 0000000..7645933 --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md @@ -0,0 +1,63 @@ +# Changelog + +## [0.4.0](https://github.com/mob-sakai/SoftMaskForUGUI/tree/0.4.0) (2019-01-13) + +[Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.3.0...0.4.0) + +**Implemented enhancements:** + +- Integrate with UnityPackageManager [\#22](https://github.com/mob-sakai/SoftMaskForUGUI/issues/22) + +**Fixed bugs:** + +- Flipped soft mask texture [\#25](https://github.com/mob-sakai/SoftMaskForUGUI/issues/25) + +## [v0.3.0](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.3.0) (2019-01-07) + +[Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.2.0...v0.3.0) + +**Implemented enhancements:** + +- Remove TMPro resources in repo [\#21](https://github.com/mob-sakai/SoftMaskForUGUI/issues/21) + +**Fixed bugs:** + +- An error occur when SoftMask is destroyed on editor [\#23](https://github.com/mob-sakai/SoftMaskForUGUI/issues/23) + +## [v0.2.0](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.2.0) (2018-12-21) + +[Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.1.0...v0.2.0) + +**Implemented enhancements:** + +- Set default material on disable [\#17](https://github.com/mob-sakai/SoftMaskForUGUI/issues/17) +- Component icon [\#15](https://github.com/mob-sakai/SoftMaskForUGUI/issues/15) +- Support TextMeshPro [\#14](https://github.com/mob-sakai/SoftMaskForUGUI/issues/14) +- Preview soft mask buffer in inspector [\#13](https://github.com/mob-sakai/SoftMaskForUGUI/issues/13) +- Add a SoftMaskable component to the child UI elements of SoftMask From the inspector [\#12](https://github.com/mob-sakai/SoftMaskForUGUI/issues/12) +- Render the soft mask buffer only when needed to improve performance [\#11](https://github.com/mob-sakai/SoftMaskForUGUI/issues/11) + +**Fixed bugs:** + +- Doesn't work with overlay canvas on 2018.3 [\#20](https://github.com/mob-sakai/SoftMaskForUGUI/issues/20) + +## [v0.1.0](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.1.0) (2018-11-20) + +[Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/0d87935fa566cd1cb5e54a6f8826bb72fffb29b8...v0.1.0) + +**Implemented enhancements:** + +- Convert existing Mask to SoftMask from context menu [\#10](https://github.com/mob-sakai/SoftMaskForUGUI/issues/10) +- Desample soft mask buffer to improve performance [\#9](https://github.com/mob-sakai/SoftMaskForUGUI/issues/9) +- Custom shaders supporting [\#8](https://github.com/mob-sakai/SoftMaskForUGUI/issues/8) +- Filter raycast only for the visible part [\#7](https://github.com/mob-sakai/SoftMaskForUGUI/issues/7) +- Inverse soft mask [\#6](https://github.com/mob-sakai/SoftMaskForUGUI/issues/6) +- Nested soft masks [\#5](https://github.com/mob-sakai/SoftMaskForUGUI/issues/5) +- Support multiple-sprites and SpriteAtlas [\#4](https://github.com/mob-sakai/SoftMaskForUGUI/issues/4) +- Adjust the visible part [\#3](https://github.com/mob-sakai/SoftMaskForUGUI/issues/3) +- Compatible with Mask [\#2](https://github.com/mob-sakai/SoftMaskForUGUI/issues/2) +- Screen space soft masking [\#1](https://github.com/mob-sakai/SoftMaskForUGUI/issues/1) + + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/LICENSE.txt b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/LICENSE.md similarity index 100% rename from LICENSE.txt rename to Assets/Coffee/UIExtensions/SoftMaskForUGUI/LICENSE.md diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/LICENSE.txt.meta b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/LICENSE.md.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/LICENSE.txt.meta rename to Assets/Coffee/UIExtensions/SoftMaskForUGUI/LICENSE.md.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/LICENSE.txt b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/LICENSE.txt deleted file mode 120000 index fff8277..0000000 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/LICENSE.txt +++ /dev/null @@ -1 +0,0 @@ -./../../../../LICENSE.txt \ No newline at end of file diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md deleted file mode 120000 index 7d6adfb..0000000 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md +++ /dev/null @@ -1 +0,0 @@ -./../../../../README.md \ No newline at end of file diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md new file mode 100644 index 0000000..60f16ee --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md @@ -0,0 +1,336 @@ +SoftMaskForUGUI +=== + +Soft masking for uGUI elements in Unity. + +![](https://user-images.githubusercontent.com/12690315/50282438-18408d80-0496-11e9-8f86-81e804edadd4.png) + +[![](https://img.shields.io/github/release/mob-sakai/SoftMaskForUGUI.svg?label=latest%20version)](https://github.com/mob-sakai/SoftMaskForUGUI/releases) +[![](https://img.shields.io/github/release-date/mob-sakai/SoftMaskForUGUI.svg)](https://github.com/mob-sakai/SoftMaskForUGUI/releases) +![](https://img.shields.io/badge/unity-2017%2B-green.svg) +[![](https://img.shields.io/github/license/mob-sakai/SoftMaskForUGUI.svg)](https://github.com/mob-sakai/SoftMaskForUGUI/blob/master/LICENSE.txt) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-orange.svg)](http://makeapullrequest.com) +[![](https://img.shields.io/twitter/follow/mob_sakai.svg?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=mob_sakai) + +<< [Description](#Description) | [WebGL Demo](#demo) | [Download](https://github.com/mob-sakai/SoftMaskForUGUI/releases) | [Usage](#usage) | [Development Note](#development-note) >> + +### What's new? [See changelog ![](https://img.shields.io/github/release-date/mob-sakai/SoftMaskForUGUI.svg?label=last%20updated)](https://github.com/mob-sakai/SoftMaskForUGUI/blob/develop/CHANGELOG.md) +### Do you want to receive notifications for new releases? [Watch this repo ![](https://img.shields.io/github/watchers/mob-sakai/SoftMaskForUGUI.svg?style=social&label=Watch)](https://github.com/mob-sakai/SoftMaskForUGUI/subscription) +### Support me on Patreon! [![become_a_patron](https://user-images.githubusercontent.com/12690315/50731629-3b18b480-11ad-11e9-8fad-4b13f27969c1.png)](https://www.patreon.com/join/2343451?) + + + +



+## Description + +SoftMask is a smooth masking component for uGUI elements in Unity. +By using SoftMask instead of default Mask, rounded edges of UI elements can be expressed beautifully. + +![](https://user-images.githubusercontent.com/12690315/50282806-4b375100-0497-11e9-891c-35309d332c7b.png) + +#### Features + +* SoftMask is compatible with Mask. +* You can adjust the visible part. +![](https://user-images.githubusercontent.com/12690315/48661087-01ca9f00-eab0-11e8-8878-772a1ed1fb7b.gif) +* Text, Image, RawImage can be used as a masking. +* Support multiple-sprites and SpriteAtlas. +* Support up to 4 nested soft masks. +![](https://user-images.githubusercontent.com/12690315/48708326-a0d4cf80-ec45-11e8-83b8-f55d29138db7.png) +* Support scroll view. +![](https://user-images.githubusercontent.com/12690315/48708527-2b1d3380-ec46-11e8-9adf-9d33498f0353.png) +* Support inversed soft mask. +![](https://user-images.githubusercontent.com/12690315/48708328-a0d4cf80-ec45-11e8-9945-e877faabc968.png) +* Support overlay, camera space and world space. +![](https://user-images.githubusercontent.com/12690315/48708329-a0d4cf80-ec45-11e8-8328-16b697f981ec.png) +* Raycast is filtered only for the visible part. +![](https://user-images.githubusercontent.com/12690315/48708330-a16d6600-ec45-11e8-94bf-afecd1bd9a39.png) +* Contain soft maskable UI shader. +* Support soft masks in your custom shaders by adding just 3 lines. For details, please see [Development Note](#support-soft-masks-in-your-custom-shaders). +* Adjust soft mask buffer size to improve performance. +* Convert existing Mask to SoftMask from context menu. +![](https://user-images.githubusercontent.com/12690315/48659018-902e2900-ea8e-11e8-9b6e-224365cdde7f.png) +* Render the soft mask buffer only when needed to improve performance. +* Add a SoftMaskable component to the child UI elements of SoftMask from the inspector. +![](https://user-images.githubusercontent.com/12690315/50284153-76bc3a80-049b-11e9-8c55-719af897960a.png) +* Preview soft mask buffer in inspector. +![](https://user-images.githubusercontent.com/12690315/50284151-7459e080-049b-11e9-9cd3-24fb476766dc.png) +* Support TextMeshPro. +![](https://user-images.githubusercontent.com/12690315/50284145-71f78680-049b-11e9-8be1-ac0ccbdf0144.png) + +#### Known issues + +* SceneView does not display SoftMask properly. It is displayed like Mask. ([By design](#why-is-not-it-displayed-properly-in-sceneview)) + +#### Components + +|Component|Description|Screenshot| +|-|-|-| +|SoftMask|Use instead of Mask for smooth masking.

**Show Mask Graphic:** Show the graphic that is associated with the Mask render area.
**Desampling Rate:** The desampling rate for soft mask buffer. The larger the value, the better the performance but the lower the quality.
**Softness:** The value used by the soft mask to select the area of influence defined over the soft mask's graphic.
**Ignore Parent:** Should the soft mask ignore parent soft masks?|| +|SoftMaskable|Add this component to Graphic under SoftMask for smooth masking.

**Inverse:** The graphic will be visible only in areas where no mask is present.|| + + + +



+## Demo + +[WebGL Demo](http://mob-sakai.github.io/SoftMaskForUGUI) + + + +



+## Install + +#### Using UnityPackageManager (for Unity 2018.3+) + +Find the manifest.json file in the Packages folder of your project and edit it to look like this: +```js +{ + "dependencies": { + "com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git#0.4.0", + ... + }, +} +``` + +#### Using .unitypackage file (for Unity 2017.1+) + +Download `*.unitypackage` from [Releases](https://github.com/mob-sakai/SoftMaskForUGUI/releases) and import the package into your Unity project. +Select `Assets > Import Package > Custom Package` from the menu. +![](https://user-images.githubusercontent.com/12690315/46570979-edbb5a00-c9a7-11e8-845d-c5ee279effec.png) + + + +



+## How to play demo + +* Import `SoftMask_Demo.unitypackage` into your project. +* The unitypackage exists in `Assets/Assets/Coffee/UIExtensions/SoftMaskForUGUI` or `Packages/Soft Mask For uGUI`. +![](https://user-images.githubusercontent.com/12690315/51080546-ff3b9d00-1720-11e9-8a58-9e22003714af.png) +* Open SoftMask_Demo scene and play it. +* The demo requires `TextMeshPro` and `TextMeshPro Essential Resources`. Import it before playing. + + + +



+## Usage + +1. Add SoftMask component instead of Mask component. +Or, convert existing Mask component to SoftMask component from the context menu. +![](https://user-images.githubusercontent.com/12690315/48659018-902e2900-ea8e-11e8-9b6e-224365cdde7f.png) +2. Add SoftMaskable components to the child UI elements of SoftMask component. +![](https://user-images.githubusercontent.com/12690315/48704424-d4a9f800-ec39-11e8-8d65-8b7d1975750c.png) +Or, add SoftMaskable components from the inspector of SoftMask component. +![](https://user-images.githubusercontent.com/12690315/50284153-76bc3a80-049b-11e9-8c55-719af897960a.png) +3. Adjust softness of SoftMask. +![](https://user-images.githubusercontent.com/12690315/48661087-01ca9f00-eab0-11e8-8878-772a1ed1fb7b.gif) +4. Enjoy! + + +##### Requirement + +* Unity 2017+ *(including Unity 2018.x)* +* No other SDK are required + + + +



+## Development Note + +#### Support soft masks in your custom shaders + +You can support soft masks in your custom shaders, by adding just 3 lines! + +1. Add `#pragma` and `#include`. `SOFTMASK_EDITOR` is a keyword for editor, not included in the build. +``` +#include "Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc" +#pragma shader_feature __ SOFTMASK_EDITOR +``` +2. Apply a soft mask in the fragment shader. `IN.vertex` is clip position. +``` +color.a *= SoftMask(IN.vertex); +``` + +As an example of implementation, please see [UI-Default-SoftMask.shader](https://raw.githubusercontent.com/mob-sakai/SoftMaskForUGUI/master/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Resources/UI-Default-SoftMask.shader). + + +

+#### Why is not it displayed properly in SceneView? + +SoftMask calculates the final alpha value based on the value of each channel of the soft mask buffer. +The soft mask buffer is a buffer generated based on GameView's screen space. + +Since SceneView has a view matrix and a projection matrix independent of GameView, the SceneView's camera can not refer to the soft mask buffer properly. + +Therefore, in GameView, it is displayed properly. but in ScreenView, it is displayed like default Mask. + +![](https://user-images.githubusercontent.com/12690315/48704647-80ebde80-ec3a-11e8-8b2a-99095af85442.png) + + +

+#### Tips: Convert component from context menu + +Converting components from the context menu is very convenient. +You can convert multiple components at the same time, without having to remove the source components. + +![](https://user-images.githubusercontent.com/12690315/48659018-902e2900-ea8e-11e8-9b6e-224365cdde7f.png) + +If the destination component has the same properties as the source component, the value is set automatically. + +In addition, if the destination component is compatible with the source component, it will not lose its reference. +For example, if `public Mask mask;` refers to a Mask, converting it to SoftMask in this way does not lose references. + +This way consists of two generic methods. + +```cs +/// +/// Verify whether it can be converted to the specified component. +/// +protected static bool CanConvertTo(Object context) + where T : MonoBehaviour +{ + return context && context.GetType() != typeof(T); +} + +/// +/// Convert to the specified component. +/// +protected static void ConvertTo(Object context) where T : MonoBehaviour +{ + var target = context as MonoBehaviour; + var so = new SerializedObject(target); + so.Update(); + + bool oldEnable = target.enabled; + target.enabled = false; + + // Find MonoScript of the specified component. + foreach (var script in Resources.FindObjectsOfTypeAll()) + { + if (script.GetClass() != typeof(T)) + continue; + + // Set 'm_Script' to convert. + so.FindProperty("m_Script").objectReferenceValue = script; + so.ApplyModifiedProperties(); + break; + } + + (so.targetObject as MonoBehaviour).enabled = oldEnable; +} +``` + +In SoftMask, they are implemented as follows. +* Mask and SoftMask can be converted to each other. +* If conversion is not possible, gray out the context menu. + +```cs +[MenuItem("CONTEXT/Mask/Convert To SoftMask", true)] +static bool _ConvertToSoftMask(MenuCommand command) +{ + return CanConvertTo(command.context); +} +[MenuItem("CONTEXT/Mask/Convert To SoftMask", false)] +static void ConvertToSoftMask(MenuCommand command) +{ + ConvertTo(command.context); +} +[MenuItem("CONTEXT/Mask/Convert To Mask", true)] +static bool _ConvertToMask(MenuCommand command) +{ + return CanConvertTo(command.context); +} +[MenuItem("CONTEXT/Mask/Convert To Mask", false)] +static void ConvertToMask(MenuCommand command) +{ + ConvertTo(command.context); +} +``` + +For details, please see [SoftMaskEditor.cs](https://raw.githubusercontent.com/mob-sakai/SoftMaskForUGUI/master/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/SoftMaskEditor.cs). + + +

+#### Tips: Shader code for editor only + +Do you know how to implement shader code "for editor only"? +SoftMask uses `SOFTMASK_EDITOR` keyword in shader code to determine whether it is running in the editor. + +`#pragma shader_feature __ SOFTMASK_EDITOR` + +`SOFTMASK_EDITOR` keyword is set from the editor script, but it is not set after it is built. Also, this shader variant will be excluded from build. + +```cs +#if UNITY_EDITOR +material = new Material(shader); +material.hideFlags = HideFlags.HideAndDontSave; +material.EnableKeyword("SOFTMASK_EDITOR"); +#endif +``` + + +

+#### Tips: Shader code for SceneView only + +Do you know how to implement shader code "for SceneView only"? +SoftMask understands that the current rendering is for SceneView, when SceneView's view projection matrix and UNITY_MATRIX_VP match. + +`fixed isSceneView = 1 - any(UNITY_MATRIX_VP - _SceneViewVP);` + +Actually, because of the movement operation in SceneView, use "approximate" instead of "match". + +```cs +float4x4 _SceneViewVP; + +fixed Approximate(float4x4 a, float4x4 b) +{ + float4x4 d = abs(a - b); + return step( + max(d._m00,max(d._m01,max(d._m02,max(d._m03, + max(d._m10,max(d._m11,max(d._m12,max(d._m13, + max(d._m20,max(d._m21,max(d._m22,max(d._m23, + max(d._m30,max(d._m31,max(d._m32,d._m33))))))))))))))), + 0.01); +} + +fixed isSceneView = Approximate(UNITY_MATRIX_VP, _SceneViewVP); +``` + +`_SceneViewVP` is set every frame from the editor script. + +```cs +#if UNITY_EDITOR +UnityEditor.EditorApplication.update += () +{ + Camera cam = UnityEditor.SceneView.lastActiveSceneView.camera; + Matrix4x4 vp = cam.projectionMatrix * cam.worldToCameraMatrix; + material.SetMatrix("_SceneViewVP", vp); +}; +#endif +``` + + + +



+## License + +* MIT +* © UTJ/UCL + + + +## Author + +[mob-sakai](https://github.com/mob-sakai) +[![](https://img.shields.io/twitter/follow/mob_sakai.svg?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=mob_sakai) +[![become_a_patron](https://user-images.githubusercontent.com/12690315/50731615-ce9db580-11ac-11e9-964f-e0423533dc69.png)](https://www.patreon.com/join/2343451?) + + + +## See Also + +* GitHub page : https://github.com/mob-sakai/SoftMaskForUGUI +* Releases : https://github.com/mob-sakai/SoftMaskForUGUI/releases +* Issue tracker : https://github.com/mob-sakai/SoftMaskForUGUI/issues +* Current project : https://github.com/mob-sakai/SoftMaskForUGUI/projects/1 +* Change log : https://github.com/mob-sakai/SoftMaskForUGUI/blob/master/CHANGELOG.md diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Coffee.SoftMaskForUGUI.asmdef b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Coffee.SoftMaskForUGUI.asmdef new file mode 100644 index 0000000..ccabcd1 --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Coffee.SoftMaskForUGUI.asmdef @@ -0,0 +1,6 @@ +{ + "name": "Coffee.SoftMaskForUGUI", + "references": [], + "includePlatforms": [], + "excludePlatforms": [] +} \ No newline at end of file diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Coffee.SoftMaskForUGUI.asmdef.meta b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Coffee.SoftMaskForUGUI.asmdef.meta new file mode 100644 index 0000000..259b247 --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Coffee.SoftMaskForUGUI.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8ef573751495a4f88822a98a88954a0b +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Coffee.SoftMaskForUGUI.Editor.asmdef b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Coffee.SoftMaskForUGUI.Editor.asmdef new file mode 100644 index 0000000..00a5c0e --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Coffee.SoftMaskForUGUI.Editor.asmdef @@ -0,0 +1,10 @@ +{ + "name": "Coffee.SoftMaskForUGUI.Editor", + "references": [ + "Coffee.SoftMaskForUGUI" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [] +} \ No newline at end of file diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Coffee.SoftMaskForUGUI.Editor.asmdef.meta b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Coffee.SoftMaskForUGUI.Editor.asmdef.meta new file mode 100644 index 0000000..62f2ca4 --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Coffee.SoftMaskForUGUI.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e8f1dfda17cbd45ad95e761ca8c9b120 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/Resources/UI-Default-SoftMask.shader b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/Resources/UI-Default-SoftMask.shader index cb08b37..f2bcaf8 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/Resources/UI-Default-SoftMask.shader +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/Resources/UI-Default-SoftMask.shader @@ -57,7 +57,7 @@ Shader "UI/Default-SoftMask" #pragma multi_compile __ UNITY_UI_CLIP_RECT #pragma multi_compile __ UNITY_UI_ALPHACLIP - #include "Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc" // Add for soft mask + #include "./../../SoftMask.cginc" // Add for soft mask #pragma shader_feature __ SOFTMASK_EDITOR // Add for soft mask struct appdata_t diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_SDF (SoftMaskable).shader b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_SDF (SoftMaskable).shader index 2561d5e..7007532 100755 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_SDF (SoftMaskable).shader +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_SDF (SoftMaskable).shader @@ -126,7 +126,7 @@ SubShader { #include "Assets/TextMesh Pro/Resources/Shaders/TMPro_Properties.cginc" #include "Assets/TextMesh Pro/Resources/Shaders/TMPro.cginc" - #include "Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc" + #include "./../SoftMask.cginc" #pragma shader_feature __ SOFTMASK_EDITOR struct vertex_t { diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_SDF-Mobile (SoftMaskable).shader b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_SDF-Mobile (SoftMaskable).shader index 2619f64..ea2c21d 100755 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_SDF-Mobile (SoftMaskable).shader +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_SDF-Mobile (SoftMaskable).shader @@ -91,7 +91,7 @@ SubShader { #include "UnityUI.cginc" #include "Assets/TextMesh Pro/Resources/Shaders/TMPro_Properties.cginc" - #include "Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc" + #include "./../SoftMask.cginc" #pragma shader_feature __ SOFTMASK_EDITOR struct vertex_t { diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_Sprite (SoftMaskable).shader b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_Sprite (SoftMaskable).shader index 4508fb5..551de98 100755 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_Sprite (SoftMaskable).shader +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Shaders/TMP_Sprite (SoftMaskable).shader @@ -56,7 +56,7 @@ Shader "TextMeshPro/Sprite (SoftMaskable)" #pragma multi_compile __ UNITY_UI_CLIP_RECT #pragma multi_compile __ UNITY_UI_ALPHACLIP - #include "Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc" + #include "./../SoftMask.cginc" #pragma shader_feature __ SOFTMASK_EDITOR struct appdata_t diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc index 13dfabd..be63faf 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc @@ -22,6 +22,10 @@ fixed Approximately(float4x4 a, float4x4 b) half SoftMask(float4 clipPos) { half2 view = clipPos.xy/_ScreenParams.xy; + #if UNITY_UV_STARTS_AT_TOP + view.y = 1.0 - view.y; + #endif + half alpha = lerp(1, tex2D(_SoftMaskTex, view).a, step(15, _Stencil)) * lerp(1, tex2D(_SoftMaskTex, view).b, step(7, _Stencil)) diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask_Demo.unitypackage b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask_Demo.unitypackage new file mode 100644 index 0000000..d9b3315 Binary files /dev/null and b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask_Demo.unitypackage differ diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask_Demo.unitypackage.meta b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask_Demo.unitypackage.meta new file mode 100644 index 0000000..8317516 --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask_Demo.unitypackage.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fdbf04e4a4f2a4ce3aebd88b2e996fbe +timeCreated: 1547267633 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json new file mode 100644 index 0000000..545400d --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json @@ -0,0 +1,16 @@ +{ + "name": "com.coffee.softmask-for-ugui", + "displayName": "Soft Mask For uGUI", + "description": "SoftMask is a smooth masking component for uGUI elements in Unity.\nBy using SoftMask instead of default Mask, rounded edges of UI elements can be expressed beautifully.", + "version": "0.4.0", + "unity": "2017.1", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/mob-sakai/SoftMaskForUGUI.git" + }, + "src": "Assets/Coffee/UIExtensions/SoftMaskForUGUI", + "author": "mob-sakai (https://github.com/mob-sakai)", + "dependencies": { + } +} diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json.meta b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json.meta new file mode 100644 index 0000000..df05cd7 --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c43fd233e88b347cdabc530c23ffe30a +timeCreated: 1547268722 +licenseType: Pro +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo.meta b/Assets/SoftMask_Demo.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo.meta rename to Assets/SoftMask_Demo.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Font.meta b/Assets/SoftMask_Demo/Font.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Font.meta rename to Assets/SoftMask_Demo/Font.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Font/FontLicense.txt b/Assets/SoftMask_Demo/Font/FontLicense.txt similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Font/FontLicense.txt rename to Assets/SoftMask_Demo/Font/FontLicense.txt diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Font/FontLicense.txt.meta b/Assets/SoftMask_Demo/Font/FontLicense.txt.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Font/FontLicense.txt.meta rename to Assets/SoftMask_Demo/Font/FontLicense.txt.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Font/LuckiestGuy.ttf b/Assets/SoftMask_Demo/Font/LuckiestGuy.ttf similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Font/LuckiestGuy.ttf rename to Assets/SoftMask_Demo/Font/LuckiestGuy.ttf diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Font/LuckiestGuy.ttf.meta b/Assets/SoftMask_Demo/Font/LuckiestGuy.ttf.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Font/LuckiestGuy.ttf.meta rename to Assets/SoftMask_Demo/Font/LuckiestGuy.ttf.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Light_Frame.png b/Assets/SoftMask_Demo/Light_Frame.png similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Light_Frame.png rename to Assets/SoftMask_Demo/Light_Frame.png diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Light_Frame.png.meta b/Assets/SoftMask_Demo/Light_Frame.png.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Light_Frame.png.meta rename to Assets/SoftMask_Demo/Light_Frame.png.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources.meta b/Assets/SoftMask_Demo/Resources.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources.meta rename to Assets/SoftMask_Demo/Resources.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials.meta b/Assets/SoftMask_Demo/Resources/Fonts & Materials.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials.meta rename to Assets/SoftMask_Demo/Resources/Fonts & Materials.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Bangers SDF Logo (SoftMaskable).asset b/Assets/SoftMask_Demo/Resources/Fonts & Materials/Bangers SDF Logo (SoftMaskable).asset similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Bangers SDF Logo (SoftMaskable).asset rename to Assets/SoftMask_Demo/Resources/Fonts & Materials/Bangers SDF Logo (SoftMaskable).asset diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Bangers SDF Logo (SoftMaskable).asset.meta b/Assets/SoftMask_Demo/Resources/Fonts & Materials/Bangers SDF Logo (SoftMaskable).asset.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Bangers SDF Logo (SoftMaskable).asset.meta rename to Assets/SoftMask_Demo/Resources/Fonts & Materials/Bangers SDF Logo (SoftMaskable).asset.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Floor Cement.jpg b/Assets/SoftMask_Demo/Resources/Fonts & Materials/Floor Cement.jpg similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Floor Cement.jpg rename to Assets/SoftMask_Demo/Resources/Fonts & Materials/Floor Cement.jpg diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Floor Cement.jpg.meta b/Assets/SoftMask_Demo/Resources/Fonts & Materials/Floor Cement.jpg.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Floor Cement.jpg.meta rename to Assets/SoftMask_Demo/Resources/Fonts & Materials/Floor Cement.jpg.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Fruit Jelly (B&W).jpg b/Assets/SoftMask_Demo/Resources/Fonts & Materials/Fruit Jelly (B&W).jpg similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Fruit Jelly (B&W).jpg rename to Assets/SoftMask_Demo/Resources/Fonts & Materials/Fruit Jelly (B&W).jpg diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Fruit Jelly (B&W).jpg.meta b/Assets/SoftMask_Demo/Resources/Fonts & Materials/Fruit Jelly (B&W).jpg.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Fonts & Materials/Fruit Jelly (B&W).jpg.meta rename to Assets/SoftMask_Demo/Resources/Fonts & Materials/Fruit Jelly (B&W).jpg.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Sprite Assets.meta b/Assets/SoftMask_Demo/Resources/Sprite Assets.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Sprite Assets.meta rename to Assets/SoftMask_Demo/Resources/Sprite Assets.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Sprite Assets/EmojiOne (SoftMaskable).mat b/Assets/SoftMask_Demo/Resources/Sprite Assets/EmojiOne (SoftMaskable).mat similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Sprite Assets/EmojiOne (SoftMaskable).mat rename to Assets/SoftMask_Demo/Resources/Sprite Assets/EmojiOne (SoftMaskable).mat diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Sprite Assets/EmojiOne (SoftMaskable).mat.meta b/Assets/SoftMask_Demo/Resources/Sprite Assets/EmojiOne (SoftMaskable).mat.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Resources/Sprite Assets/EmojiOne (SoftMaskable).mat.meta rename to Assets/SoftMask_Demo/Resources/Sprite Assets/EmojiOne (SoftMaskable).mat.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Circle.png b/Assets/SoftMask_Demo/SoftMask-Circle.png similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Circle.png rename to Assets/SoftMask_Demo/SoftMask-Circle.png diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Circle.png.meta b/Assets/SoftMask_Demo/SoftMask-Circle.png.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Circle.png.meta rename to Assets/SoftMask_Demo/SoftMask-Circle.png.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Horizontal.png b/Assets/SoftMask_Demo/SoftMask-Horizontal.png similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Horizontal.png rename to Assets/SoftMask_Demo/SoftMask-Horizontal.png diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Horizontal.png.meta b/Assets/SoftMask_Demo/SoftMask-Horizontal.png.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Horizontal.png.meta rename to Assets/SoftMask_Demo/SoftMask-Horizontal.png.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Star.png b/Assets/SoftMask_Demo/SoftMask-Star.png similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Star.png rename to Assets/SoftMask_Demo/SoftMask-Star.png diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Star.png.meta b/Assets/SoftMask_Demo/SoftMask-Star.png.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Star.png.meta rename to Assets/SoftMask_Demo/SoftMask-Star.png.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Vertictal.png b/Assets/SoftMask_Demo/SoftMask-Vertictal.png similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Vertictal.png rename to Assets/SoftMask_Demo/SoftMask-Vertictal.png diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Vertictal.png.meta b/Assets/SoftMask_Demo/SoftMask-Vertictal.png.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask-Vertictal.png.meta rename to Assets/SoftMask_Demo/SoftMask-Vertictal.png.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo.cs b/Assets/SoftMask_Demo/SoftMask_Demo.cs similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo.cs rename to Assets/SoftMask_Demo/SoftMask_Demo.cs diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo.cs.meta b/Assets/SoftMask_Demo/SoftMask_Demo.cs.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo.cs.meta rename to Assets/SoftMask_Demo/SoftMask_Demo.cs.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo.unity b/Assets/SoftMask_Demo/SoftMask_Demo.unity similarity index 99% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo.unity rename to Assets/SoftMask_Demo/SoftMask_Demo.unity index b328838..cfe5157 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo.unity +++ b/Assets/SoftMask_Demo/SoftMask_Demo.unity @@ -13262,10 +13262,10 @@ RectTransform: m_Father: {fileID: 1054913042} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 40.56795} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 650, y: -4.7160244} + m_SizeDelta: {x: 260, y: 40.56795} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1369788304 MonoBehaviour: @@ -15126,10 +15126,10 @@ RectTransform: m_Father: {fileID: 1054913042} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 40.56795} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 390, y: -4.7160244} + m_SizeDelta: {x: 260, y: 40.56795} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1544127206 MonoBehaviour: @@ -16007,7 +16007,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: '>> SoftMask v0.3.0 <<' + m_Text: '>> SoftMask v0.4.0 <<' --- !u!222 &1590748270 CanvasRenderer: m_ObjectHideFlags: 0 @@ -20295,10 +20295,10 @@ RectTransform: m_Father: {fileID: 1054913042} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 40.56795} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 130, y: -4.7160244} + m_SizeDelta: {x: 260, y: 40.56795} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1986134048 MonoBehaviour: diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo.unity.meta b/Assets/SoftMask_Demo/SoftMask_Demo.unity.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo.unity.meta rename to Assets/SoftMask_Demo/SoftMask_Demo.unity.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo_Title.controller b/Assets/SoftMask_Demo/SoftMask_Demo_Title.controller similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo_Title.controller rename to Assets/SoftMask_Demo/SoftMask_Demo_Title.controller diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo_Title.controller.meta b/Assets/SoftMask_Demo/SoftMask_Demo_Title.controller.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo_Title.controller.meta rename to Assets/SoftMask_Demo/SoftMask_Demo_Title.controller.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo_Transition.controller b/Assets/SoftMask_Demo/SoftMask_Demo_Transition.controller similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo_Transition.controller rename to Assets/SoftMask_Demo/SoftMask_Demo_Transition.controller diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo_Transition.controller.meta b/Assets/SoftMask_Demo/SoftMask_Demo_Transition.controller.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo_Transition.controller.meta rename to Assets/SoftMask_Demo/SoftMask_Demo_Transition.controller.meta diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Unity-chan.png b/Assets/SoftMask_Demo/Unity-chan.png similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Unity-chan.png rename to Assets/SoftMask_Demo/Unity-chan.png diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Unity-chan.png.meta b/Assets/SoftMask_Demo/Unity-chan.png.meta similarity index 100% rename from Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/Unity-chan.png.meta rename to Assets/SoftMask_Demo/Unity-chan.png.meta diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index d4dc761..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,51 +0,0 @@ -# Changelog - -## [v0.3.0](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.3.0) (2019-01-07) - -[Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.2.0...v0.3.0) - -**Implemented enhancements:** - -- Remove TMPro resources in repo [\#21](https://github.com/mob-sakai/SoftMaskForUGUI/issues/21) - -**Fixed bugs:** - -- An error occur when SoftMask is destroyed on editor [\#23](https://github.com/mob-sakai/SoftMaskForUGUI/issues/23) - -## [v0.2.0](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.2.0) (2018-12-21) - -[Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.1.0...v0.2.0) - -**Implemented enhancements:** - -- Set default material on disable [\#17](https://github.com/mob-sakai/SoftMaskForUGUI/issues/17) -- Component icon [\#15](https://github.com/mob-sakai/SoftMaskForUGUI/issues/15) -- Support TextMeshPro [\#14](https://github.com/mob-sakai/SoftMaskForUGUI/issues/14) -- Preview soft mask buffer in inspector [\#13](https://github.com/mob-sakai/SoftMaskForUGUI/issues/13) -- Add a SoftMaskable component to the child UI elements of SoftMask From the inspector [\#12](https://github.com/mob-sakai/SoftMaskForUGUI/issues/12) -- Render the soft mask buffer only when needed to improve performance [\#11](https://github.com/mob-sakai/SoftMaskForUGUI/issues/11) - -**Fixed bugs:** - -- Doesn't work with overlay canvas on 2018.3 [\#20](https://github.com/mob-sakai/SoftMaskForUGUI/issues/20) - -## [v0.1.0](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.1.0) (2018-11-20) - -[Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/0d87935fa566cd1cb5e54a6f8826bb72fffb29b8...v0.1.0) - -**Implemented enhancements:** - -- Convert existing Mask to SoftMask from context menu [\#10](https://github.com/mob-sakai/SoftMaskForUGUI/issues/10) -- Desample soft mask buffer to improve performance [\#9](https://github.com/mob-sakai/SoftMaskForUGUI/issues/9) -- Custom shaders supporting [\#8](https://github.com/mob-sakai/SoftMaskForUGUI/issues/8) -- Filter raycast only for the visible part [\#7](https://github.com/mob-sakai/SoftMaskForUGUI/issues/7) -- Inverse soft mask [\#6](https://github.com/mob-sakai/SoftMaskForUGUI/issues/6) -- Nested soft masks [\#5](https://github.com/mob-sakai/SoftMaskForUGUI/issues/5) -- Support multiple-sprites and SpriteAtlas [\#4](https://github.com/mob-sakai/SoftMaskForUGUI/issues/4) -- Adjust the visible part [\#3](https://github.com/mob-sakai/SoftMaskForUGUI/issues/3) -- Compatible with Mask [\#2](https://github.com/mob-sakai/SoftMaskForUGUI/issues/2) -- Screen space soft masking [\#1](https://github.com/mob-sakai/SoftMaskForUGUI/issues/1) - - - -\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 120000 index 0000000..0ad5450 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 120000 index 0000000..c3bca56 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1 @@ +Assets/Coffee/UIExtensions/SoftMaskForUGUI/LICENSE.md \ No newline at end of file diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 421e638..a1f4cc0 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -6,5 +6,5 @@ EditorBuildSettings: serializedVersion: 2 m_Scenes: - enabled: 1 - path: Assets/Coffee/UIExtensions/SoftMaskForUGUI/Demo/SoftMask_Demo.unity + path: Assets/SoftMask_Demo/SoftMask_Demo.unity guid: aa372e7b286d0416eb942adfc3e442ec diff --git a/README.md b/README.md deleted file mode 100644 index c79ab2f..0000000 --- a/README.md +++ /dev/null @@ -1,300 +0,0 @@ -SoftMaskForUGUI -=== - -Soft masking for uGUI elements in Unity. - -![](https://user-images.githubusercontent.com/12690315/50282438-18408d80-0496-11e9-8f86-81e804edadd4.png) - -[![](https://img.shields.io/github/release/mob-sakai/SoftMaskForUGUI.svg?label=latest%20version)](https://github.com/mob-sakai/SoftMaskForUGUI/releases) -[![](https://img.shields.io/github/release-date/mob-sakai/SoftMaskForUGUI.svg)](https://github.com/mob-sakai/SoftMaskForUGUI/releases) -![](https://img.shields.io/badge/unity-2017%2B-green.svg) -[![](https://img.shields.io/github/license/mob-sakai/SoftMaskForUGUI.svg)](https://github.com/mob-sakai/SoftMaskForUGUI/blob/master/LICENSE.txt) -[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-orange.svg)](http://makeapullrequest.com) - -<< [Description](#Description) | [WebGL Demo](#demo) | [Download](https://github.com/mob-sakai/SoftMaskForUGUI/releases) | [Usage](#usage) | [Development Note](#development-note) >> - -### What's new? [See changelog ![](https://img.shields.io/github/release-date/mob-sakai/SoftMaskForUGUI.svg?label=last%20updated)](https://github.com/mob-sakai/SoftMaskForUGUI/blob/develop/CHANGELOG.md) -### Do you want to receive notifications for new releases? [Watch this repo ![](https://img.shields.io/github/watchers/mob-sakai/SoftMaskForUGUI.svg?style=social&label=Watch)](https://github.com/mob-sakai/SoftMaskForUGUI/subscription) - - - -



-## Description - -SoftMask is a smooth masking component for uGUI elements in Unity. -By using SoftMask instead of default Mask, rounded edges of UI elements can be expressed beautifully. - -![](https://user-images.githubusercontent.com/12690315/50282806-4b375100-0497-11e9-891c-35309d332c7b.png) - -#### Features - -* SoftMask is compatible with Mask. -* You can adjust the visible part. -![](https://user-images.githubusercontent.com/12690315/48661087-01ca9f00-eab0-11e8-8878-772a1ed1fb7b.gif) -* Text, Image, RawImage can be used as a masking. -* Support multiple-sprites and SpriteAtlas. -* Support up to 4 nested soft masks. -![](https://user-images.githubusercontent.com/12690315/48708326-a0d4cf80-ec45-11e8-83b8-f55d29138db7.png) -* Support scroll view. -![](https://user-images.githubusercontent.com/12690315/48708527-2b1d3380-ec46-11e8-9adf-9d33498f0353.png) -* Support inversed soft mask. -![](https://user-images.githubusercontent.com/12690315/48708328-a0d4cf80-ec45-11e8-9945-e877faabc968.png) -* Support overlay, camera space and world space. -![](https://user-images.githubusercontent.com/12690315/48708329-a0d4cf80-ec45-11e8-8328-16b697f981ec.png) -* Raycast is filtered only for the visible part. -![](https://user-images.githubusercontent.com/12690315/48708330-a16d6600-ec45-11e8-94bf-afecd1bd9a39.png) -* Contain soft maskable UI shader. -* Support soft masks in your custom shaders by adding just 3 lines. For details, please see [Development Note](#support-soft-masks-in-your-custom-shaders). -* Adjust soft mask buffer size to improve performance. -* Convert existing Mask to SoftMask from context menu. -![](https://user-images.githubusercontent.com/12690315/48659018-902e2900-ea8e-11e8-9b6e-224365cdde7f.png) -* Render the soft mask buffer only when needed to improve performance. -* Add a SoftMaskable component to the child UI elements of SoftMask from the inspector. -![](https://user-images.githubusercontent.com/12690315/50284153-76bc3a80-049b-11e9-8c55-719af897960a.png) -* Preview soft mask buffer in inspector. -![](https://user-images.githubusercontent.com/12690315/50284151-7459e080-049b-11e9-9cd3-24fb476766dc.png) -* Support TextMeshPro. -![](https://user-images.githubusercontent.com/12690315/50284145-71f78680-049b-11e9-8be1-ac0ccbdf0144.png) - -#### Known issues - -* SceneView does not display SoftMask properly. It is displayed like Mask. ([By design](#why-is-not-it-displayed-properly-in-sceneview)) - -#### Components - -|Component|Description|Screenshot| -|-|-|-| -|SoftMask|Use instead of Mask for smooth masking.

**Show Mask Graphic:** Show the graphic that is associated with the Mask render area.
**Desampling Rate:** The desampling rate for soft mask buffer. The larger the value, the better the performance but the lower the quality.
**Softness:** The value used by the soft mask to select the area of influence defined over the soft mask's graphic.
**Ignore Parent:** Should the soft mask ignore parent soft masks?|| -|SoftMaskable|Add this component to Graphic under SoftMask for smooth masking.

**Inverse:** The graphic will be visible only in areas where no mask is present.|| - - - -



-## Demo - -[WebGL Demo](http://mob-sakai.github.io/SoftMaskForUGUI) - - - -



-## Usage - -1. Download `*.unitypackage` from [Releases](https://github.com/mob-sakai/SoftMaskForUGUI/releases). -2. Import the package into your Unity project. Select `Import Package > Custom Package` from the `Assets` menu. -![](https://user-images.githubusercontent.com/12690315/46570979-edbb5a00-c9a7-11e8-845d-c5ee279effec.png) -3. Add SoftMask component instead of Mask component. Or, convert existing Mask component to SoftMask component from the context menu. -![](https://user-images.githubusercontent.com/12690315/48659018-902e2900-ea8e-11e8-9b6e-224365cdde7f.png) -4. Add SoftMaskable components to the child UI elements of SoftMask component. -![](https://user-images.githubusercontent.com/12690315/48704424-d4a9f800-ec39-11e8-8d65-8b7d1975750c.png) -Or, add SoftMaskable components from the inspector of SoftMask component. -![](https://user-images.githubusercontent.com/12690315/50284153-76bc3a80-049b-11e9-8c55-719af897960a.png) -5. Adjust softness of SoftMask. -![](https://user-images.githubusercontent.com/12690315/48661087-01ca9f00-eab0-11e8-8878-772a1ed1fb7b.gif) -6. Enjoy! - - -##### Requirement - -* Unity 2017+ *(including Unity 2018.x)* -* No other SDK are required - - - -



-## Development Note - -#### Support soft masks in your custom shaders - -You can support soft masks in your custom shaders, by adding just 3 lines! - -1. Add `#pragma` and `#include`. `SOFTMASK_EDITOR` is a keyword for editor, not included in the build. -``` -#include "Assets/Coffee/UIExtensions/SoftMaskForUGUI/SoftMask.cginc" -#pragma shader_feature __ SOFTMASK_EDITOR -``` -2. Apply a soft mask in the fragment shader. `IN.vertex` is clip position. -``` -color.a *= SoftMask(IN.vertex); -``` - -As an example of implementation, please see [UI-Default-SoftMask.shader](https://raw.githubusercontent.com/mob-sakai/SoftMaskForUGUI/master/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Resources/UI-Default-SoftMask.shader). - - -

-#### Why is not it displayed properly in SceneView? - -SoftMask calculates the final alpha value based on the value of each channel of the soft mask buffer. -The soft mask buffer is a buffer generated based on GameView's screen space. - -Since SceneView has a view matrix and a projection matrix independent of GameView, the SceneView's camera can not refer to the soft mask buffer properly. - -Therefore, in GameView, it is displayed properly. but in ScreenView, it is displayed like default Mask. - -![](https://user-images.githubusercontent.com/12690315/48704647-80ebde80-ec3a-11e8-8b2a-99095af85442.png) - - -

-#### Tips: Convert component from context menu - -Converting components from the context menu is very convenient. -You can convert multiple components at the same time, without having to remove the source components. - -![](https://user-images.githubusercontent.com/12690315/48659018-902e2900-ea8e-11e8-9b6e-224365cdde7f.png) - -If the destination component has the same properties as the source component, the value is set automatically. - -In addition, if the destination component is compatible with the source component, it will not lose its reference. -For example, if `public Mask mask;` refers to a Mask, converting it to SoftMask in this way does not lose references. - -This way consists of two generic methods. - -```cs -/// -/// Verify whether it can be converted to the specified component. -/// -protected static bool CanConvertTo(Object context) - where T : MonoBehaviour -{ - return context && context.GetType() != typeof(T); -} - -/// -/// Convert to the specified component. -/// -protected static void ConvertTo(Object context) where T : MonoBehaviour -{ - var target = context as MonoBehaviour; - var so = new SerializedObject(target); - so.Update(); - - bool oldEnable = target.enabled; - target.enabled = false; - - // Find MonoScript of the specified component. - foreach (var script in Resources.FindObjectsOfTypeAll()) - { - if (script.GetClass() != typeof(T)) - continue; - - // Set 'm_Script' to convert. - so.FindProperty("m_Script").objectReferenceValue = script; - so.ApplyModifiedProperties(); - break; - } - - (so.targetObject as MonoBehaviour).enabled = oldEnable; -} -``` - -In SoftMask, they are implemented as follows. -* Mask and SoftMask can be converted to each other. -* If conversion is not possible, gray out the context menu. - -```cs -[MenuItem("CONTEXT/Mask/Convert To SoftMask", true)] -static bool _ConvertToSoftMask(MenuCommand command) -{ - return CanConvertTo(command.context); -} -[MenuItem("CONTEXT/Mask/Convert To SoftMask", false)] -static void ConvertToSoftMask(MenuCommand command) -{ - ConvertTo(command.context); -} -[MenuItem("CONTEXT/Mask/Convert To Mask", true)] -static bool _ConvertToMask(MenuCommand command) -{ - return CanConvertTo(command.context); -} -[MenuItem("CONTEXT/Mask/Convert To Mask", false)] -static void ConvertToMask(MenuCommand command) -{ - ConvertTo(command.context); -} -``` - -For details, please see [SoftMaskEditor.cs](https://raw.githubusercontent.com/mob-sakai/SoftMaskForUGUI/master/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/SoftMaskEditor.cs). - - -

-#### Tips: Shader code for editor only - -Do you know how to implement shader code "for editor only"? -SoftMask uses `SOFTMASK_EDITOR` keyword in shader code to determine whether it is running in the editor. - -`#pragma shader_feature __ SOFTMASK_EDITOR` - -`SOFTMASK_EDITOR` keyword is set from the editor script, but it is not set after it is built. Also, this shader variant will be excluded from build. - -```cs -#if UNITY_EDITOR -material = new Material(shader); -material.hideFlags = HideFlags.HideAndDontSave; -material.EnableKeyword("SOFTMASK_EDITOR"); -#endif -``` - - -

-#### Tips: Shader code for SceneView only - -Do you know how to implement shader code "for SceneView only"? -SoftMask understands that the current rendering is for SceneView, when SceneView's view projection matrix and UNITY_MATRIX_VP match. - -`fixed isSceneView = 1 - any(UNITY_MATRIX_VP - _SceneViewVP);` - -Actually, because of the movement operation in SceneView, use "approximate" instead of "match". - -```cs -float4x4 _SceneViewVP; - -fixed Approximate(float4x4 a, float4x4 b) -{ - float4x4 d = abs(a - b); - return step( - max(d._m00,max(d._m01,max(d._m02,max(d._m03, - max(d._m10,max(d._m11,max(d._m12,max(d._m13, - max(d._m20,max(d._m21,max(d._m22,max(d._m23, - max(d._m30,max(d._m31,max(d._m32,d._m33))))))))))))))), - 0.01); -} - -fixed isSceneView = Approximate(UNITY_MATRIX_VP, _SceneViewVP); -``` - -`_SceneViewVP` is set every frame from the editor script. - -```cs -#if UNITY_EDITOR -UnityEditor.EditorApplication.update += () -{ - Camera cam = UnityEditor.SceneView.lastActiveSceneView.camera; - Matrix4x4 vp = cam.projectionMatrix * cam.worldToCameraMatrix; - material.SetMatrix("_SceneViewVP", vp); -}; -#endif -``` - - - -



-## License - -* MIT -* © UTJ/UCL - - - -## Author - -[mob-sakai](https://github.com/mob-sakai) - - - -## See Also - -* GitHub page : https://github.com/mob-sakai/SoftMaskForUGUI -* Releases : https://github.com/mob-sakai/SoftMaskForUGUI/releases -* Issue tracker : https://github.com/mob-sakai/SoftMaskForUGUI/issues -* Current project : https://github.com/mob-sakai/SoftMaskForUGUI/projects/1 -* Change log : https://github.com/mob-sakai/SoftMaskForUGUI/blob/master/CHANGELOG.md diff --git a/README.md b/README.md new file mode 120000 index 0000000..d250138 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md \ No newline at end of file diff --git a/package.json b/package.json deleted file mode 100644 index c6f5ef7..0000000 --- a/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "SoftMaskForUGUI", - "version": "0.3.0", - "repository": { - "type": "git", - "url": "git+https://github.com/mob-sakai/SoftMaskForUGUI.git" - }, - "src": "Assets/Coffee/UIExtensions/SoftMaskForUGUI", - "license": "MIT" -} diff --git a/package.json b/package.json new file mode 120000 index 0000000..fe92664 --- /dev/null +++ b/package.json @@ -0,0 +1 @@ +Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json \ No newline at end of file diff --git a/release.sh b/release.sh deleted file mode 100755 index 8e8bce8..0000000 --- a/release.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -e - -# NOTE: Set an environment variable `CHANGELOG_GITHUB_TOKEN` by running the following command at the prompt, or by adding it to your shell profile (e.g., ~/.bash_profile or ~/.zshrc): -# export CHANGELOG_GITHUB_TOKEN="«your-40-digit-github-token»" -bash <(curl -sL 'https://gist.github.com/mob-sakai/a883999a32dd8b1927639e46b3cd6801/raw/unity_release.sh') \ No newline at end of file diff --git a/unity_release.sh b/unity_release.sh new file mode 100755 index 0000000..ed87c98 --- /dev/null +++ b/unity_release.sh @@ -0,0 +1,137 @@ +#!/bin/bash -e + +# NOTE: Run the following command at the prompt +# bash <(curl -sL 'https://gist.github.com/mob-sakai/a883999a32dd8b1927639e46b3cd6801/raw/unity_release.sh') +# NOTE: Set an environment variable `CHANGELOG_GITHUB_TOKEN` by running the following command at the prompt, or by adding it to your shell profile (e.g., ~/.bash_profile or ~/.zshrc): +# export CHANGELOG_GITHUB_TOKEN="«your-40-digit-github-token»" + + + +# 1. << Input release version >> +echo -e ">> Start Github Release:" +PACKAGE_NAME=`node -pe 'require("./package.json").name'` +echo -e ">> Package name: ${PACKAGE_NAME}" +CURRENT_VERSION=`grep -o -e "\"version\".*$" package.json | sed -e "s/\"version\": \"\(.*\)\".*$/\1/"` + +read -p "[? (1/8) Input release version (for current: ${CURRENT_VERSION}): " RELEASE_VERSION +[ -z "${RELEASE_VERSION}" ] && exit + +read -p "[? Are the issues on this release closed all? (y/N):" yn +case "$yn" in [yY]*) ;; *) exit ;; esac + +read -p "[? Is package editor only? (y/N):" yn +case "$yn" in [yY]*) EDITOR_ONLY=true;; *) ;; esac + +read -p "[? Is package for UnityPackageManager? (y/N):" yn +case "$yn" in [yY]*) UNITY_PACKAGE_MANAGER=true;; *) ;; esac + +echo -e ">> OK" + + + +# 2. << Update version in package.json >> +echo -e "\n>> (2/8) Update version... package.json" +[ -L package.json ] && PKG_JSON_PATH=`readlink package.json` || PKG_JSON_PATH=package.json +git checkout -B release develop +sed -i -e "s/\"version\": \(.*\)/\"version\": \"${RELEASE_VERSION}\",/g" "${PKG_JSON_PATH}" +rm "${PKG_JSON_PATH}-e" +echo -e ">> OK" + + + +# 3. << Check unity editor is exist and no compile error >> +UNITY_VER=`sed -e "s/m_EditorVersion: \(.*\)/\1/g" ProjectSettings/ProjectVersion.txt` +UNITY_EDITOR="/Applications/Unity/Hub/Editor/${UNITY_VER}/Unity.app/Contents/MacOS/Unity" +UNITY_LOG="unity.log" +UNITY_ARGS="-quit -batchmode -projectPath `pwd` -logFile $UNITY_LOG" +UNITY_PACKAGE_SRC=`node -pe 'require("./package.json").src'` +UNITY_PACKAGE_NAME="${PACKAGE_NAME}_${RELEASE_VERSION}.unitypackage" +echo -e "\n>> (3/8) Check exporting package is available..." +echo -e "Version: $UNITY_VER ($UNITY_EDITOR)" +echo -e "Package Source: $UNITY_PACKAGE_SRC" + +# 3-1. Is src directory exist? +[ ! -d "$UNITY_PACKAGE_SRC" ] && echo -e "\n>> Error : $UNITY_PACKAGE_SRC is not exist." && exit + +# 3-2. Is runtime compile successfully? +set +e +if [ "$EDITOR_ONLY" != "true" ]; then + echo -e "\n>> compile for runtime..." + "$UNITY_EDITOR" $UNITY_ARGS -buildOSX64Player `pwd`/build.app + [ $? != 0 ] && echo -e "\n>> Error : \n`cat $UNITY_LOG | grep -E ': error CS|Fatal Error'`" && exit + echo -e ">> OK" +fi + +# 3-3. Is exporting package successfully? +echo -e "\n>> Pre export package..." +"$UNITY_EDITOR" $UNITY_ARGS -exportpackage $UNITY_PACKAGE_SRC $UNITY_PACKAGE_NAME +[ $? != 0 ] && echo -e "\n>> Error : \n`cat $UNITY_LOG | grep -E ': error CS|Fatal Error'`" && exit +echo -e ">> OK" +set -e + + + +# 4. << Generate change log >> +CHANGELOG_GENERATOR_ARG=`grep -o -e ".*git\"$" package.json | sed -e "s/^.*\/\([^\/]*\)\/\([^\/]*\).git.*$/--user \1 --project \2/"` +CHANGELOG_GENERATOR_ARG="--future-release ${RELEASE_VERSION} ${CHANGELOG_GENERATOR_ARG}" +echo -e "\n>> (4/8) Generate change log... ${CHANGELOG_GENERATOR_ARG}" +github_changelog_generator ${CHANGELOG_GENERATOR_ARG} + +[ -L CHANGELOG.md ] && git diff -- `readlink CHANGELOG.md` || git diff -- CHANGELOG.md +read -p "[? Is the change log correct? (y/N):" yn +case "$yn" in [yY]*) ;; *) exit ;; esac +echo -e ">> OK" + + + +# 5. << Export unitypackage >> +echo -e "\n>> (5/8) Export unitypackage..." +set +e +"$UNITY_EDITOR" $UNITY_ARGS -exportpackage $UNITY_PACKAGE_SRC $UNITY_PACKAGE_NAME +[ $? != 0 ] && echo -e "\n>> Error : \n`cat $UNITY_LOG | grep -E ': error CS|Fatal Error'`" && exit +set -e +echo -e ">> OK" + + + +# 6. << Commit release files >> +echo -e "\n>> (6/8) Commit release files..." +[ -L CHANGELOG.md ] && git add -- "`readlink CHANGELOG.md`" || git add -- CHANGELOG.md +[ -L package.json ] && git add -- "`readlink package.json`" || git add -- package.json +git commit -m "update change log" +echo -e ">> OK" + + + +# 7. << Split for upm >> +if [ "$UNITY_PACKAGE_MANAGER" == "true" ]; then + echo -e "\n>> Split for upm..." + git subtree split --prefix="$UNITY_PACKAGE_SRC" --branch upm + git push origin upm +fi + + + +# 7. << Merge and push master and develop branch >> +echo -e "\n>> (7/8) Merge and push..." +git checkout master +git merge --no-ff release -m "release $RELEASE_VERSION" +git branch -D release +git push origin master +git checkout develop +git merge --ff master +git push origin develop +echo -e ">> OK" + + + +# 8. << Upload unitypackage and release on Github >> +echo -e "\n>> (8/8) Releasing..." +[ "$UNITY_PACKAGE_MANAGER" == "true" ] && git checkout upm -f +gh-release --assets $UNITY_PACKAGE_NAME --name $RELEASE_VERSION --tag_name $RELEASE_VERSION +echo -e ">> OK" + + + + +echo -e "\n\n>> $PACKAGE_NAME $RELEASE_VERSION has been successfully released!\n"