diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..b98b11b --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # [mob-sakai] +patreon: mob_sakai +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with a single custom sponsorship URL diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md index 86b5c18..2e33567 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [v0.9.0](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.9.0) (2019-08-27) + +[Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.8.1...v0.9.0) + +**Implemented enhancements:** + +- Improved work in prefab view [\#55](https://github.com/mob-sakai/SoftMaskForUGUI/pull/55) ([ManeFunction](https://github.com/ManeFunction)) + +**Fixed bugs:** + +- Prefab Mode in Play Mode is not supported [\#60](https://github.com/mob-sakai/SoftMaskForUGUI/issues/60) +- Missing .meta file [\#59](https://github.com/mob-sakai/SoftMaskForUGUI/issues/59) + ## [v0.8.1](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.8.1) (2019-05-07) [Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.8.0...v0.8.1) diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md index bdf135c..f026a0d 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/README.md @@ -7,7 +7,7 @@ Soft masking for uGUI elements in Unity. [![](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/badge/unity-2017%20or%20later-green.svg) [![](https://img.shields.io/github/license/mob-sakai/SoftMaskForUGUI.svg)](https://github.com/mob-sakai/SoftMaskForUGUI/blob/upm/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) @@ -16,7 +16,9 @@ Soft masking for uGUI elements in Unity. ### 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?) +### Support me on Patreon! +[![become_a_patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/join/2343451?) + @@ -82,7 +84,7 @@ By using SoftMask instead of default Mask, rounded edges of UI elements can be e



## Install -#### Using UnityPackageManager (for Unity 2018.3+) +#### Using UnityPackageManager (for Unity 2018.3 or later) Find the manifest.json file in the Packages folder of your project and edit it to look like this: ```js @@ -96,7 +98,7 @@ Find the manifest.json file in the Packages folder of your project and edit it t To update the package, change `#{version}` to the target version. Or, use [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension). -#### Using .unitypackage file (for Unity 2017.1+) +#### Using .unitypackage file (for Unity 2017.1 or later) 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. @@ -132,7 +134,7 @@ Or, add SoftMaskable components from the inspector of SoftMask component. ##### Requirement -* Unity 2017+ *(including Unity 2018.x)* +* Unity 2017 or later *(including Unity 2018.x)* * No other SDK are required @@ -144,14 +146,17 @@ Or, add SoftMaskable components from the inspector of SoftMask component. 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. +1. Add `#pragma` and `#include`. `SOFTMASK_EDITOR` is a keyword for editor only, not included in the build. +If you installed using packageManager, include `Packages/com.coffee.softmask-for-ugui/SoftMask.cginc` instead of. ``` #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. +2. Apply a soft mask in the fragment shader. + - `IN.vertex` is clip position + - `IN.worldPosition` is world position ``` -color.a *= SoftMask(IN.vertex); +color.a *= SoftMask(IN.vertex, IN.worldPosition); ``` As an example of implementation, please see [UI-Default-SoftMask.shader](https://raw.githubusercontent.com/mob-sakai/SoftMaskForUGUI/upm/Shaders/Resources/UI-Default-SoftMask.shader). @@ -313,7 +318,8 @@ UnityEditor.EditorApplication.update += () [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?) +[![become_a_patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/join/2343451?) + diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/SoftMaskEditor.cs b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/SoftMaskEditor.cs index 64543ea..80a1c1c 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/SoftMaskEditor.cs +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/SoftMaskEditor.cs @@ -1,4 +1,3 @@ -using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; @@ -34,7 +33,7 @@ namespace Coffee.UIExtensions.Editors if (0 < fixTargets.Count) { GUILayout.BeginHorizontal (); - EditorGUILayout.HelpBox ("There are child Graphicss that does not have a SoftMaskable component.\nAdd SoftMaskable component to them.", MessageType.Warning); + EditorGUILayout.HelpBox ("There are child Graphics that does not have a SoftMaskable component.\nAdd SoftMaskable component to them.", MessageType.Warning); GUILayout.BeginVertical (); if (GUILayout.Button ("Fix")) { @@ -42,6 +41,8 @@ namespace Coffee.UIExtensions.Editors { p.gameObject.AddComponent (); } + + Utils.MarkPrefabDirty (); } if (GUILayout.Button ("Ping")) { @@ -60,8 +61,8 @@ namespace Coffee.UIExtensions.Editors if (s_Preview) { var tex = current.softMaskBuffer; - var wtdth = tex.width * 64 / tex.height; - EditorGUI.DrawPreviewTexture (GUILayoutUtility.GetRect (wtdth, 64), tex, null, ScaleMode.ScaleToFit); + var width = tex.width * 64 / tex.height; + EditorGUI.DrawPreviewTexture (GUILayoutUtility.GetRect (width, 64), tex, null, ScaleMode.ScaleToFit); Repaint (); } GUILayout.FlexibleSpace (); diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/SoftMaskableEditor.cs b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/SoftMaskableEditor.cs index 085bf46..3f1fd41 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/SoftMaskableEditor.cs +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/SoftMaskableEditor.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEditor; @@ -71,7 +71,7 @@ namespace Coffee.UIExtensions.Editors List _materialEditors = new List (); SerializedProperty _spMaskInteraction; - private void OnEnable () + void OnEnable () { _spMaskInteraction = serializedObject.FindProperty("m_MaskInteraction"); _custom = (maskInteraction == MaskInteraction.Custom); @@ -98,8 +98,8 @@ namespace Coffee.UIExtensions.Editors s_MaskWarning = new GUIContent(EditorGUIUtility.FindTexture("console.warnicon.sml"), "This component is not SoftMask. Use SoftMask instead of Mask."); } - - private void OnDisable () + + void OnDisable () { ClearMaterialEditors (); } @@ -201,15 +201,14 @@ namespace Coffee.UIExtensions.Editors - -// var current = target as SoftMaskable; var current = target as SoftMaskable; + current.GetComponentsInChildren (true, s_Graphics); var fixTargets = s_Graphics.Where (x => x.gameObject != current.gameObject && !x.GetComponent () && (!x.GetComponent () || x.GetComponent ().showMaskGraphic)).ToList (); if (0 < fixTargets.Count) { GUILayout.BeginHorizontal (); - EditorGUILayout.HelpBox ("There are child Graphicss that does not have a SoftMaskable component.\nAdd SoftMaskable component to them.", MessageType.Warning); + EditorGUILayout.HelpBox ("There are child Graphics that does not have a SoftMaskable component.\nAdd SoftMaskable component to them.", MessageType.Warning); GUILayout.BeginVertical (); if (GUILayout.Button ("Fix")) { @@ -236,6 +235,34 @@ namespace Coffee.UIExtensions.Editors ShowMaterialEditors (fontSharedMaterials, 1, fontSharedMaterials.Length - 1); } } + + if (!DetectMask (current.transform.parent)) + { + GUILayout.BeginHorizontal (); + EditorGUILayout.HelpBox ("This is unnecessary SoftMaskable.\nCan't find any SoftMask components above.", MessageType.Warning); + if (GUILayout.Button ("Remove", GUILayout.Height (40))) + { + DestroyImmediate (current); + + Utils.MarkPrefabDirty (); + } + GUILayout.EndHorizontal (); + } + } + + static bool DetectMask (Transform transform) + { + if (transform == null) + { + return false; + } + + if (transform.GetComponent () != null) + { + return true; + } + + return DetectMask (transform.parent); } void ClearMaterialEditors () diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Utils.cs b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Utils.cs new file mode 100644 index 0000000..3dcaea8 --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Utils.cs @@ -0,0 +1,22 @@ +#if UNITY_2018_3_OR_NEWER +using UnityEditor.Experimental.SceneManagement; +#endif +using UnityEditor.SceneManagement; + + +namespace Coffee.UIExtensions.Editors +{ + public static class Utils + { + public static void MarkPrefabDirty () + { + #if UNITY_2018_3_OR_NEWER + var prefabStage = PrefabStageUtility.GetCurrentPrefabStage (); + if (prefabStage != null) + { + EditorSceneManager.MarkSceneDirty (prefabStage.scene); + } + #endif + } + } +} \ No newline at end of file diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Utils.cs.meta b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Utils.cs.meta new file mode 100644 index 0000000..e16b794 --- /dev/null +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/Editor/Utils.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8829eb4004797463480fafa9a1112833 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs index 2210763..76844ca 100755 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/Scripts/SoftMaskable.cs @@ -12,7 +12,11 @@ namespace Coffee.UIExtensions /// Soft maskable. /// Add this component to Graphic under SoftMask for smooth masking. /// +#if UNITY_2018_3_OR_NEWER + [ExecuteAlways] +#else [ExecuteInEditMode] +# endif public class SoftMaskable : MonoBehaviour, IMaterialModifier, ICanvasRaycastFilter, ISerializationCallbackReceiver { //################################ diff --git a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json index 70ede13..a5cd789 100644 --- a/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json +++ b/Assets/Coffee/UIExtensions/SoftMaskForUGUI/package.json @@ -2,7 +2,7 @@ "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.8.1", + "version": "0.9.0", "unity": "2017.1", "license": "MIT", "repository": { diff --git a/CHANGELOG.md b/CHANGELOG.md index 86b5c18..2e33567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [v0.9.0](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.9.0) (2019-08-27) + +[Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.8.1...v0.9.0) + +**Implemented enhancements:** + +- Improved work in prefab view [\#55](https://github.com/mob-sakai/SoftMaskForUGUI/pull/55) ([ManeFunction](https://github.com/ManeFunction)) + +**Fixed bugs:** + +- Prefab Mode in Play Mode is not supported [\#60](https://github.com/mob-sakai/SoftMaskForUGUI/issues/60) +- Missing .meta file [\#59](https://github.com/mob-sakai/SoftMaskForUGUI/issues/59) + ## [v0.8.1](https://github.com/mob-sakai/SoftMaskForUGUI/tree/v0.8.1) (2019-05-07) [Full Changelog](https://github.com/mob-sakai/SoftMaskForUGUI/compare/v0.8.0...v0.8.1) diff --git a/README.md b/README.md index bdf135c..f026a0d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Soft masking for uGUI elements in Unity. [![](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/badge/unity-2017%20or%20later-green.svg) [![](https://img.shields.io/github/license/mob-sakai/SoftMaskForUGUI.svg)](https://github.com/mob-sakai/SoftMaskForUGUI/blob/upm/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) @@ -16,7 +16,9 @@ Soft masking for uGUI elements in Unity. ### 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?) +### Support me on Patreon! +[![become_a_patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/join/2343451?) + @@ -82,7 +84,7 @@ By using SoftMask instead of default Mask, rounded edges of UI elements can be e



## Install -#### Using UnityPackageManager (for Unity 2018.3+) +#### Using UnityPackageManager (for Unity 2018.3 or later) Find the manifest.json file in the Packages folder of your project and edit it to look like this: ```js @@ -96,7 +98,7 @@ Find the manifest.json file in the Packages folder of your project and edit it t To update the package, change `#{version}` to the target version. Or, use [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension). -#### Using .unitypackage file (for Unity 2017.1+) +#### Using .unitypackage file (for Unity 2017.1 or later) 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. @@ -132,7 +134,7 @@ Or, add SoftMaskable components from the inspector of SoftMask component. ##### Requirement -* Unity 2017+ *(including Unity 2018.x)* +* Unity 2017 or later *(including Unity 2018.x)* * No other SDK are required @@ -144,14 +146,17 @@ Or, add SoftMaskable components from the inspector of SoftMask component. 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. +1. Add `#pragma` and `#include`. `SOFTMASK_EDITOR` is a keyword for editor only, not included in the build. +If you installed using packageManager, include `Packages/com.coffee.softmask-for-ugui/SoftMask.cginc` instead of. ``` #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. +2. Apply a soft mask in the fragment shader. + - `IN.vertex` is clip position + - `IN.worldPosition` is world position ``` -color.a *= SoftMask(IN.vertex); +color.a *= SoftMask(IN.vertex, IN.worldPosition); ``` As an example of implementation, please see [UI-Default-SoftMask.shader](https://raw.githubusercontent.com/mob-sakai/SoftMaskForUGUI/upm/Shaders/Resources/UI-Default-SoftMask.shader). @@ -313,7 +318,8 @@ UnityEditor.EditorApplication.update += () [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?) +[![become_a_patron](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/join/2343451?) + diff --git a/package.json b/package.json index 70ede13..a5cd789 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "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.8.1", + "version": "0.9.0", "unity": "2017.1", "license": "MIT", "repository": {