├── ProjectSettings ├── ProjectVersion.txt ├── TagManager.asset ├── AudioManager.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── TimeManager.asset ├── DynamicsManager.asset ├── EditorSettings.asset ├── NetworkManager.asset ├── ProjectSettings.asset ├── QualitySettings.asset ├── GraphicsSettings.asset ├── Physics2DSettings.asset ├── UnityAdsSettings.asset ├── ClusterInputManager.asset ├── EditorBuildSettings.asset └── UnityConnectSettings.asset ├── README.md ├── Assets ├── Res │ ├── Canvas.prefab │ ├── ui_Bag_bg_1.png │ ├── ui_Bag_bg_2.png │ ├── ui_Bag_bg_3.png │ ├── ui_Bag_bg_4.png │ ├── ui_Bag_bg_5.png │ ├── ui_Bag_bg_6.png │ ├── ui_Bag_bg_7.jpg │ ├── Acceleration.prefab │ ├── Canvas.prefab.meta │ ├── Acceleration.prefab.meta │ ├── ui_Bag_bg_1.png.meta │ ├── ui_Bag_bg_2.png.meta │ ├── ui_Bag_bg_3.png.meta │ ├── ui_Bag_bg_4.png.meta │ ├── ui_Bag_bg_5.png.meta │ ├── ui_Bag_bg_6.png.meta │ └── ui_Bag_bg_7.jpg.meta ├── SoftMask │ ├── Doc │ │ ├── 说明.docx │ │ ├── Readme.docx │ │ ├── 说明.docx.meta │ │ └── Readme.docx.meta │ ├── test.unity │ ├── Scene │ │ ├── testdd.unity │ │ └── testdd.unity.meta │ ├── test.unity.meta │ ├── Doc.meta │ ├── Scene.meta │ ├── Editor.meta │ ├── Resources.meta │ ├── Resources │ │ ├── Shader.meta │ │ └── Shader │ │ │ ├── Particle Add.shader.meta │ │ │ ├── UI-Default.shader.meta │ │ │ ├── Particle Blend.shader.meta │ │ │ ├── Particle Multiply.shader.meta │ │ │ ├── UI-Default Grey.shader.meta │ │ │ ├── Particle AddMultiply.shader.meta │ │ │ ├── Particle AddSmooth.shader.meta │ │ │ ├── Particle Alpha Blend.shader.meta │ │ │ ├── Particle MultiplyDouble.shader.meta │ │ │ ├── Particle Premultiply Blend.shader.meta │ │ │ ├── Particle Premultiply Blend.shader │ │ │ ├── Particle Blend.shader │ │ │ ├── Particle Multiply.shader │ │ │ ├── Particle AddSmooth.shader │ │ │ ├── Particle Alpha Blend.shader │ │ │ ├── Particle Add.shader │ │ │ ├── UI-Default Grey.shader │ │ │ ├── UI-Default.shader │ │ │ ├── Particle MultiplyDouble.shader │ │ │ └── Particle AddMultiply.shader │ ├── SoftMaskModle.cs.meta │ ├── AlphaMaskMaterial.cs.meta │ ├── RectSoftAlphaMask.cs.meta │ ├── Editor │ │ ├── SoftMaskModleEditor.cs.meta │ │ ├── RectSoftAlphaMaskEditor.cs.meta │ │ ├── RectSoftAlphaMaskEditor.cs │ │ └── SoftMaskModleEditor.cs │ ├── AlphaMaskMaterial.cs │ ├── SoftMaskModle.cs │ └── RectSoftAlphaMask.cs ├── Res.meta └── SoftMask.meta └── .gitignore /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.3.3f1 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnityGUISoftMask 2 | Unity GUI架构下,支持UI组件以及特效的软裁剪,使用中如有遇到问题,可发邮件12666146@qq.com联系 3 | -------------------------------------------------------------------------------- /Assets/Res/Canvas.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/Res/Canvas.prefab -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/Res/ui_Bag_bg_1.png -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/Res/ui_Bag_bg_2.png -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/Res/ui_Bag_bg_3.png -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/Res/ui_Bag_bg_4.png -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/Res/ui_Bag_bg_5.png -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/Res/ui_Bag_bg_6.png -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/Res/ui_Bag_bg_7.jpg -------------------------------------------------------------------------------- /Assets/SoftMask/Doc/说明.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/SoftMask/Doc/说明.docx -------------------------------------------------------------------------------- /Assets/SoftMask/test.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/SoftMask/test.unity -------------------------------------------------------------------------------- /Assets/Res/Acceleration.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/Res/Acceleration.prefab -------------------------------------------------------------------------------- /Assets/SoftMask/Doc/Readme.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/SoftMask/Doc/Readme.docx -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /Assets/SoftMask/Scene/testdd.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/Assets/SoftMask/Scene/testdd.unity -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuxiongbin/UnityGUISoftMask/HEAD/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /Assets/SoftMask/Doc/说明.docx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3668aab761b85cc4ab35cf4d106e764a 3 | timeCreated: 1472307572 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SoftMask/test.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67a3b1bc539aedc4b92616f5e1791c32 3 | timeCreated: 1471503153 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Res/Canvas.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe393425accd73341a15db1228821701 3 | timeCreated: 1472310651 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SoftMask/Doc/Readme.docx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62e0887b15a2fbc419246136d9e11d06 3 | timeCreated: 1472309035 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Res/Acceleration.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac34bdc801789084bbe7b1e4a8b7fbb6 3 | timeCreated: 1472309912 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SoftMask/Scene/testdd.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19eb034d1609a184da82744c4f9da85a 3 | timeCreated: 1471525741 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Res.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8d7576d0c6e2ac42ad5692d3d6c44fd 3 | folderAsset: yes 4 | timeCreated: 1472310634 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c297614da618da40bea48b2b28bb8b9 3 | folderAsset: yes 4 | timeCreated: 1471524847 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Doc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4be9b0da1ce7d57408813118f74c8b7d 3 | folderAsset: yes 4 | timeCreated: 1472307549 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Scene.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d517b9f1d56dbc43ba4bef62aabdb80 3 | folderAsset: yes 4 | timeCreated: 1471617285 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11e1d9f3f571cac4582d253689498632 3 | folderAsset: yes 4 | timeCreated: 1471445281 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1ff11c019a40454e9517fb1801a8b64 3 | folderAsset: yes 4 | timeCreated: 1471445223 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e5b3a59f2777c94684f42a8bd8ad804 3 | folderAsset: yes 4 | timeCreated: 1471445223 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle Add.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e7b1840bc7d06040845202ba95f8ece 3 | timeCreated: 1466215902 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/UI-Default.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 995c14c8c2f4bce45af66caaee52cde8 3 | timeCreated: 1471444461 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle Blend.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7db255927f0270c40942f46ecf4ae574 3 | timeCreated: 1466215902 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle Multiply.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d6eaa7926342f34388ddf62f6e3f94b 3 | timeCreated: 1466215903 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/UI-Default Grey.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d354a1fa98d53547a9bcf2dfc886b90 3 | timeCreated: 1471444023 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle AddMultiply.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f2caffade515414791c7d933b13ce8d 3 | timeCreated: 1466215902 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle AddSmooth.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da72a9dd06ceefe47a6c659acdf59f05 3 | timeCreated: 1466215902 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle Alpha Blend.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 062d06bc5da24f048afde932e159d7ea 3 | timeCreated: 1466215902 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle MultiplyDouble.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61dbe436313b58648bfeb5751c914af2 3 | timeCreated: 1466215902 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle Premultiply Blend.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9eb2eb3e49eee5844b6bd762d2bac7d4 3 | timeCreated: 1466215902 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SoftMask/SoftMaskModle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f5cf886fa5df164ca946b9552831c2b 3 | timeCreated: 1471416100 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SoftMask/AlphaMaskMaterial.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39f02dea4bc652b4aa09373c9f63cbeb 3 | timeCreated: 1471445282 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SoftMask/RectSoftAlphaMask.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e78fe7e66016c748a99eed7edda800d 3 | timeCreated: 1471421329 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SoftMask/Editor/SoftMaskModleEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 933cca8c161961441b0ba03fd7faf124 3 | timeCreated: 1471416100 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SoftMask/Editor/RectSoftAlphaMaskEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d08469bed3bb6b4e8af8df314ff6867 3 | timeCreated: 1471421365 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Autogenerated VS/MD solution and project files 9 | ExportedObj/ 10 | *.csproj 11 | *.unityproj 12 | *.sln 13 | *.suo 14 | *.tmp 15 | *.user 16 | *.userprefs 17 | *.pidb 18 | *.booproj 19 | *.svd 20 | 21 | 22 | # Unity3D generated meta files 23 | *.pidb.meta 24 | 25 | # Unity3D Generated File On Crash Reports 26 | sysinfo.txt 27 | 28 | # Builds 29 | *.apk 30 | *.unitypackage 31 | -------------------------------------------------------------------------------- /Assets/SoftMask/Editor/RectSoftAlphaMaskEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections.Generic; 4 | using UnityEngine.UI; 5 | 6 | namespace UI 7 | { 8 | [CustomEditor(typeof(RectSoftAlphaMask))] 9 | public class RectSoftAlphaMaskEditor : Editor 10 | { 11 | public override void OnInspectorGUI() 12 | { 13 | base.OnInspectorGUI(); 14 | 15 | RectSoftAlphaMask mask = target as RectSoftAlphaMask; 16 | Vector4 softEdge = mask.SoftEdge; 17 | 18 | EditorGUILayout.LabelField("软裁剪边"); 19 | GUI.changed = false; 20 | softEdge.x = EditorGUILayout.FloatField("左边", softEdge.x); 21 | softEdge.w = EditorGUILayout.FloatField("顶边", softEdge.w); 22 | softEdge.z = EditorGUILayout.FloatField("右边", softEdge.z); 23 | softEdge.y = EditorGUILayout.FloatField("底边", softEdge.y); 24 | 25 | mask.SoftEdge = softEdge; 26 | 27 | if (GUI.changed) 28 | { 29 | mask.Update(); 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_1.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c08c15ddbd9f834b84219b8d3ff5755 3 | timeCreated: 1469449807 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 1024 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 0 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 1 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 1 49 | textureType: 8 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: Common 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_2.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c63e336c2c1080a4490f839c45301000 3 | timeCreated: 1469449804 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 1024 31 | textureSettings: 32 | filterMode: -1 33 | aniso: 0 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 0 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 1 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 1 49 | textureType: 8 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: NoUsed 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_3.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e4bc96051b8b5c468c80d30c15e8925 3 | timeCreated: 1469449804 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 1024 31 | textureSettings: 32 | filterMode: -1 33 | aniso: 0 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 0 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 1 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 1 49 | textureType: 8 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: NoUsed 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_4.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f19d11af67c6f3c4086b06f80551fbd1 3 | timeCreated: 1469449804 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 1024 31 | textureSettings: 32 | filterMode: -1 33 | aniso: 0 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 0 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 1 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 1 49 | textureType: 8 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: NoUsed 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_5.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36a28e9a5b055214db771597fe9d0599 3 | timeCreated: 1469449805 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 1024 31 | textureSettings: 32 | filterMode: -1 33 | aniso: 0 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 0 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 1 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 1 49 | textureType: 8 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: NoUsed 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_6.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8649bb1390c6cee4798f4b720e1182de 3 | timeCreated: 1469449806 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 1024 31 | textureSettings: 32 | filterMode: -1 33 | aniso: 0 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 0 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 1 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 1 49 | textureType: 8 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: NoUsed 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/Res/ui_Bag_bg_7.jpg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfe3f32c11908a14a8eb19629bfe7a1c 3 | timeCreated: 1469449806 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 1024 31 | textureSettings: 32 | filterMode: -1 33 | aniso: 0 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 0 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 1 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 1 49 | textureType: 8 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: NoUsed 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/SoftMask/Editor/SoftMaskModleEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using System.Collections.Generic; 4 | 5 | namespace UI 6 | { 7 | [CustomEditor(typeof(SoftMaskModle), true)] 8 | public class SoftMaskModleEditor : Editor 9 | { 10 | Vector2 ScrollPosition; 11 | 12 | bool isFoldout = false; 13 | 14 | public override void OnInspectorGUI() 15 | { 16 | SoftMaskModle maskModle = target as SoftMaskModle; 17 | List datas = maskModle.mDatas; 18 | 19 | isFoldout = EditorGUILayout.Foldout(isFoldout, "show"); 20 | if (!isFoldout) 21 | return; 22 | 23 | ScrollPosition = GUILayout.BeginScrollView(ScrollPosition); 24 | for (int i = 0; i < datas.Count; ++i) 25 | { 26 | EditorGUILayout.ObjectField("obj", datas[i].renderer, typeof(Renderer), true); 27 | EditorGUI.indentLevel++; 28 | SoftMaskModle.Data d = datas[i]; 29 | for (int j = 0; j < d.dstMaterials.Length; ++j) 30 | { 31 | Material src = d.srcMaterials[j]; 32 | Material dst = d.dstMaterials[j]; 33 | EditorGUILayout.ObjectField(string.Format("src id:{0}", src == null ? "" : src.GetInstanceID().ToString()), src, typeof(Material), true); 34 | EditorGUILayout.ObjectField(string.Format("dst id:{0}", dst == null ? "" : dst.GetInstanceID().ToString()), dst, typeof(Material), true); 35 | } 36 | EditorGUI.indentLevel--; 37 | } 38 | 39 | GUILayout.EndScrollView(); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Assets/SoftMask/AlphaMaskMaterial.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine.UI; 5 | 6 | namespace UI 7 | { 8 | public class AlphaMaskMaterial : MonoBehaviour, IMaterialModifier 9 | { 10 | public RectSoftAlphaMask rectParent; 11 | Graphic graphic_; 12 | 13 | Graphic graphic 14 | { 15 | get 16 | { 17 | if (graphic_ == null) 18 | graphic_ = GetComponent(); 19 | return graphic_; 20 | } 21 | } 22 | 23 | void Awake() 24 | { 25 | if (graphic == null) 26 | Destroy(this); 27 | } 28 | 29 | void OnEnable() 30 | { 31 | if (graphic != null) 32 | graphic.SetMaterialDirty(); 33 | } 34 | 35 | void OnDisable() 36 | { 37 | if (graphic != null) 38 | graphic.SetMaterialDirty(); 39 | } 40 | 41 | public void SetMaterialDirty() 42 | { 43 | if (graphic != null) 44 | graphic.SetMaterialDirty(); 45 | } 46 | 47 | public Material GetModifiedMaterial(Material baseMaterial) 48 | { 49 | if (!enabled) 50 | return baseMaterial; 51 | 52 | if (rectParent == null) 53 | { 54 | rectParent = GetComponentInParent(); 55 | if (rectParent == null) 56 | { 57 | #if UNITY_EDITOR 58 | if (Application.isEditor) 59 | Object.DestroyImmediate(this); 60 | else 61 | Object.Destroy(this); 62 | #else 63 | Object.Destroy(this); 64 | #endif 65 | return baseMaterial; 66 | } 67 | } 68 | 69 | if (!rectParent.enabled) 70 | return baseMaterial; 71 | 72 | return rectParent.GetDefaultMaterial(baseMaterial); 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle Premultiply Blend.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Alpha Blended Premultiply Soft Mask" { 2 | Properties { 3 | _MainTex ("Particle Texture", 2D) = "white" {} 4 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 5 | 6 | _Min("Min",Vector) = (0,0,0,0) 7 | _Max("Max",Vector) = (1,1,0,0) 8 | _SoftEdge("SoftEdge", Vector) = (1,1,1,1) 9 | } 10 | 11 | Category { 12 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 13 | Blend One OneMinusSrcAlpha 14 | ColorMask RGB 15 | Cull Off Lighting Off ZWrite Off 16 | 17 | SubShader { 18 | Pass { 19 | 20 | CGPROGRAM 21 | #pragma vertex vert 22 | #pragma fragment frag 23 | #pragma multi_compile_particles 24 | #pragma target 3.0 25 | 26 | #include "UnityCG.cginc" 27 | 28 | sampler2D _MainTex; 29 | fixed4 _TintColor; 30 | 31 | struct appdata_t { 32 | float4 vertex : POSITION; 33 | fixed4 color : COLOR; 34 | float2 texcoord : TEXCOORD0; 35 | }; 36 | 37 | struct v2f { 38 | float4 vertex : SV_POSITION; 39 | fixed4 color : COLOR; 40 | float2 texcoord : TEXCOORD0; 41 | //#ifdef SOFTPARTICLES_ON 42 | //float4 projPos : TEXCOORD1; 43 | //#endif 44 | 45 | float4 worldPosition : TEXCOORD2; 46 | float4 worldPosition2 : COLOR1; 47 | }; 48 | 49 | float4 _MainTex_ST; 50 | 51 | v2f vert (appdata_t v) 52 | { 53 | v2f o; 54 | o.worldPosition = v.vertex; 55 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 56 | o.worldPosition2 = mul(_Object2World, v.vertex); 57 | 58 | //#ifdef SOFTPARTICLES_ON 59 | //o.projPos = ComputeScreenPos (o.vertex); 60 | //COMPUTE_EYEDEPTH(o.projPos.z); 61 | //#endif 62 | o.color = v.color; 63 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 64 | return o; 65 | } 66 | 67 | sampler2D_float _CameraDepthTexture; 68 | float _InvFade; 69 | 70 | float2 _Min; 71 | float2 _Max; 72 | float4 _SoftEdge; 73 | 74 | fixed4 frag (v2f i) : SV_Target 75 | { 76 | half4 color = i.color * tex2D(_MainTex, i.texcoord) * i.color.a; 77 | float alpha = 0; 78 | //return color; 79 | if (i.worldPosition2.x <= _Min.x || i.worldPosition2.x >= _Max.x || i.worldPosition2.y <= _Min.y || i.worldPosition2.y >= _Max.y) 80 | { 81 | alpha = 0; 82 | } 83 | else // It's in the mask rectangle, so apply the alpha of the mask provided. 84 | { 85 | alpha = 1; 86 | if (i.worldPosition2.x - _Min.x < _SoftEdge.x) 87 | alpha *= (i.worldPosition2.x - _Min.x) / _SoftEdge.x; 88 | else if (_Max.x - i.worldPosition2.x < _SoftEdge.z) 89 | alpha *= (_Max.x - i.worldPosition2.x) / _SoftEdge.z; 90 | 91 | if (i.worldPosition2.y - _Min.y < _SoftEdge.y) 92 | alpha *= (i.worldPosition2.y - _Min.y) / _SoftEdge.y; 93 | else if (_Max.y - i.worldPosition2.y < _SoftEdge.w) 94 | alpha *= (_Max.y - i.worldPosition2.y) / _SoftEdge.w; 95 | } 96 | 97 | color *= alpha; 98 | return color; 99 | } 100 | ENDCG 101 | } 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle Blend.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Blend Soft Mask" { 2 | Properties { 3 | _MainTex ("Particle Texture", 2D) = "white" {} 4 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 5 | 6 | _Min("Min",Vector) = (0,0,0,0) 7 | _Max("Max",Vector) = (1,1,0,0) 8 | _SoftEdge("SoftEdge", Vector) = (1,1,1,1) 9 | } 10 | 11 | Category { 12 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 13 | Blend DstColor One 14 | ColorMask RGB 15 | Cull Off Lighting Off ZWrite Off 16 | 17 | SubShader { 18 | Pass { 19 | 20 | CGPROGRAM 21 | #pragma vertex vert 22 | #pragma fragment frag 23 | #pragma target 3.0 24 | 25 | #include "UnityCG.cginc" 26 | 27 | sampler2D _MainTex; 28 | fixed4 _TintColor; 29 | 30 | struct appdata_t { 31 | float4 vertex : POSITION; 32 | fixed4 color : COLOR; 33 | float2 texcoord : TEXCOORD0; 34 | }; 35 | 36 | struct v2f { 37 | float4 vertex : SV_POSITION; 38 | fixed4 color : COLOR; 39 | float2 texcoord : TEXCOORD0; 40 | UNITY_FOG_COORDS(1) 41 | //#ifdef SOFTPARTICLES_ON 42 | //float4 projPos : TEXCOORD2; 43 | //#endif 44 | 45 | float4 worldPosition : TEXCOORD1; 46 | float4 worldPosition2 : COLOR1; 47 | }; 48 | 49 | float4 _MainTex_ST; 50 | 51 | v2f vert (appdata_t v) 52 | { 53 | v2f o; 54 | o.worldPosition = v.vertex; 55 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 56 | o.worldPosition2 = mul(_Object2World, v.vertex); 57 | //#ifdef SOFTPARTICLES_ON 58 | //o.projPos = ComputeScreenPos (o.vertex); 59 | //COMPUTE_EYEDEPTH(o.projPos.z); 60 | //#endif 61 | o.color = v.color; 62 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 63 | UNITY_TRANSFER_FOG(o,o.vertex); 64 | return o; 65 | } 66 | 67 | sampler2D_float _CameraDepthTexture; 68 | float _InvFade; 69 | 70 | float2 _Min; 71 | float2 _Max; 72 | float4 _SoftEdge; 73 | fixed4 frag (v2f i) : SV_Target 74 | { 75 | fixed4 col = i.color * tex2D(_MainTex, i.texcoord); 76 | UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode 77 | 78 | float alpha = 0; 79 | //return color; 80 | if (i.worldPosition2.x <= _Min.x || i.worldPosition2.x >= _Max.x || i.worldPosition2.y <= _Min.y || i.worldPosition2.y >= _Max.y) 81 | { 82 | alpha = 0; 83 | } 84 | else // It's in the mask rectangle, so apply the alpha of the mask provided. 85 | { 86 | alpha = 1; 87 | if (i.worldPosition2.x - _Min.x < _SoftEdge.x) 88 | alpha *= (i.worldPosition2.x - _Min.x) / _SoftEdge.x; 89 | else if (_Max.x - i.worldPosition2.x < _SoftEdge.z) 90 | alpha *= (_Max.x - i.worldPosition2.x) / _SoftEdge.z; 91 | 92 | if (i.worldPosition2.y - _Min.y < _SoftEdge.y) 93 | alpha *= (i.worldPosition2.y - _Min.y) / _SoftEdge.y; 94 | else if (_Max.y - i.worldPosition2.y < _SoftEdge.w) 95 | alpha *= (_Max.y - i.worldPosition2.y) / _SoftEdge.w; 96 | } 97 | 98 | col *= alpha; 99 | 100 | return col; 101 | } 102 | ENDCG 103 | } 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle Multiply.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Multiply Soft Mask" { 2 | Properties { 3 | _MainTex ("Particle Texture", 2D) = "white" {} 4 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 5 | 6 | _Min("Min",Vector) = (0,0,0,0) 7 | _Max("Max",Vector) = (1,1,0,0) 8 | _SoftEdge("SoftEdge", Vector) = (1,1,1,1) 9 | } 10 | 11 | Category { 12 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 13 | Blend Zero SrcColor 14 | Cull Off Lighting Off ZWrite Off 15 | 16 | SubShader { 17 | Pass { 18 | 19 | CGPROGRAM 20 | #pragma vertex vert 21 | #pragma fragment frag 22 | #pragma target 3.0 23 | 24 | #include "UnityCG.cginc" 25 | 26 | sampler2D _MainTex; 27 | fixed4 _TintColor; 28 | 29 | struct appdata_t { 30 | float4 vertex : POSITION; 31 | fixed4 color : COLOR; 32 | float2 texcoord : TEXCOORD0; 33 | }; 34 | 35 | struct v2f { 36 | float4 vertex : SV_POSITION; 37 | fixed4 color : COLOR; 38 | float2 texcoord : TEXCOORD0; 39 | UNITY_FOG_COORDS(1) 40 | //#ifdef SOFTPARTICLES_ON 41 | //float4 projPos : TEXCOORD2; 42 | //#endif 43 | 44 | float4 worldPosition : TEXCOORD1; 45 | float4 worldPosition2 : COLOR1; 46 | }; 47 | 48 | float4 _MainTex_ST; 49 | 50 | v2f vert (appdata_t v) 51 | { 52 | v2f o; 53 | o.worldPosition = v.vertex; 54 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 55 | o.worldPosition2 = mul(_Object2World, v.vertex); 56 | //#ifdef SOFTPARTICLES_ON 57 | //o.projPos = ComputeScreenPos (o.vertex); 58 | //COMPUTE_EYEDEPTH(o.projPos.z); 59 | //#endif 60 | o.color = v.color; 61 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 62 | UNITY_TRANSFER_FOG(o,o.vertex); 63 | return o; 64 | } 65 | 66 | sampler2D_float _CameraDepthTexture; 67 | float _InvFade; 68 | 69 | float2 _Min; 70 | float2 _Max; 71 | float4 _SoftEdge; 72 | fixed4 frag (v2f i) : SV_Target 73 | { 74 | half4 prev = i.color * tex2D(_MainTex, i.texcoord); 75 | fixed4 col = lerp(half4(1,1,1,1), prev, prev.a); 76 | UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(1,1,1,1)); // fog towards white due to our blend mode 77 | 78 | float alpha = 0; 79 | //return color; 80 | if (i.worldPosition2.x <= _Min.x || i.worldPosition2.x >= _Max.x || i.worldPosition2.y <= _Min.y || i.worldPosition2.y >= _Max.y) 81 | { 82 | alpha = 0; 83 | } 84 | else // It's in the mask rectangle, so apply the alpha of the mask provided. 85 | { 86 | alpha = 1; 87 | if (i.worldPosition2.x - _Min.x < _SoftEdge.x) 88 | alpha *= (i.worldPosition2.x - _Min.x) / _SoftEdge.x; 89 | else if (_Max.x - i.worldPosition2.x < _SoftEdge.z) 90 | alpha *= (_Max.x - i.worldPosition2.x) / _SoftEdge.z; 91 | 92 | if (i.worldPosition2.y - _Min.y < _SoftEdge.y) 93 | alpha *= (i.worldPosition2.y - _Min.y) / _SoftEdge.y; 94 | else if (_Max.y - i.worldPosition2.y < _SoftEdge.w) 95 | alpha *= (_Max.y - i.worldPosition2.y) / _SoftEdge.w; 96 | } 97 | 98 | col *= alpha; 99 | 100 | return col; 101 | } 102 | ENDCG 103 | } 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle AddSmooth.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Additive (Soft) Soft Mask" { 2 | Properties { 3 | _MainTex ("Particle Texture", 2D) = "white" {} 4 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 5 | 6 | _Min("Min",Vector) = (0,0,0,0) 7 | _Max("Max",Vector) = (1,1,0,0) 8 | _SoftEdge("SoftEdge", Vector) = (1,1,1,1) 9 | } 10 | 11 | Category { 12 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 13 | Blend One OneMinusSrcColor 14 | ColorMask RGB 15 | Cull Off Lighting Off ZWrite Off 16 | 17 | SubShader { 18 | Pass { 19 | 20 | CGPROGRAM 21 | #pragma vertex vert 22 | #pragma fragment frag 23 | #pragma target 3.0 24 | 25 | #include "UnityCG.cginc" 26 | 27 | sampler2D _MainTex; 28 | fixed4 _TintColor; 29 | 30 | struct appdata_t { 31 | float4 vertex : POSITION; 32 | fixed4 color : COLOR; 33 | float2 texcoord : TEXCOORD0; 34 | }; 35 | 36 | struct v2f { 37 | float4 vertex : SV_POSITION; 38 | fixed4 color : COLOR; 39 | float2 texcoord : TEXCOORD0; 40 | UNITY_FOG_COORDS(1) 41 | //#ifdef SOFTPARTICLES_ON 42 | //float4 projPos : TEXCOORD2; 43 | //#endif 44 | 45 | float4 worldPosition : TEXCOORD1; 46 | float4 worldPosition2 : COLOR1; 47 | }; 48 | 49 | float4 _MainTex_ST; 50 | 51 | v2f vert (appdata_t v) 52 | { 53 | v2f o; 54 | o.worldPosition = v.vertex; 55 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 56 | o.worldPosition2 = mul(_Object2World, v.vertex); 57 | //#ifdef SOFTPARTICLES_ON 58 | //o.projPos = ComputeScreenPos (o.vertex); 59 | //COMPUTE_EYEDEPTH(o.projPos.z); 60 | //#endif 61 | o.color = v.color; 62 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 63 | UNITY_TRANSFER_FOG(o,o.vertex); 64 | return o; 65 | } 66 | 67 | sampler2D_float _CameraDepthTexture; 68 | float _InvFade; 69 | 70 | float2 _Min; 71 | float2 _Max; 72 | float4 _SoftEdge; 73 | 74 | fixed4 frag (v2f i) : SV_Target 75 | { 76 | half4 col = i.color * tex2D(_MainTex, i.texcoord); 77 | col.rgb *= col.a; 78 | UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode 79 | 80 | float alpha = 0; 81 | //return color; 82 | if (i.worldPosition2.x <= _Min.x || i.worldPosition2.x >= _Max.x || i.worldPosition2.y <= _Min.y || i.worldPosition2.y >= _Max.y) 83 | { 84 | alpha = 0; 85 | } 86 | else // It's in the mask rectangle, so apply the alpha of the mask provided. 87 | { 88 | alpha = 1; 89 | if (i.worldPosition2.x - _Min.x < _SoftEdge.x) 90 | alpha *= (i.worldPosition2.x - _Min.x) / _SoftEdge.x; 91 | else if (_Max.x - i.worldPosition2.x < _SoftEdge.z) 92 | alpha *= (_Max.x - i.worldPosition2.x) / _SoftEdge.z; 93 | 94 | if (i.worldPosition2.y - _Min.y < _SoftEdge.y) 95 | alpha *= (i.worldPosition2.y - _Min.y) / _SoftEdge.y; 96 | else if (_Max.y - i.worldPosition2.y < _SoftEdge.w) 97 | alpha *= (_Max.y - i.worldPosition2.y) / _SoftEdge.w; 98 | } 99 | 100 | col *= alpha; 101 | return col; 102 | } 103 | ENDCG 104 | } 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle Alpha Blend.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Alpha Blended Soft Mask" { 2 | Properties { 3 | _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) 4 | _MainTex ("Particle Texture", 2D) = "white" {} 5 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 6 | 7 | _Min("Min",Vector) = (0,0,0,0) 8 | _Max("Max",Vector) = (1,1,0,0) 9 | _SoftEdge("SoftEdge", Vector) = (1,1,1,1) 10 | } 11 | 12 | Category { 13 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 14 | Blend SrcAlpha OneMinusSrcAlpha 15 | ColorMask RGB 16 | Cull Off Lighting Off ZWrite Off 17 | 18 | SubShader { 19 | Pass { 20 | 21 | CGPROGRAM 22 | #pragma vertex vert 23 | #pragma fragment frag 24 | #pragma target 3.0 25 | 26 | #include "UnityCG.cginc" 27 | 28 | sampler2D _MainTex; 29 | fixed4 _TintColor; 30 | 31 | struct appdata_t { 32 | float4 vertex : POSITION; 33 | fixed4 color : COLOR; 34 | float2 texcoord : TEXCOORD0; 35 | }; 36 | 37 | struct v2f { 38 | float4 vertex : SV_POSITION; 39 | fixed4 color : COLOR; 40 | float2 texcoord : TEXCOORD0; 41 | UNITY_FOG_COORDS(1) 42 | //#ifdef SOFTPARTICLES_ON 43 | //float4 projPos : TEXCOORD2; 44 | //#endif 45 | 46 | float4 worldPosition : TEXCOORD1; 47 | float4 worldPosition2 : COLOR1; 48 | }; 49 | 50 | float4 _MainTex_ST; 51 | 52 | v2f vert (appdata_t v) 53 | { 54 | v2f o; 55 | o.worldPosition = v.vertex; 56 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 57 | o.worldPosition2 = mul(_Object2World, v.vertex); 58 | 59 | //#ifdef SOFTPARTICLES_ON 60 | //o.projPos = ComputeScreenPos (o.vertex); 61 | //COMPUTE_EYEDEPTH(o.projPos.z); 62 | //#endif 63 | o.color = v.color; 64 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 65 | UNITY_TRANSFER_FOG(o,o.vertex); 66 | return o; 67 | } 68 | 69 | sampler2D_float _CameraDepthTexture; 70 | float _InvFade; 71 | 72 | float2 _Min; 73 | float2 _Max; 74 | float4 _SoftEdge; 75 | 76 | fixed4 frag (v2f i) : SV_Target 77 | { 78 | fixed4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord); 79 | UNITY_APPLY_FOG(i.fogCoord, col); 80 | 81 | float alpha = 0; 82 | //return color; 83 | if (i.worldPosition2.x <= _Min.x || i.worldPosition2.x >= _Max.x || i.worldPosition2.y <= _Min.y || i.worldPosition2.y >= _Max.y) 84 | { 85 | alpha = 0; 86 | } 87 | else // It's in the mask rectangle, so apply the alpha of the mask provided. 88 | { 89 | alpha = 1; 90 | if (i.worldPosition2.x - _Min.x < _SoftEdge.x) 91 | alpha *= (i.worldPosition2.x - _Min.x) / _SoftEdge.x; 92 | else if (_Max.x - i.worldPosition2.x < _SoftEdge.z) 93 | alpha *= (_Max.x - i.worldPosition2.x) / _SoftEdge.z; 94 | 95 | if (i.worldPosition2.y - _Min.y < _SoftEdge.y) 96 | alpha *= (i.worldPosition2.y - _Min.y) / _SoftEdge.y; 97 | else if (_Max.y - i.worldPosition2.y < _SoftEdge.w) 98 | alpha *= (_Max.y - i.worldPosition2.y) / _SoftEdge.w; 99 | } 100 | 101 | col *= alpha; 102 | 103 | return col; 104 | } 105 | ENDCG 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle Add.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Additive Soft Mask" { 2 | Properties { 3 | _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) 4 | _MainTex ("Particle Texture", 2D) = "white" {} 5 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 6 | 7 | _Min("Min",Vector) = (0,0,0,0) 8 | _Max("Max",Vector) = (1,1,0,0) 9 | _SoftEdge("SoftEdge", Vector) = (1,1,1,1) 10 | } 11 | 12 | Category { 13 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 14 | Blend SrcAlpha One 15 | ColorMask RGB 16 | Cull Off Lighting Off ZWrite Off 17 | 18 | SubShader { 19 | Pass { 20 | 21 | CGPROGRAM 22 | #pragma vertex vert 23 | #pragma fragment frag 24 | #pragma target 3.0 25 | 26 | #include "UnityCG.cginc" 27 | 28 | sampler2D _MainTex; 29 | fixed4 _TintColor; 30 | 31 | struct appdata_t { 32 | float4 vertex : POSITION; 33 | fixed4 color : COLOR; 34 | float2 texcoord : TEXCOORD0; 35 | }; 36 | 37 | struct v2f { 38 | float4 vertex : SV_POSITION; 39 | fixed4 color : COLOR; 40 | float2 texcoord : TEXCOORD0; 41 | UNITY_FOG_COORDS(1) 42 | //#ifdef SOFTPARTICLES_ON 43 | //float4 projPos : TEXCOORD2; 44 | //#endif 45 | 46 | float4 worldPosition : TEXCOORD1; 47 | float4 worldPosition2 : COLOR1; 48 | }; 49 | 50 | float4 _MainTex_ST; 51 | 52 | v2f vert (appdata_t v) 53 | { 54 | v2f o; 55 | o.worldPosition = v.vertex; 56 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 57 | o.worldPosition2 = mul(_Object2World, v.vertex); 58 | //#ifdef SOFTPARTICLES_ON 59 | //o.projPos = ComputeScreenPos (o.vertex); 60 | //COMPUTE_EYEDEPTH(o.projPos.z); 61 | //#endif 62 | o.color = v.color; 63 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 64 | UNITY_TRANSFER_FOG(o,o.vertex); 65 | return o; 66 | } 67 | 68 | sampler2D_float _CameraDepthTexture; 69 | float _InvFade; 70 | 71 | float2 _Min; 72 | float2 _Max; 73 | float4 _SoftEdge; 74 | 75 | fixed4 frag (v2f i) : SV_Target 76 | { 77 | fixed4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord); 78 | UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode 79 | 80 | float alpha = 0; 81 | //return color; 82 | if (i.worldPosition2.x <= _Min.x || i.worldPosition2.x >= _Max.x || i.worldPosition2.y <= _Min.y || i.worldPosition2.y >= _Max.y) 83 | { 84 | alpha = 0; 85 | } 86 | else // It's in the mask rectangle, so apply the alpha of the mask provided. 87 | { 88 | alpha = 1; 89 | if (i.worldPosition2.x - _Min.x < _SoftEdge.x) 90 | alpha *= (i.worldPosition2.x - _Min.x) / _SoftEdge.x; 91 | else if (_Max.x - i.worldPosition2.x < _SoftEdge.z) 92 | alpha *= (_Max.x - i.worldPosition2.x) / _SoftEdge.z; 93 | 94 | if (i.worldPosition2.y - _Min.y < _SoftEdge.y) 95 | alpha *= (i.worldPosition2.y - _Min.y) / _SoftEdge.y; 96 | else if (_Max.y - i.worldPosition2.y < _SoftEdge.w) 97 | alpha *= (_Max.y - i.worldPosition2.y) / _SoftEdge.w; 98 | } 99 | 100 | col *= alpha; 101 | return col; 102 | } 103 | ENDCG 104 | } 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/UI-Default Grey.shader: -------------------------------------------------------------------------------- 1 | Shader "UI/Default Grey Soft Mask" 2 | { 3 | Properties 4 | { 5 | [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {} 6 | _Color ("Tint", Color) = (1,1,1,1) 7 | 8 | _Min("Min",Vector) = (0,0,0,0) 9 | _Max("Max",Vector) = (1,1,0,0) 10 | _SoftEdge("SoftEdge", Vector) = (1,1,1,1) 11 | } 12 | 13 | SubShader 14 | { 15 | Tags 16 | { 17 | "Queue"="Transparent" 18 | "IgnoreProjector"="True" 19 | "RenderType"="Transparent" 20 | "PreviewType"="Plane" 21 | "CanUseSpriteAtlas"="True" 22 | } 23 | 24 | Cull Off 25 | Lighting Off 26 | ZWrite Off 27 | ZTest [unity_GUIZTestMode] 28 | Blend SrcAlpha OneMinusSrcAlpha 29 | 30 | Pass 31 | { 32 | CGPROGRAM 33 | #pragma vertex vert 34 | #pragma fragment frag 35 | #pragma target 3.0 36 | 37 | #include "UnityCG.cginc" 38 | #include "UnityUI.cginc" 39 | 40 | #pragma multi_compile __ UNITY_UI_ALPHACLIP 41 | 42 | struct appdata_t 43 | { 44 | float4 vertex : POSITION; 45 | float4 color : COLOR; 46 | float2 texcoord : TEXCOORD0; 47 | }; 48 | 49 | struct v2f 50 | { 51 | float4 vertex : SV_POSITION; 52 | fixed4 color : COLOR; 53 | half2 texcoord : TEXCOORD0; 54 | float4 worldPosition : TEXCOORD1; 55 | float4 worldPosition2 : COLOR1; 56 | }; 57 | 58 | fixed4 _Color; 59 | fixed4 _TextureSampleAdd; 60 | float4 _ClipRect; 61 | float2 _Min; 62 | float2 _Max; 63 | float4 _SoftEdge; 64 | 65 | v2f vert(appdata_t IN) 66 | { 67 | v2f OUT; 68 | OUT.worldPosition = IN.vertex; 69 | OUT.vertex = mul(UNITY_MATRIX_MVP, OUT.worldPosition); 70 | OUT.worldPosition2 = mul(_Object2World, IN.vertex); 71 | 72 | OUT.texcoord = IN.texcoord; 73 | 74 | #ifdef UNITY_HALF_TEXEL_OFFSET 75 | OUT.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1); 76 | #endif 77 | 78 | OUT.color = IN.color * _Color; 79 | return OUT; 80 | } 81 | 82 | sampler2D _MainTex; 83 | 84 | fixed4 frag(v2f IN) : SV_Target 85 | { 86 | half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color; 87 | 88 | color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect); 89 | 90 | float alpha = 0; 91 | if (IN.worldPosition2.x <= _Min.x || IN.worldPosition2.x >= _Max.x || IN.worldPosition2.y <= _Min.y || IN.worldPosition2.y >= _Max.y) 92 | { 93 | alpha = 0; 94 | } 95 | else // It's in the mask rectangle, so apply the alpha of the mask provided. 96 | { 97 | alpha = 1; 98 | if (IN.worldPosition2.x - _Min.x < _SoftEdge.x) 99 | alpha *= (IN.worldPosition2.x - _Min.x) / _SoftEdge.x; 100 | else if (_Max.x - IN.worldPosition2.x < _SoftEdge.z) 101 | alpha *= (_Max.x - IN.worldPosition2.x) / _SoftEdge.z; 102 | 103 | if (IN.worldPosition2.y - _Min.y < _SoftEdge.y) 104 | alpha *= (IN.worldPosition2.y - _Min.y) / _SoftEdge.y; 105 | else if (_Max.y - IN.worldPosition2.y < _SoftEdge.w) 106 | alpha *= (_Max.y - IN.worldPosition2.y) / _SoftEdge.w; 107 | } 108 | 109 | float grey = dot(color.rgb, fixed3(0.22, 0.707, 0.071)); 110 | return half4(grey, grey, grey, color.a * alpha); 111 | } 112 | ENDCG 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/UI-Default.shader: -------------------------------------------------------------------------------- 1 | Shader "UI/Default Soft Mask" 2 | { 3 | Properties 4 | { 5 | [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {} 6 | _Color ("Tint", Color) = (1,1,1,1) 7 | 8 | 9 | _Min("Min",Vector) = (0,0,0,0) 10 | _Max("Max",Vector) = (1,1,0,0) 11 | _SoftEdge("SoftEdge", Vector) = (1,1,1,1) 12 | } 13 | 14 | SubShader 15 | { 16 | Tags 17 | { 18 | "Queue"="Transparent" 19 | "IgnoreProjector"="True" 20 | "RenderType"="Transparent" 21 | "PreviewType"="Plane" 22 | "CanUseSpriteAtlas"="True" 23 | } 24 | 25 | Cull Off 26 | Lighting Off 27 | ZWrite Off 28 | ZTest [unity_GUIZTestMode] 29 | Blend SrcAlpha OneMinusSrcAlpha 30 | 31 | Pass 32 | { 33 | Name "Default" 34 | CGPROGRAM 35 | #pragma vertex vert 36 | #pragma fragment frag 37 | #pragma target 3.0 38 | 39 | #include "UnityCG.cginc" 40 | #include "UnityUI.cginc" 41 | 42 | #pragma multi_compile __ UNITY_UI_ALPHACLIP 43 | 44 | struct appdata_t 45 | { 46 | float4 vertex : POSITION; 47 | float4 color : COLOR; 48 | float2 texcoord : TEXCOORD0; 49 | }; 50 | 51 | struct v2f 52 | { 53 | float4 vertex : SV_POSITION; 54 | fixed4 color : COLOR; 55 | half2 texcoord : TEXCOORD0; 56 | float4 worldPosition : TEXCOORD1; 57 | 58 | float4 worldPosition2 : COLOR1; 59 | }; 60 | 61 | fixed4 _Color; 62 | fixed4 _TextureSampleAdd; 63 | float4 _ClipRect; 64 | float2 _Min; 65 | float2 _Max; 66 | float4 _SoftEdge; 67 | v2f vert(appdata_t IN) 68 | { 69 | v2f OUT; 70 | OUT.worldPosition = IN.vertex; 71 | OUT.vertex = mul(UNITY_MATRIX_MVP, OUT.worldPosition); 72 | OUT.worldPosition2 = mul(_Object2World, IN.vertex); 73 | 74 | OUT.texcoord = IN.texcoord; 75 | 76 | #ifdef UNITY_HALF_TEXEL_OFFSET 77 | OUT.vertex.xy += (_ScreenParams.zw-1.0) * float2(-1,1) * OUT.vertex.w; 78 | #endif 79 | 80 | OUT.color = IN.color * _Color; 81 | return OUT; 82 | } 83 | 84 | sampler2D _MainTex; 85 | 86 | fixed4 frag(v2f IN) : SV_Target 87 | { 88 | half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color; 89 | 90 | color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect); 91 | 92 | float alpha = 0; 93 | if (IN.worldPosition2.x <= _Min.x || IN.worldPosition2.x >= _Max.x || IN.worldPosition2.y <= _Min.y || IN.worldPosition2.y >= _Max.y) 94 | { 95 | alpha = 0; 96 | } 97 | else // It's in the mask rectangle, so apply the alpha of the mask provided. 98 | { 99 | alpha = 1; 100 | if (IN.worldPosition2.x - _Min.x < _SoftEdge.x) 101 | alpha *= (IN.worldPosition2.x - _Min.x) / _SoftEdge.x; 102 | else if (_Max.x - IN.worldPosition2.x < _SoftEdge.z) 103 | alpha *= (_Max.x - IN.worldPosition2.x) / _SoftEdge.z; 104 | 105 | if (IN.worldPosition2.y - _Min.y < _SoftEdge.y) 106 | alpha *= (IN.worldPosition2.y - _Min.y) / _SoftEdge.y; 107 | else if (_Max.y - IN.worldPosition2.y < _SoftEdge.w) 108 | alpha *= (_Max.y - IN.worldPosition2.y) / _SoftEdge.w; 109 | } 110 | 111 | color.a *= alpha; 112 | 113 | #ifdef UNITY_UI_ALPHACLIP 114 | clip (color.a - 0.001); 115 | #endif 116 | 117 | return color; 118 | } 119 | ENDCG 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle MultiplyDouble.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/Multiply (Double) Soft Mask" { 2 | Properties { 3 | _MainTex ("Particle Texture", 2D) = "white" {} 4 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 5 | 6 | _Min("Min",Vector) = (0,0,0,0) 7 | _Max("Max",Vector) = (1,1,0,0) 8 | _SoftEdge("SoftEdge", Vector) = (1,1,1,1) 9 | } 10 | 11 | Category { 12 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 13 | Blend DstColor SrcColor 14 | ColorMask RGB 15 | Cull Off Lighting Off ZWrite Off 16 | 17 | SubShader { 18 | Pass { 19 | 20 | CGPROGRAM 21 | #pragma vertex vert 22 | #pragma fragment frag 23 | #pragma target 3.0 24 | 25 | #include "UnityCG.cginc" 26 | 27 | sampler2D _MainTex; 28 | fixed4 _TintColor; 29 | 30 | struct appdata_t { 31 | float4 vertex : POSITION; 32 | fixed4 color : COLOR; 33 | float2 texcoord : TEXCOORD0; 34 | }; 35 | 36 | struct v2f { 37 | float4 vertex : SV_POSITION; 38 | fixed4 color : COLOR; 39 | float2 texcoord : TEXCOORD0; 40 | UNITY_FOG_COORDS(1) 41 | //#ifdef SOFTPARTICLES_ON 42 | //float4 projPos : TEXCOORD2; 43 | //#endif 44 | 45 | float4 worldPosition : TEXCOORD1; 46 | float4 worldPosition2 : COLOR1; 47 | }; 48 | 49 | float4 _MainTex_ST; 50 | 51 | v2f vert (appdata_t v) 52 | { 53 | v2f o; 54 | o.worldPosition = v.vertex; 55 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 56 | o.worldPosition2 = mul(_Object2World, v.vertex); 57 | 58 | //#ifdef SOFTPARTICLES_ON 59 | //o.projPos = ComputeScreenPos (o.vertex); 60 | //COMPUTE_EYEDEPTH(o.projPos.z); 61 | //#endif 62 | o.color = v.color; 63 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 64 | UNITY_TRANSFER_FOG(o,o.vertex); 65 | return o; 66 | } 67 | 68 | sampler2D_float _CameraDepthTexture; 69 | float _InvFade; 70 | 71 | float2 _Min; 72 | float2 _Max; 73 | float4 _SoftEdge; 74 | fixed4 frag (v2f i) : SV_Target 75 | { 76 | fixed4 col; 77 | fixed4 tex = tex2D(_MainTex, i.texcoord); 78 | col.rgb = tex.rgb * i.color.rgb * 2; 79 | col.a = i.color.a * tex.a; 80 | col = lerp(fixed4(0.5f,0.5f,0.5f,0.5f), col, col.a); 81 | UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0.5,0.5,0.5,0.5)); // fog towards gray due to our blend mode 82 | 83 | float alpha = 0; 84 | //return color; 85 | if (i.worldPosition2.x <= _Min.x || i.worldPosition2.x >= _Max.x || i.worldPosition2.y <= _Min.y || i.worldPosition2.y >= _Max.y) 86 | { 87 | alpha = 0; 88 | } 89 | else // It's in the mask rectangle, so apply the alpha of the mask provided. 90 | { 91 | alpha = 1; 92 | if (i.worldPosition2.x - _Min.x < _SoftEdge.x) 93 | alpha *= (i.worldPosition2.x - _Min.x) / _SoftEdge.x; 94 | else if (_Max.x - i.worldPosition2.x < _SoftEdge.z) 95 | alpha *= (_Max.x - i.worldPosition2.x) / _SoftEdge.z; 96 | 97 | if (i.worldPosition2.y - _Min.y < _SoftEdge.y) 98 | alpha *= (i.worldPosition2.y - _Min.y) / _SoftEdge.y; 99 | else if (_Max.y - i.worldPosition2.y < _SoftEdge.w) 100 | alpha *= (_Max.y - i.worldPosition2.y) / _SoftEdge.w; 101 | } 102 | 103 | col *= alpha; 104 | 105 | return col; 106 | } 107 | ENDCG 108 | } 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Assets/SoftMask/Resources/Shader/Particle AddMultiply.shader: -------------------------------------------------------------------------------- 1 | Shader "Particles/~Additive-Multiply Soft Mask" { 2 | Properties { 3 | _TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5) 4 | _MainTex ("Particle Texture", 2D) = "white" {} 5 | _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 6 | 7 | _Min("Min",Vector) = (0,0,0,0) 8 | _Max("Max",Vector) = (1,1,0,0) 9 | _SoftEdge("SoftEdge", Vector) = (1,1,1,1) 10 | } 11 | 12 | Category { 13 | Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 14 | Blend One OneMinusSrcAlpha 15 | ColorMask RGB 16 | Cull Off Lighting Off ZWrite Off 17 | 18 | SubShader { 19 | Pass { 20 | 21 | CGPROGRAM 22 | #pragma vertex vert 23 | #pragma fragment frag 24 | #pragma target 3.0 25 | 26 | #include "UnityCG.cginc" 27 | 28 | sampler2D _MainTex; 29 | fixed4 _TintColor; 30 | 31 | struct appdata_t { 32 | float4 vertex : POSITION; 33 | fixed4 color : COLOR; 34 | float2 texcoord : TEXCOORD0; 35 | }; 36 | 37 | struct v2f { 38 | float4 vertex : SV_POSITION; 39 | fixed4 color : COLOR; 40 | float2 texcoord : TEXCOORD0; 41 | UNITY_FOG_COORDS(1) 42 | //#ifdef SOFTPARTICLES_ON 43 | //float4 projPos : TEXCOORD2; 44 | //#endif 45 | 46 | float4 worldPosition : TEXCOORD1; 47 | float4 worldPosition2 : COLOR1; 48 | }; 49 | 50 | float4 _MainTex_ST; 51 | 52 | v2f vert (appdata_t v) 53 | { 54 | v2f o; 55 | o.worldPosition = v.vertex; 56 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 57 | o.worldPosition2 = mul(_Object2World, v.vertex); 58 | //#ifdef SOFTPARTICLES_ON 59 | //o.projPos = ComputeScreenPos (o.vertex); 60 | //COMPUTE_EYEDEPTH(o.projPos.z); 61 | //#endif 62 | o.color = v.color; 63 | o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex); 64 | UNITY_TRANSFER_FOG(o,o.vertex); 65 | return o; 66 | } 67 | 68 | sampler2D_float _CameraDepthTexture; 69 | float _InvFade; 70 | 71 | float2 _Min; 72 | float2 _Max; 73 | float4 _SoftEdge; 74 | 75 | fixed4 frag (v2f i) : SV_Target 76 | { 77 | fixed4 tex = tex2D(_MainTex, i.texcoord); 78 | fixed4 col; 79 | col.rgb = _TintColor.rgb * tex.rgb * i.color.rgb * 2.0f; 80 | col.a = (1 - tex.a) * (_TintColor.a * i.color.a * 2.0f); 81 | 82 | UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode 83 | 84 | float alpha = 0; 85 | if (i.worldPosition2.x <= _Min.x || i.worldPosition2.x >= _Max.x || i.worldPosition2.y <= _Min.y || i.worldPosition2.y >= _Max.y) 86 | { 87 | alpha = 0; 88 | } 89 | else // It's in the mask rectangle, so apply the alpha of the mask provided. 90 | { 91 | alpha = 1; 92 | if (i.worldPosition2.x - _Min.x < _SoftEdge.x) 93 | alpha *= (i.worldPosition2.x - _Min.x) / _SoftEdge.x; 94 | else if (_Max.x - i.worldPosition2.x < _SoftEdge.z) 95 | alpha *= (_Max.x - i.worldPosition2.x) / _SoftEdge.z; 96 | 97 | if (i.worldPosition2.y - _Min.y < _SoftEdge.y) 98 | alpha *= (i.worldPosition2.y - _Min.y) / _SoftEdge.y; 99 | else if (_Max.y - i.worldPosition2.y < _SoftEdge.w) 100 | alpha *= (_Max.y - i.worldPosition2.y) / _SoftEdge.w; 101 | } 102 | 103 | col *= alpha; 104 | return col; 105 | } 106 | ENDCG 107 | } 108 | } 109 | 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Assets/SoftMask/SoftMaskModle.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using UnityEngine.Rendering; 4 | using System.Collections.Generic; 5 | 6 | namespace UI 7 | { 8 | public class SoftMaskModle : MonoBehaviour 9 | { 10 | static List Renderers = new List(); 11 | 12 | public class Data 13 | { 14 | public Renderer renderer; 15 | public Material[] srcMaterials; // 源材质 16 | public Material[] dstMaterials; // 拷贝的材质 17 | 18 | public void Restore() 19 | { 20 | renderer.sharedMaterials = srcMaterials; 21 | } 22 | 23 | public void Set(UI.RectSoftAlphaMask mask) 24 | { 25 | for (int i = 0; i < dstMaterials.Length; ++i) 26 | { 27 | mask.UpdateMaterial(dstMaterials[i]); 28 | } 29 | 30 | renderer.sharedMaterials = dstMaterials; 31 | } 32 | } 33 | 34 | public List mDatas = new List(); 35 | 36 | public void Set() 37 | { 38 | if (mTotalMateiral == 0) 39 | return; 40 | 41 | RectSoftAlphaMask mask = GetComponentInParent(); 42 | if (mask == null) 43 | return; 44 | 45 | for (int i = 0; i < mDatas.Count; ++i) 46 | { 47 | mDatas[i].Set(mask); 48 | } 49 | } 50 | 51 | public void Restore() 52 | { 53 | if (mTotalMateiral == 0) 54 | return; 55 | 56 | for (int i = 0; i < mDatas.Count; ++i) 57 | { 58 | mDatas[i].Restore(); 59 | } 60 | } 61 | 62 | int mTotalMateiral = 0; 63 | 64 | void Start() 65 | { 66 | Renderers.Clear(); 67 | gameObject.GetComponentsInChildren(true, Renderers); 68 | 69 | mDatas.Capacity = Renderers.Count; 70 | mTotalMateiral = 0; 71 | for (int i = 0; i < Renderers.Count; ++i) 72 | { 73 | Data d = new Data(); 74 | d.renderer = Renderers[i]; 75 | d.srcMaterials = Renderers[i].sharedMaterials; 76 | d.dstMaterials = new Material[d.srcMaterials.Length]; 77 | 78 | for (int j = 0; j < d.dstMaterials.Length; ++j) 79 | { 80 | Shader shader; 81 | Material mat = d.srcMaterials[j]; 82 | if (mat != null && ((shader = mat.shader) != null)) 83 | { 84 | if (!mat.shader.name.EndsWith(" Soft Mask")) 85 | { 86 | Shader s = Shader.Find(shader.name + " Soft Mask"); 87 | if (s != null) 88 | { 89 | mat = new Material(mat); 90 | mat.shader = s; 91 | ++mTotalMateiral; 92 | 93 | d.dstMaterials[j] = mat; 94 | } 95 | } 96 | } 97 | } 98 | 99 | mDatas.Add(d); 100 | } 101 | 102 | Set(); 103 | } 104 | 105 | void Update() 106 | { 107 | Set(); 108 | } 109 | 110 | void OnDisable() 111 | { 112 | Restore(); 113 | } 114 | 115 | void OnEnable() 116 | { 117 | Set(); 118 | } 119 | } 120 | } -------------------------------------------------------------------------------- /Assets/SoftMask/RectSoftAlphaMask.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine.UI; 5 | 6 | namespace UI 7 | { 8 | [RequireComponent(typeof(RectTransform))] 9 | [AddComponentMenu("UI/RectSoftAlphaMask", 16)] 10 | [ExecuteInEditMode] 11 | public class RectSoftAlphaMask : MonoBehaviour 12 | { 13 | [HideInInspector] 14 | public Vector4 SoftEdge = new Vector4(10, 10, 10, 10); // 软边 15 | 16 | static List s_AlphaMaskMaterial = new List(); 17 | 18 | void OnDisable() 19 | { 20 | s_AlphaMaskMaterial.Clear(); 21 | gameObject.GetComponentsInChildren(s_AlphaMaskMaterial); 22 | for (int i = 0; i < s_AlphaMaskMaterial.Count; ++i) 23 | s_AlphaMaskMaterial[i].SetMaterialDirty(); 24 | s_AlphaMaskMaterial.Clear(); 25 | } 26 | 27 | void OnEnable() 28 | { 29 | Set(); 30 | } 31 | 32 | public Rect MaskRect 33 | { 34 | get 35 | { 36 | Rect rect = rectTransform.rect; 37 | rect.xMin -= SoftEdge.x; 38 | rect.xMax -= SoftEdge.z; 39 | rect.yMin -= SoftEdge.y; 40 | rect.yMax -= SoftEdge.w; 41 | return rect; 42 | } 43 | } 44 | 45 | RectTransform rectTransform; 46 | 47 | [SerializeField] 48 | RectSoftAlphaMask parentMask; 49 | 50 | static List s_graphics = new List(); 51 | 52 | void Set() 53 | { 54 | s_graphics.Clear(); 55 | GetComponentsInChildren(s_graphics); 56 | GameObject go = gameObject; 57 | for (int i = 0; i < s_graphics.Count; ++i) 58 | { 59 | if (go == s_graphics[i].gameObject) 60 | continue; 61 | 62 | AlphaMaskMaterial amm = s_graphics[i].GetComponent(); 63 | if (amm == null) 64 | { 65 | amm = s_graphics[i].gameObject.AddComponent(); 66 | amm.rectParent = this; 67 | } 68 | 69 | amm.SetMaterialDirty(); 70 | } 71 | 72 | s_graphics.Clear(); 73 | } 74 | 75 | void Awake() 76 | { 77 | rectTransform = GetComponent(); 78 | currentMaterial = null; 79 | } 80 | 81 | [SerializeField] 82 | Material currentMaterial; 83 | 84 | [SerializeField] 85 | Material greyMaterial; 86 | 87 | static Vector3[] worldCorners; 88 | 89 | public void Update() 90 | { 91 | if (currentMaterial == null && greyMaterial == null) 92 | return; 93 | 94 | if (!rectTransform.hasChanged) 95 | return; 96 | 97 | if (currentMaterial != null) 98 | UpdateMaterial(currentMaterial); 99 | if (greyMaterial != null) 100 | UpdateMaterial(greyMaterial); 101 | } 102 | 103 | Rect GetSelfMaskRect() 104 | { 105 | float xMin, xMax, yMin, yMax; 106 | 107 | worldCorners = new Vector3[4]; 108 | rectTransform.GetWorldCorners(worldCorners); 109 | 110 | xMin = Mathf.Min(worldCorners[0].x, worldCorners[1].x); 111 | xMin = Mathf.Min(xMin, worldCorners[2].x); 112 | xMin = Mathf.Min(xMin, worldCorners[3].x); 113 | 114 | yMin = Mathf.Min(worldCorners[0].y, worldCorners[1].y); 115 | yMin = Mathf.Min(yMin, worldCorners[2].y); 116 | yMin = Mathf.Min(yMin, worldCorners[3].y); 117 | 118 | xMax = Mathf.Max(worldCorners[0].x, worldCorners[1].x); 119 | xMax = Mathf.Max(xMax, worldCorners[2].x); 120 | xMax = Mathf.Max(xMax, worldCorners[3].x); 121 | 122 | yMax = Mathf.Max(worldCorners[0].y, worldCorners[1].y); 123 | yMax = Mathf.Max(yMax, worldCorners[2].y); 124 | yMax = Mathf.Max(yMax, worldCorners[3].y); 125 | 126 | return Rect.MinMaxRect(xMin, yMin, xMax, yMax); 127 | } 128 | 129 | public Rect GetMaskRect() 130 | { 131 | if (parentMask == null) 132 | return GetSelfMaskRect(); 133 | 134 | Rect rect = GetSelfMaskRect(); 135 | Rect parentRect = parentMask.GetMaskRect(); 136 | 137 | rect.xMin = Mathf.Max(rect.xMin, parentRect.xMin); 138 | rect.xMax = Mathf.Min(rect.xMax, parentRect.xMax); 139 | rect.yMin = Mathf.Max(rect.yMin, parentRect.yMin); 140 | rect.yMax = Mathf.Min(rect.yMax, parentRect.yMax); 141 | 142 | return rect; 143 | } 144 | 145 | public void UpdateMaterial(Material material) 146 | { 147 | Rect maskRect = GetMaskRect(); 148 | 149 | // Pass the values to the shader 150 | material.SetVector("_Min", maskRect.min); 151 | material.SetVector("_Max", maskRect.max); 152 | 153 | Vector2 size = maskRect.size; 154 | size.x = Mathf.Abs(size.x); 155 | size.y = Mathf.Abs(size.y); 156 | 157 | Vector2 screenSize = rectTransform.rect.size; 158 | 159 | size.x /= screenSize.x; 160 | size.y /= screenSize.y; 161 | 162 | Vector4 softEdge = new Vector4( 163 | SoftEdge.x * size.x, 164 | SoftEdge.y * size.y, 165 | SoftEdge.z * size.x, 166 | SoftEdge.w * size.y); 167 | 168 | material.SetVector("_SoftEdge", softEdge); 169 | } 170 | 171 | public Material GetDefaultMaterial(Material baseMaterial) 172 | { 173 | if (baseMaterial == Canvas.GetDefaultCanvasMaterial()) 174 | { 175 | if (currentMaterial == null) 176 | { 177 | currentMaterial = new Material(Shader.Find("UI/Default Soft Mask")); 178 | } 179 | 180 | return currentMaterial; 181 | } 182 | 183 | if (baseMaterial.shader.name == "UI/Default Grey") 184 | { 185 | if (greyMaterial == null) 186 | { 187 | greyMaterial = new Material(Shader.Find("UI/Default Grey Soft Mask")); 188 | } 189 | 190 | return greyMaterial; 191 | } 192 | 193 | return baseMaterial; 194 | } 195 | } 196 | } --------------------------------------------------------------------------------