|
|
11 月之前 | |
|---|---|---|
| .. | ||
| .github | 11 月之前 | |
| Icons | 11 月之前 | |
| Samples~ | 11 月之前 | |
| Scripts | 11 月之前 | |
| Shaders | 11 月之前 | |
| .releaserc.json | 11 月之前 | |
| CHANGELOG.md | 11 月之前 | |
| CHANGELOG.md.meta | 11 月之前 | |
| CODE_OF_CONDUCT.md | 11 月之前 | |
| CODE_OF_CONDUCT.md.meta | 11 月之前 | |
| CONTRIBUTING.md | 11 月之前 | |
| CONTRIBUTING.md.meta | 11 月之前 | |
| Icons.meta | 11 月之前 | |
| LICENSE.md | 11 月之前 | |
| LICENSE.md.meta | 11 月之前 | |
| README.md | 11 月之前 | |
| README.md.meta | 11 月之前 | |
| Scripts.meta | 11 月之前 | |
| Shaders.meta | 11 月之前 | |
| package.json | 11 月之前 | |
| package.json.meta | 11 月之前 | |
:warning: NOTE: Do not use the obsolete tags and branches to reference the package. They will be removed in near future. :warning:
UI Soft Mask is a smooth masking component for Unity UI (uGUI) elements.
<< Description | WebGL Demo | Installation | Usage | For Your Custom Shader | Contributing >>
By using SoftMask instead of the default Mask component, you can beautifully represent the rounded edges of UI elements.










This package is available on OpenUPM. You can install it via openupm-cli.
openupm add com.coffee.softmask-for-ugui
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
{
"dependencies": {
"com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git",
...
},
}
To update the package, change suffix #{version} to the target version.
"com.coffee.softmask-for-ugui": "https://github.com/mob-sakai/SoftMaskForUGUI.git#1.0.0",Or, use UpmGitExtension to install and update the package.
Packages (It works as an embedded package. For Unity 2018.1 or later)Assets (Legacy way. For Unity 2017.1 or later)Package Manager window and select UI Soft Mask package in package list and click Demo > Import in project buttonAssets/Samples/UISoftMask/Import Demo from menuThe assets will be imported into Assets/Samples/UI Soft Mask/{version}/Demo.
Open UISoftMask_Demo scene and play it.




To use SoftMask with TextMeshPro, import a sample asset.
Package Manager window and select UI Soft Mask package in package list and click TextMeshPro Support > Import in project buttonAssets/Samples/UISoftMask/Import TextMeshPro Support from menuThe assets will be imported into Assets/Samples/UI Soft Mask/{version}/TextMeshPro Support.
NOTE: You must import TMP Essential Resources before using. They include shaders, fonts, etc.
NOTE: If the shader error is not resolved, reimport the shader. Or, import the TextMeshPro Support again.
Only a few steps are needed to support soft mask in your custom shaders!
Duplicate your shader file and add the (SoftMaskable) suffix to the file name.
Your_Custom_Shader.shader
-> Your_Custom_Shader (SoftMaskable).shader
Modify the shader name (defined at the beginning of the shader file) as follows:
Hidden/ prefixAdd (SoftMaskable) suffix
Shader "UI/Your_Custom_Shader"
-> Shader "Hidden/UI/Your_Custom_Shader (SoftMaskable)"
Add #pragma and #include directives, where SOFTMASK_EDITOR is an editor-only keyword and is not included in the build.
If you didn't use package manager to install, include SoftMask.cginc in the appropriate path instead.
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
#pragma shader_feature __ SOFTMASK_EDITOR
Apply a soft mask in the fragment shader.
This operation determines the final alpha according to the soft mask buffer.
IN.vertex: the clip positionIN.worldPosition: the world position
color.a *= SoftMask(IN.vertex, IN.worldPosition);
As an example of implementation, please see UI-Default-SoftMask.shader.
Issues are very valuable to this project.
Pull requests are, a great way to get your ideas into this repository.
See CONTRIBUTING.md.
This is an open source project that I am developing in my spare time.
If you like it, please support me.
With your support, I can spend more time on development. :)