├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── question.md ├── .releaserc ├── CHANGELOG.md ├── CHANGELOG.md.meta ├── LICENSE.md ├── LICENSE.md.meta ├── README.md ├── README.md.meta ├── Resources.meta ├── Resources ├── Default-Transition.png ├── Default-Transition.png.meta ├── UIDissolve.shader ├── UIDissolve.shader.meta ├── UIEffect.cginc ├── UIEffect.cginc.meta ├── UIEffect.shader ├── UIEffect.shader.meta ├── UIEffectSprite.cginc ├── UIEffectSprite.cginc.meta ├── UIHsvModifier.shader ├── UIHsvModifier.shader.meta ├── UIShiny.shader ├── UIShiny.shader.meta ├── UITtransition.shader └── UITtransition.shader.meta ├── Samples~ ├── Demo.meta └── Demo │ ├── UIEffect_Demo.asmdef │ ├── UIEffect_Demo.asmdef.meta │ ├── UIEffect_Demo.cs │ ├── UIEffect_Demo.cs.meta │ ├── UIEffect_Demo.unity │ ├── UIEffect_Demo.unity.meta │ ├── UIEffect_Demo_Atlas.png │ ├── UIEffect_Demo_Atlas.png.meta │ ├── UIEffect_Demo_ColorControl.cs │ ├── UIEffect_Demo_ColorControl.cs.meta │ ├── UIEffect_Demo_For Thumbnail.controller │ ├── UIEffect_Demo_For Thumbnail.controller.meta │ ├── UIEffect_Demo_Pattern.png │ ├── UIEffect_Demo_Pattern.png.meta │ ├── UIEffect_Demo_PropertyControl.cs │ ├── UIEffect_Demo_PropertyControl.cs.meta │ ├── UIEffect_Demo_Transition.controller │ ├── UIEffect_Demo_Transition.controller.meta │ ├── UITransitionTex.png │ ├── UITransitionTex.png.meta │ ├── UITransitionTex_Demo1.png │ ├── UITransitionTex_Demo1.png.meta │ ├── UITransitionTex_Demo2.png │ ├── UITransitionTex_Demo2.png.meta │ ├── UITransitionTex_Demo3.png │ ├── UITransitionTex_Demo3.png.meta │ ├── UITransitionTex_Demo4.png │ ├── UITransitionTex_Demo4.png.meta │ ├── UITransition_Art.png │ └── UITransition_Art.png.meta ├── Scripts.meta ├── Scripts ├── Common.meta ├── Common │ ├── BaseMaterialEffect.cs │ ├── BaseMaterialEffect.cs.meta │ ├── BaseMeshEffect.cs │ ├── BaseMeshEffect.cs.meta │ ├── EffectPlayer.cs │ ├── EffectPlayer.cs.meta │ ├── GraphicConnector.cs │ ├── GraphicConnector.cs.meta │ ├── MaterialCache.cs │ ├── MaterialCache.cs.meta │ ├── Matrix2x3.cs │ ├── Matrix2x3.cs.meta │ ├── Packer.cs │ ├── Packer.cs.meta │ ├── ParameterTexture.cs │ └── ParameterTexture.cs.meta ├── Editor.meta ├── Editor │ ├── ImportSampleMenu.cs │ ├── ImportSampleMenu.cs.meta │ ├── MaterialDirtyScope.cs │ ├── MaterialDirtyScope.cs.meta │ ├── UIDissolveEditor.cs │ ├── UIDissolveEditor.cs.meta │ ├── UIEffect-Editor.asmdef │ ├── UIEffect-Editor.asmdef.meta │ ├── UIEffectEditor.cs │ ├── UIEffectEditor.cs.meta │ ├── UIGradientEditor.cs │ ├── UIGradientEditor.cs.meta │ ├── UIHsvModifierEditor.cs │ ├── UIHsvModifierEditor.cs.meta │ ├── UIShadowEditor.cs │ ├── UIShadowEditor.cs.meta │ ├── UIShinyEditor.cs │ ├── UIShinyEditor.cs.meta │ ├── UITransitionEffectEditor.cs │ └── UITransitionEffectEditor.cs.meta ├── Enums.meta ├── Enums │ ├── BlurMode.cs │ ├── BlurMode.cs.meta │ ├── ColorMode.cs │ ├── ColorMode.cs.meta │ ├── EffectArea.cs │ ├── EffectArea.cs.meta │ ├── EffectMode.cs │ ├── EffectMode.cs.meta │ ├── ShadowStyle.cs │ └── ShadowStyle.cs.meta ├── UIDissolve.cs ├── UIDissolve.cs.meta ├── UIEffect.asmdef ├── UIEffect.asmdef.meta ├── UIEffect.cs ├── UIEffect.cs.meta ├── UIFlip.cs ├── UIFlip.cs.meta ├── UIGradient.cs ├── UIGradient.cs.meta ├── UIHsvModifier.cs ├── UIHsvModifier.cs.meta ├── UIShadow.cs ├── UIShadow.cs.meta ├── UIShiny.cs ├── UIShiny.cs.meta ├── UISyncEffect.cs ├── UISyncEffect.cs.meta ├── UITransitionEffect.cs └── UITransitionEffect.cs.meta ├── package.json └── package.json.meta /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: mob-sakai # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: mob_sakai # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: mob-sakai 7 | 8 | --- 9 | 10 | NOTE: Your issue may already be reported! Please search on the [issue tracker](../) before creating one. 11 | 12 | **Describe the bug** 13 | A clear and concise description of what the bug is. 14 | 15 | **To Reproduce** 16 | Steps to reproduce the behavior: 17 | 1. Go to '...' 18 | 2. Click on '....' 19 | 3. Scroll down to '....' 20 | 4. See error 21 | 22 | **Expected behavior** 23 | A clear and concise description of what you expected to happen. 24 | 25 | **Screenshots** 26 | If applicable, add screenshots to help explain your problem. 27 | 28 | **Environment (please complete the following information):** 29 | - Version [e.g. 4.0.0] 30 | - Platform: [e.g. Editor(Windows/Mac), Standalone(Windows/Mac), iOS, Android, WebGL] 31 | - Unity version: [e.g. 2018.2.8f1] 32 | - Build options: [e.g. IL2CPP, .Net 4.x, LWRP] 33 | 34 | **Additional context** 35 | Add any other context about the problem here. 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: mob-sakai 7 | 8 | --- 9 | 10 | NOTE: Your issue may already be reported! Please search on the [issue tracker](../) before creating one. 11 | 12 | **Is your feature request related to a problem? Please describe.** 13 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 14 | 15 | **Describe the solution you'd like** 16 | A clear and concise description of what you want to happen. 17 | 18 | **Describe alternatives you've considered** 19 | A clear and concise description of any alternative solutions or features you've considered. 20 | 21 | **Additional context** 22 | Add any other context or screenshots about the feature request here. 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Ask a question about this project 4 | title: '' 5 | labels: question 6 | assignees: mob-sakai 7 | 8 | --- 9 | 10 | NOTE: Your issue may already be reported! Please search on the [issue tracker](../) before creating one. 11 | 12 | **Describe what help do you need** 13 | A description of the question. 14 | 15 | **Screenshots** 16 | If applicable, add screenshots to help explain your problem. 17 | 18 | **Environment (please complete the following information):** 19 | - Version [e.g. 4.0.0] 20 | - Platform: [e.g. Editor(Windows/Mac), Standalone(Windows/Mac), iOS, Android, WebGL] 21 | - Unity version: [e.g. 2018.2.8f1] 22 | - Build options: [e.g. IL2CPP, .Net 4.x, LWRP] 23 | 24 | **Additional context** 25 | Add any other context or screenshots about the question here. 26 | -------------------------------------------------------------------------------- /.releaserc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ankh4396/UIEffect/b43e40508b167d143330d8b9eff0d5c9965cdf3c/.releaserc -------------------------------------------------------------------------------- /CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fe75f65a37454bf5aa2dab183b4305a 3 | timeCreated: 1522651812 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2017-2020 mob-sakai 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c8ea34522dd786479be28b1347542b7 3 | timeCreated: 1515125149 4 | licenseType: Free 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UIEffect 2 | === 3 | 4 | UIEffect provides visual effect components for Unity UI. 5 | 6 | [![](https://img.shields.io/npm/v/com.coffee.ui-effect?label=openupm®istry_uri=https://package.openupm.com)](https://openupm.com/packages/com.coffee.ui-effect/) 7 | [![](https://img.shields.io/github/v/release/mob-sakai/UIEffect?include_prereleases)](https://github.com/mob-sakai/UIEffect/releases) 8 | [![](https://img.shields.io/github/release-date/mob-sakai/UIEffect.svg)](https://github.com/mob-sakai/UIEffect/releases) 9 | ![](https://img.shields.io/badge/unity-2017.1%20or%20later-green.svg) 10 | [![](https://img.shields.io/github/license/mob-sakai/UIEffect.svg)](https://github.com/mob-sakai/UIEffect/blob/master/LICENSE.txt) 11 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-orange.svg)](http://makeapullrequest.com) 12 | [![](https://img.shields.io/github/watchers/mob-sakai/UIEffect.svg?style=social&label=Watch)](https://github.com/mob-sakai/UIEffect/subscription) 13 | [![](https://img.shields.io/twitter/follow/mob_sakai.svg?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=mob_sakai) 14 | 15 | << [Description](#Description) | [WebGL Demo](#demo) | [Installation](#installation) | [Usage](#usage) | [Example of using](#example-of-using) | [Change log](https://github.com/mob-sakai/UIEffect/blob/upm/CHANGELOG.md) | [Support](#support) >> 16 | 17 | 18 | 19 |



20 | ## Description 21 | 22 | Let's decorate your UI with effects! 23 | You can control parameters as you like from the script as well as inspector. 24 | AnimationClip is supported as a matter of course! 25 | 26 | ![thumbnail](https://user-images.githubusercontent.com/12690315/41398364-155cf5a6-6ff2-11e8-8124-9d16ef6ca267.gif) 27 | ![image](https://user-images.githubusercontent.com/12690315/38594668-636dd3ac-3d82-11e8-9951-820964a6a95f.gif) 28 | 29 |

30 | #### Available effects 31 | 32 | | Component | Features | Screenshot | 33 | | -- | -- | -- | 34 | | **UIEffect** | Combine some visual effects.

**Effect Mode:** Grayscale, Sepia, Nega, Pixelation
**Color Mode:** Multiply, Fill, Additive, Subtract
**Blur Mode:** Fast, Medium, Detail
**Advanced Blur:** Enable more beautiful blurring. | ![][eff1] | 35 | | **UIShiny** | Apply shining effect to a graphic.
The effect does not require Mask component or normal map.

**Parameters:** Effect factor, Width, Rotation, Softness, Brightness, Gloss | ![][eff2] | 36 | | **UIDissolve** | Apply dissolve effect to a graphic.

**Color Mode for edge:** Multiply, Fill, Additive, Subtract
**Parameters:** Effect factor, Width, Rotation, Softness, Edge color
**Options:** Effect area, Keep effect aspect ratio | ![][eff3] | 37 | | **UIHsvModifier** | Modify HSV for graphic.

**Target:** Color, Range
**Adjustment:** Hue, Saturation, Value | ![][eff4] | 38 | | **UITransition Effect** | Apply transition effect with a single channel texture.

**Effect Mode:** Cutoff, Fade, Dissolve
**Options:** Effect area, Keep effect aspect ratio, transition texture
**Pass Ray On Hidden:** Disable the graphic's raycastTarget on hidden. | ![][eff5] | 39 | 40 | [eff1]:https://user-images.githubusercontent.com/12690315/46639603-258df180-cba2-11e8-8f50-9e93bdc4c96e.png 41 | [eff2]:https://user-images.githubusercontent.com/12690315/46639689-b1078280-cba2-11e8-8716-cbc634af7293.gif 42 | [eff3]:https://user-images.githubusercontent.com/12690315/46639690-b1078280-cba2-11e8-8aa9-1d2650fe9a62.gif 43 | [eff4]:https://user-images.githubusercontent.com/12690315/43200006-d6e2bf54-904e-11e8-9f22-0c0f9ce5912f.gif 44 | [eff5]:https://user-images.githubusercontent.com/12690315/46639688-b1078280-cba2-11e8-8bbb-16b8498bca5f.gif 45 | 46 |

47 | ##### The following effects can be used with the above components. 48 | 49 | | Component | Features | Screenshot | 50 | | -- | -- | -- | 51 | | **UIShadow** | Add shadow/outline to a graphic.
The performance is better than the default Shadow/Outline component.

**ShadowStyle:** Shadow, Shadow3, Outline, Outline8 | ![][meff1] | 52 | | **UIGradient** | Change vertex color as gradient with angle and offset.

**Direction:** Horizontal, Vertical, Angle, Diagonal
**Options:** Offset, Color space | ![][meff2] | 53 | | **UIFlip** | Flip a graphic.

**Direction:** Horizontal, Vertical, Both | ![][meff3] | 54 | 55 | [meff1]:https://user-images.githubusercontent.com/12690315/46639604-258df180-cba2-11e8-98a9-aa31f04c695d.png 56 | [meff2]:https://user-images.githubusercontent.com/12690315/40716995-ca87665e-6445-11e8-8233-ec2e21fefd6b.png 57 | [meff3]:https://user-images.githubusercontent.com/12690315/40716996-cab1fd7e-6445-11e8-9753-962d23991d86.png 58 | 59 | 60 | 61 |



62 | ## Demo 63 | 64 | [WebGL Demo](http://mob-sakai.github.io/UIEffect) 65 | 66 | 67 | 68 | 69 |



70 | ## Installation 71 | 72 | #### Requirement 73 | 74 | * Unity 2017.1 or later 75 | * No other SDK are required 76 | 77 | #### Using OpenUPM (for Unity 2018.3 or later) 78 | 79 | This package is available on [OpenUPM](https://openupm.com). 80 | You can install it via [openupm-cli](https://github.com/openupm/openupm-cli). 81 | ``` 82 | openupm add com.coffee.ui-effect 83 | ``` 84 | 85 | #### Using Git (for Unity 2018.3 or later) 86 | 87 | Find the manifest.json file in the Packages folder of your project and edit it to look like this: 88 | ```js 89 | { 90 | "dependencies": { 91 | "com.coffee.ui-effect": "https://github.com/mob-sakai/UIEffect.git", 92 | ... 93 | }, 94 | } 95 | ``` 96 | 97 | To update the package, change suffix `#{version}` to the target version. 98 | 99 | * e.g. `"com.coffee.ui-effect": "https://github.com/mob-sakai/UIEffect.git#4.0.0",` 100 | 101 | Or, use [UpmGitExtension](https://github.com/mob-sakai/UpmGitExtension) to install and update the package. 102 | 103 | #### For Unity 2018.2 or earlier 104 | 105 | 1. Download a source code zip file from [Releases](https://github.com/mob-sakai/UIEffect/releases) page 106 | 2. Extract it 107 | 3. Import it into the following directory in your Unity project 108 | - `Packages` (It works as an embedded package. For Unity 2018.1 or later) 109 | - `Assets` (Legacy way. For Unity 2017.1 or later) 110 | 111 | 112 | 113 |



114 | ## How to play demo 115 | 116 | - For Unity 2019.1 or later 117 | - Open `Package Manager` window and select `UI Effect` package in package list and click `Demo > Import in project` button 118 | - For Unity 2018.4 or earlier 119 | - Click `Assets/Samples/UIEffect/Import Demo` from menu 120 | 121 | The assets will be imported into `Assets/Samples/UI Effect/{version}/Demo`. 122 | Open ` 123 | 124 | 125 | 126 |



127 | ## Usage 128 | 129 | 1. Add any effect component to UI element (Image, RawImage, Text, etc...) from `Add Component` in inspector or `Component > UI > UIEffect > ...` menu. 130 | ![](https://user-images.githubusercontent.com/12690315/78853708-811c9200-7a5a-11ea-9826-0606046525b6.png) 131 | 2. Adjust the parameters of the effect as you like, in inspector. 132 | ![](https://user-images.githubusercontent.com/12690315/38594668-636dd3ac-3d82-11e8-9951-820964a6a95f.gif) 133 | 3. You can add or modify effects from the script. 134 | ```cs 135 | var uieffect = gameObject.AddComponent(); 136 | uieffect.effectMode = EffectMode.Grayscale; 137 | uieffect.effectFactor = 0.85f; 138 | uieffect.colorMode = ColorMode.Add; 139 | uieffect.effectColor = Color.white; 140 | uieffect.colorFactor = 0.1f; 141 | uieffect.blurMode = BlurMode.FastBlur; 142 | uieffect.blurFactor = 1; 143 | ``` 144 | ![](https://user-images.githubusercontent.com/12690315/78853467-e4f28b00-7a59-11ea-82fa-3235aa95e993.png) 145 | 146 | 4. Enjoy! 147 | 148 | 149 | 150 |



151 | ## Example of using 152 | 153 | UIEffect can easily be used in a variety of cases in the game. 154 | 155 | | Case | Description | Screenshot | 156 | | -- | -- | -- | 157 | | Lock/unlock contents | Use UIEffect to apply grayscale.
Indicate to user that the content is unavailable. | ![][ex1] | 158 | | Silhouette | Use UIEffect for filling color. | ![][ex2] | 159 | | Soft shadow/
Outer glow | Use UIEffect and UIShadow to blur the shadow. | ![][ex3] | 160 | | Colored shadow | Use UIEffect and UIShadow to fill shadow with color. | ![][ex4] | 161 | | Blurred dynamic font | Use UIEffect to blur text.
To blur dynamic font cleanly, enable `Advanced Blur` option. | ![][ex5] | 162 | | Text with outline & shadow | Use two UIShadows to add outline and shadow.
There is less overdraw than default Outline/Shadow. | ![][ex6] | 163 | | Shining button | Use UIShiny for shining button.
Indicate to user that you can press the button. | ![][ex7] | 164 | | Screen transition | Use UITransitionEffect to transition the screen with any transition texture. | ![][ex8] | 165 | 166 | [ex1]:https://user-images.githubusercontent.com/12690315/46563469-aba8fe80-c93c-11e8-850f-949f6f8da742.png 167 | [ex2]:https://user-images.githubusercontent.com/12690315/46563576-3db10700-c93d-11e8-960e-4336ff3ce481.png 168 | [ex3]:https://user-images.githubusercontent.com/12690315/46566001-452edb00-c952-11e8-9cc4-6098a9eb67f3.png 169 | [ex4]:https://user-images.githubusercontent.com/12690315/46566000-452edb00-c952-11e8-8d20-6ccc3fa92ae4.png 170 | [ex5]:https://user-images.githubusercontent.com/12690315/46566002-45c77180-c952-11e8-87cb-4d915e0614be.png 171 | [ex6]:https://user-images.githubusercontent.com/12690315/46566003-45c77180-c952-11e8-9b47-7bf563ffbaa7.png 172 | [ex7]:https://user-images.githubusercontent.com/12690315/46563539-fb87c580-c93c-11e8-8c08-0f21872c47d4.gif 173 | [ex8]:https://user-images.githubusercontent.com/12690315/46565182-dfd5ec80-c947-11e8-834f-a2ef67ad0d95.gif 174 | 175 | 176 | 177 |



178 | ## License 179 | 180 | * MIT 181 | * © UTJ/UCL 182 | 183 | 184 | 185 |



186 | ## Support 187 | 188 | This is an open-source project that I am developing in my free time. 189 | If you like it, you can support me. 190 | By supporting, you let me spend more time working on better tools that you can use for free. :) 191 | 192 | [![become_a_patron_on_patreon](https://user-images.githubusercontent.com/12690315/50731629-3b18b480-11ad-11e9-8fad-4b13f27969c1.png)](https://www.patreon.com/join/2343451?) 193 | [![become_a_sponsor_on_github](https://user-images.githubusercontent.com/12690315/66942881-03686280-f085-11e9-9586-fc0b6011029f.png)](https://github.com/users/mob-sakai/sponsorship) 194 | 195 | 196 | 197 | ## Author 198 | 199 | [mob-sakai](https://github.com/mob-sakai) 200 | [![](https://img.shields.io/twitter/follow/mob_sakai.svg?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=mob_sakai) 201 | 202 | 203 | 204 | ## See Also 205 | 206 | * GitHub page : https://github.com/mob-sakai/UIEffect 207 | * Releases : https://github.com/mob-sakai/UIEffect/releases 208 | * Issue tracker : https://github.com/mob-sakai/UIEffect/issues 209 | * Change log : https://github.com/mob-sakai/UIEffect/blob/upm/CHANGELOG.md 210 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ddc08462bf3e14c82929e462ff7823e7 3 | timeCreated: 1502939317 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f38c4e6372f684b60a94e0d0b902a98a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Resources/Default-Transition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ankh4396/UIEffect/b43e40508b167d143330d8b9eff0d5c9965cdf3c/Resources/Default-Transition.png -------------------------------------------------------------------------------- /Resources/Default-Transition.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e04c247fb2604af186173fce0bc62de 3 | timeCreated: 1524468976 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 0 12 | linearTexture: 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: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: 1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 2 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 10 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 256 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 256 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: iPhone 70 | maxTextureSize: 256 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: Android 78 | maxTextureSize: 256 79 | textureFormat: -1 80 | textureCompression: 1 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | - buildTarget: WebGL 86 | maxTextureSize: 256 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | spriteSheet: 94 | serializedVersion: 2 95 | sprites: [] 96 | outline: [] 97 | spritePackingTag: 98 | userData: 99 | assetBundleName: 100 | assetBundleVariant: 101 | -------------------------------------------------------------------------------- /Resources/UIDissolve.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/UI/Default (UIDissolve)" 2 | { 3 | Properties 4 | { 5 | [PerRendererData] _MainTex ("Main Texture", 2D) = "white" {} 6 | _Color ("Tint", Color) = (1,1,1,1) 7 | 8 | _StencilComp ("Stencil Comparison", Float) = 8 9 | _Stencil ("Stencil ID", Float) = 0 10 | _StencilOp ("Stencil Operation", Float) = 0 11 | _StencilWriteMask ("Stencil Write Mask", Float) = 255 12 | _StencilReadMask ("Stencil Read Mask", Float) = 255 13 | 14 | _ColorMask ("Color Mask", Float) = 15 15 | 16 | [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0 17 | 18 | [Header(Dissolve)] 19 | _TransitionTex ("Transition Texture (A)", 2D) = "white" {} 20 | _ParamTex ("Parameter Texture", 2D) = "white" {} 21 | } 22 | 23 | SubShader 24 | { 25 | Tags 26 | { 27 | "Queue"="Transparent" 28 | "IgnoreProjector"="True" 29 | "RenderType"="Transparent" 30 | "PreviewType"="Plane" 31 | "CanUseSpriteAtlas"="True" 32 | } 33 | 34 | Stencil 35 | { 36 | Ref [_Stencil] 37 | Comp [_StencilComp] 38 | Pass [_StencilOp] 39 | ReadMask [_StencilReadMask] 40 | WriteMask [_StencilWriteMask] 41 | } 42 | 43 | Cull Off 44 | Lighting Off 45 | ZWrite Off 46 | ZTest [unity_GUIZTestMode] 47 | Blend SrcAlpha OneMinusSrcAlpha 48 | ColorMask [_ColorMask] 49 | 50 | Pass 51 | { 52 | Name "Default" 53 | 54 | CGPROGRAM 55 | #pragma vertex vert 56 | #pragma fragment frag 57 | #pragma target 2.0 58 | 59 | #define DISSOLVE 1 60 | #pragma multi_compile __ UNITY_UI_ALPHACLIP 61 | #pragma multi_compile __ ADD SUBTRACT FILL 62 | 63 | #include "UnityCG.cginc" 64 | #include "UnityUI.cginc" 65 | 66 | #define UI_DISSOLVE 1 67 | #include "UIEffect.cginc" 68 | #include "UIEffectSprite.cginc" 69 | 70 | fixed4 frag(v2f IN) : SV_Target 71 | { 72 | half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color; 73 | color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect); 74 | 75 | // Dissolve 76 | color = ApplyTransitionEffect(color, IN.eParam); 77 | 78 | #ifdef UNITY_UI_ALPHACLIP 79 | clip (color.a - 0.001); 80 | #endif 81 | 82 | return color; 83 | } 84 | ENDCG 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Resources/UIDissolve.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1b48dc831eb147e9886c049033213bf 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: 6 | - _MainTex: {instanceID: 0} 7 | - _TransitionTex: {instanceID: 0} 8 | - _ParamTex: {instanceID: 0} 9 | nonModifiableTextures: [] 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Resources/UIEffect.cginc: -------------------------------------------------------------------------------- 1 | #ifndef UI_EFFECT_INCLUDED 2 | #define UI_EFFECT_INCLUDED 3 | 4 | 5 | sampler2D _TransitionTex; 6 | sampler2D _ParamTex; 7 | 8 | #if GRAYSCALE | SEPIA | NEGA | PIXEL | MONO | CUTOFF | HUE 9 | #define UI_TONE 10 | #endif 11 | 12 | #if ADD | SUBTRACT | FILL 13 | #define UI_COLOR 14 | #endif 15 | 16 | #if FASTBLUR | MEDIUMBLUR | DETAILBLUR 17 | #define UI_BLUR 18 | #endif 19 | 20 | // Unpack float to low-precision [0-1] fixed4. 21 | fixed4 UnpackToVec4(float value) 22 | { 23 | const int PACKER_STEP = 64; 24 | const int PRECISION = PACKER_STEP - 1; 25 | fixed4 unpacked; 26 | 27 | unpacked.x = (value % PACKER_STEP) / PRECISION; 28 | value = floor(value / PACKER_STEP); 29 | 30 | unpacked.y = (value % PACKER_STEP) / PRECISION; 31 | value = floor(value / PACKER_STEP); 32 | 33 | unpacked.z = (value % PACKER_STEP) / PRECISION; 34 | value = floor(value / PACKER_STEP); 35 | 36 | unpacked.w = (value % PACKER_STEP) / PRECISION; 37 | return unpacked; 38 | } 39 | 40 | // Unpack float to low-precision [0-1] fixed3. 41 | fixed3 UnpackToVec3(float value) 42 | { 43 | const int PACKER_STEP = 256; 44 | const int PRECISION = PACKER_STEP - 1; 45 | fixed3 unpacked; 46 | 47 | unpacked.x = (value % (PACKER_STEP)) / (PACKER_STEP - 1); 48 | value = floor(value / (PACKER_STEP)); 49 | 50 | unpacked.y = (value % PACKER_STEP) / (PACKER_STEP - 1); 51 | value = floor(value / PACKER_STEP); 52 | 53 | unpacked.z = (value % PACKER_STEP) / (PACKER_STEP - 1); 54 | return unpacked; 55 | } 56 | 57 | // Unpack float to low-precision [0-1] half2. 58 | half2 UnpackToVec2(float value) 59 | { 60 | const int PACKER_STEP = 4096; 61 | const int PRECISION = PACKER_STEP - 1; 62 | half2 unpacked; 63 | 64 | unpacked.x = (value % (PACKER_STEP)) / (PACKER_STEP - 1); 65 | value = floor(value / (PACKER_STEP)); 66 | 67 | unpacked.y = (value % PACKER_STEP) / (PACKER_STEP - 1); 68 | return unpacked; 69 | } 70 | 71 | // Sample texture with blurring. 72 | // * Fast: Sample texture with 3x3 kernel. 73 | // * Medium: Sample texture with 5x5 kernel. 74 | // * Detail: Sample texture with 7x7 kernel. 75 | fixed4 Tex2DBlurring (sampler2D tex, half2 texcood, half2 blur, half4 mask) 76 | { 77 | #if FASTBLUR && EX 78 | const int KERNEL_SIZE = 5; 79 | const float KERNEL_[5] = { 0.2486, 0.7046, 1.0, 0.7046, 0.2486}; 80 | #elif MEDIUMBLUR && EX 81 | const int KERNEL_SIZE = 9; 82 | const float KERNEL_[9] = { 0.0438, 0.1719, 0.4566, 0.8204, 1.0, 0.8204, 0.4566, 0.1719, 0.0438}; 83 | #elif DETAILBLUR && EX 84 | const int KERNEL_SIZE = 13; 85 | const float KERNEL_[13] = { 0.0438, 0.1138, 0.2486, 0.4566, 0.7046, 0.9141, 1.0, 0.9141, 0.7046, 0.4566, 0.2486, 0.1138, 0.0438}; 86 | #elif FASTBLUR 87 | const int KERNEL_SIZE = 3; 88 | const float KERNEL_[3] = { 0.4566, 1.0, 0.4566}; 89 | #elif MEDIUMBLUR 90 | const int KERNEL_SIZE = 5; 91 | const float KERNEL_[5] = { 0.2486, 0.7046, 1.0, 0.7046, 0.2486}; 92 | #elif DETAILBLUR 93 | const int KERNEL_SIZE = 7; 94 | const float KERNEL_[7] = { 0.1719, 0.4566, 0.8204, 1.0, 0.8204, 0.4566, 0.1719}; 95 | #else 96 | const int KERNEL_SIZE = 1; 97 | const float KERNEL_[1] = { 1.0 }; 98 | #endif 99 | float4 o = 0; 100 | float sum = 0; 101 | float2 shift = 0; 102 | for(int x = 0; x < KERNEL_SIZE; x++) 103 | { 104 | shift.x = blur.x * (float(x) - KERNEL_SIZE/2); 105 | for(int y = 0; y < KERNEL_SIZE; y++) 106 | { 107 | shift.y = blur.y * (float(y) - KERNEL_SIZE/2); 108 | float2 uv = texcood + shift; 109 | float weight = KERNEL_[x] * KERNEL_[y]; 110 | sum += weight; 111 | #if EX 112 | fixed masked = min(mask.x <= uv.x, uv.x <= mask.z) * min(mask.y <= uv.y, uv.y <= mask.w); 113 | o += lerp(fixed4(0.5, 0.5, 0.5, 0), tex2D(tex, uv), masked) * weight; 114 | #else 115 | o += tex2D(tex, uv) * weight; 116 | #endif 117 | } 118 | } 119 | return o / sum; 120 | } 121 | 122 | // Sample texture with blurring. 123 | // * Fast: Sample texture with 3x3 kernel. 124 | // * Medium: Sample texture with 5x5 kernel. 125 | // * Detail: Sample texture with 7x7 kernel. 126 | fixed4 Tex2DBlurring (sampler2D tex, half2 texcood, half2 blur) 127 | { 128 | return Tex2DBlurring(tex, texcood, blur, half4(0,0,1,1)); 129 | } 130 | 131 | 132 | // Sample texture with blurring. 133 | // * Fast: Sample texture with 3x1 kernel. 134 | // * Medium: Sample texture with 5x1 kernel. 135 | // * Detail: Sample texture with 7x1 kernel. 136 | fixed4 Tex2DBlurring1D (sampler2D tex, half2 uv, half2 blur) 137 | { 138 | #if FASTBLUR 139 | const int KERNEL_SIZE = 3; 140 | #elif MEDIUMBLUR 141 | const int KERNEL_SIZE = 5; 142 | #elif DETAILBLUR 143 | const int KERNEL_SIZE = 7; 144 | #else 145 | const int KERNEL_SIZE = 1; 146 | #endif 147 | float4 o = 0; 148 | float sum = 0; 149 | float weight; 150 | half2 texcood; 151 | for(int i = -KERNEL_SIZE/2; i <= KERNEL_SIZE/2; i++) 152 | { 153 | texcood = uv; 154 | texcood.x += blur.x * i; 155 | texcood.y += blur.y * i; 156 | weight = 1.0/(abs(i)+2); 157 | o += tex2D(tex, texcood)*weight; 158 | sum += weight; 159 | } 160 | return o / sum; 161 | } 162 | 163 | fixed3 shift_hue(fixed3 RGB, half VSU, half VSW) 164 | { 165 | fixed3 result; 166 | result.x = (0.299 + 0.701*VSU + 0.168*VSW)*RGB.x 167 | + (0.587 - 0.587*VSU + 0.330*VSW)*RGB.y 168 | + (0.114 - 0.114*VSU - 0.497*VSW)*RGB.z; 169 | 170 | result.y = (0.299 - 0.299*VSU - 0.328*VSW)*RGB.x 171 | + (0.587 + 0.413*VSU + 0.035*VSW)*RGB.y 172 | + (0.114 - 0.114*VSU + 0.292*VSW)*RGB.z; 173 | 174 | result.z = (0.299 - 0.3*VSU + 1.25*VSW)*RGB.x 175 | + (0.587 - 0.588*VSU - 1.05*VSW)*RGB.y 176 | + (0.114 + 0.886*VSU - 0.203*VSW)*RGB.z; 177 | 178 | return result; 179 | } 180 | 181 | // Apply tone effect. 182 | fixed4 ApplyToneEffect(fixed4 color, fixed factor) 183 | { 184 | #ifdef GRAYSCALE 185 | color.rgb = lerp(color.rgb, Luminance(color.rgb), factor); 186 | 187 | #elif SEPIA 188 | color.rgb = lerp(color.rgb, Luminance(color.rgb) * half3(1.07, 0.74, 0.43), factor); 189 | 190 | #elif NEGA 191 | color.rgb = lerp(color.rgb, 1 - color.rgb, factor); 192 | #endif 193 | 194 | return color; 195 | } 196 | 197 | // Apply color effect. 198 | fixed4 ApplyColorEffect(half4 color, half4 factor) 199 | { 200 | #if FILL 201 | color.rgb = lerp(color.rgb, factor.rgb, factor.a); 202 | 203 | #elif ADD 204 | color.rgb += factor.rgb * factor.a; 205 | 206 | #elif SUBTRACT 207 | color.rgb -= factor.rgb * factor.a; 208 | 209 | #else 210 | color.rgb = lerp(color.rgb, color.rgb * factor.rgb, factor.a); 211 | #endif 212 | 213 | #if CUTOFF 214 | color.a = factor.a; 215 | #endif 216 | 217 | return color; 218 | } 219 | 220 | // Apply transition effect. 221 | fixed4 ApplyTransitionEffect(half4 color, half3 transParam) 222 | { 223 | fixed4 param = tex2D(_ParamTex, float2(0.25, transParam.z)); 224 | float alpha = tex2D(_TransitionTex, transParam.xy).a; 225 | 226 | #if REVERSE 227 | fixed effectFactor = 1 - param.x; 228 | #else 229 | fixed effectFactor = param.x; 230 | #endif 231 | 232 | #if FADE 233 | color.a *= saturate(alpha + (1 - effectFactor * 2)); 234 | #elif CUTOFF 235 | color.a *= step(0.001, color.a * alpha - effectFactor); 236 | #elif DISSOLVE 237 | fixed width = param.y/4; 238 | fixed softness = param.z; 239 | fixed3 dissolveColor = tex2D(_ParamTex, float2(0.75, transParam.z)).rgb; 240 | float factor = alpha - effectFactor * ( 1 + width ) + width; 241 | fixed edgeLerp = step(factor, color.a) * saturate((width - factor)*16/ softness); 242 | color = ApplyColorEffect(color, fixed4(dissolveColor, edgeLerp)); 243 | color.a *= saturate((factor)*32/ softness); 244 | #endif 245 | 246 | return color; 247 | } 248 | 249 | 250 | // Apply shiny effect. 251 | half4 ApplyShinyEffect(half4 color, half2 shinyParam) 252 | { 253 | fixed nomalizedPos = shinyParam.x; 254 | fixed4 param1 = tex2D(_ParamTex, float2(0.25, shinyParam.y)); 255 | fixed4 param2 = tex2D(_ParamTex, float2(0.75, shinyParam.y)); 256 | half location = param1.x * 2 - 0.5; 257 | fixed width = param1.y; 258 | fixed soft = param1.z; 259 | fixed brightness = param1.w; 260 | fixed gloss = param2.x; 261 | half normalized = 1 - saturate(abs((nomalizedPos - location) / width)); 262 | half shinePower = smoothstep(0, soft, normalized); 263 | half3 reflectColor = lerp(fixed3(1,1,1), color.rgb * 7, gloss); 264 | 265 | color.rgb += color.a * (shinePower / 2) * brightness * reflectColor; 266 | 267 | 268 | return color; 269 | } 270 | 271 | half3 RgbToHsv(half3 c) { 272 | half4 K = half4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); 273 | half4 p = lerp(half4(c.bg, K.wz), half4(c.gb, K.xy), step(c.b, c.g)); 274 | half4 q = lerp(half4(p.xyw, c.r), half4(c.r, p.yzx), step(p.x, c.r)); 275 | 276 | half d = q.x - min(q.w, q.y); 277 | half e = 1.0e-10; 278 | return half3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); 279 | } 280 | 281 | half3 HsvToRgb(half3 c) { 282 | c = half3(c.x, clamp(c.yz, 0.0, 1.0)); 283 | half4 K = half4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); 284 | half3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www); 285 | return c.z * lerp(K.xxx, clamp(p.xyz - K.xxx, 0.0, 1.0), c.y); 286 | } 287 | 288 | 289 | // Apply Hsv effect. 290 | half4 ApplyHsvEffect(half4 color, half param) 291 | { 292 | fixed4 param1 = tex2D(_ParamTex, float2(0.25, param)); 293 | fixed4 param2 = tex2D(_ParamTex, float2(0.75, param)); 294 | fixed3 targetHsv = param1.rgb; 295 | 296 | fixed3 targetRange = param1.w; 297 | fixed3 hsvShift = param2.xyz - 0.5; 298 | half3 hsv = RgbToHsv(color.rgb); 299 | half3 range = abs(hsv - targetHsv); 300 | half diff = max(max(min(1-range.x, range.x), min(1-range.y, range.y)/10), min(1-range.z, range.z)/10); 301 | 302 | fixed masked = step(diff, targetRange); 303 | color.rgb = HsvToRgb(hsv + hsvShift * masked); 304 | 305 | return color; 306 | } 307 | 308 | 309 | #endif // UI_EFFECT_INCLUDED 310 | -------------------------------------------------------------------------------- /Resources/UIEffect.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7467061e9f5514f2c80e30817ee2458b 3 | timeCreated: 1487915863 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/UIEffect.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/UI/Default (UIEffect)" 2 | { 3 | Properties 4 | { 5 | [PerRendererData] _MainTex ("Main Texture", 2D) = "white" {} 6 | _Color ("Tint", Color) = (1,1,1,1) 7 | 8 | _StencilComp ("Stencil Comparison", Float) = 8 9 | _Stencil ("Stencil ID", Float) = 0 10 | _StencilOp ("Stencil Operation", Float) = 0 11 | _StencilWriteMask ("Stencil Write Mask", Float) = 255 12 | _StencilReadMask ("Stencil Read Mask", Float) = 255 13 | 14 | _ColorMask ("Color Mask", Float) = 15 15 | 16 | [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0 17 | 18 | _ParamTex ("Parameter Texture", 2D) = "white" {} 19 | } 20 | 21 | SubShader 22 | { 23 | Tags 24 | { 25 | "Queue"="Transparent" 26 | "IgnoreProjector"="True" 27 | "RenderType"="Transparent" 28 | "PreviewType"="Plane" 29 | "CanUseSpriteAtlas"="True" 30 | } 31 | 32 | Stencil 33 | { 34 | Ref [_Stencil] 35 | Comp [_StencilComp] 36 | Pass [_StencilOp] 37 | ReadMask [_StencilReadMask] 38 | WriteMask [_StencilWriteMask] 39 | } 40 | 41 | Cull Off 42 | Lighting Off 43 | ZWrite Off 44 | ZTest [unity_GUIZTestMode] 45 | Blend SrcAlpha OneMinusSrcAlpha 46 | ColorMask [_ColorMask] 47 | 48 | Pass 49 | { 50 | Name "Default" 51 | 52 | CGPROGRAM 53 | #pragma vertex vert 54 | #pragma fragment frag 55 | #if !defined(SHADER_API_D3D11_9X) && !defined(SHADER_API_D3D9) 56 | #pragma target 2.0 57 | #else 58 | #pragma target 3.0 59 | #endif 60 | 61 | #pragma multi_compile __ UNITY_UI_ALPHACLIP 62 | 63 | #pragma multi_compile __ GRAYSCALE SEPIA NEGA PIXEL 64 | #pragma multi_compile __ ADD SUBTRACT FILL 65 | #pragma multi_compile __ FASTBLUR MEDIUMBLUR DETAILBLUR 66 | #pragma multi_compile __ EX 67 | 68 | #include "UnityCG.cginc" 69 | #include "UnityUI.cginc" 70 | 71 | #define UI_EFFECT 1 72 | #include "UIEffect.cginc" 73 | #include "UIEffectSprite.cginc" 74 | 75 | fixed4 frag(v2f IN) : SV_Target 76 | { 77 | fixed4 param = tex2D(_ParamTex, float2(0.25, IN.eParam)); 78 | fixed effectFactor = param.x; 79 | fixed colorFactor = param.y; 80 | fixed blurFactor = param.z; 81 | 82 | #if PIXEL 83 | half2 pixelSize = max(2, (1-effectFactor*0.95) * _MainTex_TexelSize.zw); 84 | IN.texcoord = round(IN.texcoord * pixelSize) / pixelSize; 85 | #endif 86 | 87 | #if defined(UI_BLUR) && EX 88 | half4 color = (Tex2DBlurring(_MainTex, IN.texcoord, blurFactor * _MainTex_TexelSize.xy * 2, IN.uvMask) + _TextureSampleAdd); 89 | #elif defined(UI_BLUR) 90 | half4 color = (Tex2DBlurring(_MainTex, IN.texcoord, blurFactor * _MainTex_TexelSize.xy * 2) + _TextureSampleAdd); 91 | #else 92 | half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd); 93 | #endif 94 | 95 | color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect); 96 | 97 | #if UNITY_UI_ALPHACLIP 98 | clip (color.a - 0.001); 99 | #endif 100 | 101 | #if defined (UI_TONE) 102 | color = ApplyToneEffect(color, effectFactor); 103 | #endif 104 | 105 | color = ApplyColorEffect(color, fixed4(IN.color.rgb, colorFactor)); 106 | color.a *= IN.color.a; 107 | 108 | return color; 109 | } 110 | ENDCG 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Resources/UIEffect.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b868e81d0156245e08c8646b4fb68d7a 3 | timeCreated: 1482973535 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/UIEffectSprite.cginc: -------------------------------------------------------------------------------- 1 | #ifndef UI_EFFECT_SPRITE_INCLUDED 2 | #define UI_EFFECT_SPRITE_INCLUDED 3 | 4 | fixed4 _Color; 5 | fixed4 _TextureSampleAdd; 6 | float4 _ClipRect; 7 | sampler2D _MainTex; 8 | float4 _MainTex_TexelSize; 9 | 10 | struct appdata_t 11 | { 12 | float4 vertex : POSITION; 13 | float4 color : COLOR; 14 | float2 texcoord : TEXCOORD0; 15 | #if EX 16 | float2 uvMask : TEXCOORD1; 17 | #endif 18 | UNITY_VERTEX_INPUT_INSTANCE_ID 19 | }; 20 | 21 | struct v2f 22 | { 23 | float4 vertex : SV_POSITION; 24 | fixed4 color : COLOR; 25 | half2 texcoord : TEXCOORD0; 26 | float4 worldPosition : TEXCOORD1; 27 | #if UI_DISSOLVE || UI_TRANSITION 28 | half3 eParam : TEXCOORD2; 29 | #elif UI_SHINY 30 | half2 eParam : TEXCOORD2; 31 | #else 32 | half eParam : TEXCOORD2; 33 | #endif 34 | #if EX 35 | half4 uvMask : TEXCOORD3; 36 | #endif 37 | UNITY_VERTEX_OUTPUT_STEREO 38 | }; 39 | 40 | v2f vert(appdata_t IN) 41 | { 42 | v2f OUT; 43 | UNITY_SETUP_INSTANCE_ID(IN); 44 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT); 45 | OUT.worldPosition = IN.vertex; 46 | OUT.vertex = UnityObjectToClipPos(OUT.worldPosition); 47 | 48 | #if UI_EFFECT 49 | OUT.texcoord = UnpackToVec2(IN.texcoord.x) * 2 - 0.5; 50 | #else 51 | OUT.texcoord = UnpackToVec2(IN.texcoord.x); 52 | #endif 53 | 54 | #ifdef UNITY_HALF_TEXEL_OFFSET 55 | OUT.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1); 56 | #endif 57 | 58 | OUT.color = IN.color * _Color; 59 | 60 | #if UI_DISSOLVE || UI_TRANSITION 61 | OUT.eParam = UnpackToVec3(IN.texcoord.y); 62 | #elif UI_SHINY 63 | OUT.eParam = UnpackToVec2(IN.texcoord.y); 64 | #else 65 | OUT.eParam = IN.texcoord.y; 66 | #endif 67 | 68 | #if EX 69 | OUT.uvMask = half4(UnpackToVec2(IN.uvMask.x), UnpackToVec2(IN.uvMask.y)); 70 | #endif 71 | 72 | return OUT; 73 | } 74 | 75 | #endif // UI_EFFECT_SPRITE_INCLUDED 76 | -------------------------------------------------------------------------------- /Resources/UIEffectSprite.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd60a36b172cf49e2b82258a68799ce3 3 | timeCreated: 1487915863 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/UIHsvModifier.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/UI/Default (UIHsvModifier)" 2 | { 3 | Properties 4 | { 5 | [PerRendererData] _MainTex ("Main Texture", 2D) = "white" {} 6 | _Color ("Tint", Color) = (1,1,1,1) 7 | 8 | _StencilComp ("Stencil Comparison", Float) = 8 9 | _Stencil ("Stencil ID", Float) = 0 10 | _StencilOp ("Stencil Operation", Float) = 0 11 | _StencilWriteMask ("Stencil Write Mask", Float) = 255 12 | _StencilReadMask ("Stencil Read Mask", Float) = 255 13 | 14 | _ColorMask ("Color Mask", Float) = 15 15 | 16 | [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0 17 | 18 | _ParamTex ("Parameter Texture", 2D) = "white" {} 19 | } 20 | 21 | SubShader 22 | { 23 | Tags 24 | { 25 | "Queue"="Transparent" 26 | "IgnoreProjector"="True" 27 | "RenderType"="Transparent" 28 | "PreviewType"="Plane" 29 | "CanUseSpriteAtlas"="True" 30 | } 31 | 32 | Stencil 33 | { 34 | Ref [_Stencil] 35 | Comp [_StencilComp] 36 | Pass [_StencilOp] 37 | ReadMask [_StencilReadMask] 38 | WriteMask [_StencilWriteMask] 39 | } 40 | 41 | Cull Off 42 | Lighting Off 43 | ZWrite Off 44 | ZTest [unity_GUIZTestMode] 45 | Blend SrcAlpha OneMinusSrcAlpha 46 | ColorMask [_ColorMask] 47 | 48 | Pass 49 | { 50 | CGPROGRAM 51 | #pragma vertex vert 52 | #pragma fragment frag 53 | #pragma multi_compile __ UNITY_UI_ALPHACLIP 54 | 55 | #include "UnityCG.cginc" 56 | #include "UnityUI.cginc" 57 | 58 | #define UI_HSV_MODIFIER 1 59 | #include "UIEffect.cginc" 60 | #include "UIEffectSprite.cginc" 61 | 62 | fixed4 frag(v2f IN) : COLOR 63 | { 64 | half4 color = tex2D(_MainTex, IN.texcoord);// + _TextureSampleAdd) * IN.color; 65 | color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect); 66 | 67 | #ifdef UNITY_UI_ALPHACLIP 68 | clip (color.a - 0.001); 69 | #endif 70 | 71 | color = ApplyHsvEffect(color, IN.eParam); 72 | 73 | return (color + _TextureSampleAdd) * IN.color; 74 | } 75 | 76 | ENDCG 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Resources/UIHsvModifier.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7fc74090480c84f8b977cfcd55cdfe82 3 | timeCreated: 1531882595 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/UIShiny.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/UI/Default (UIShiny)" 2 | { 3 | Properties 4 | { 5 | [PerRendererData] _MainTex ("Main Texture", 2D) = "white" {} 6 | _Color ("Tint", Color) = (1,1,1,1) 7 | 8 | _StencilComp ("Stencil Comparison", Float) = 8 9 | _Stencil ("Stencil ID", Float) = 0 10 | _StencilOp ("Stencil Operation", Float) = 0 11 | _StencilWriteMask ("Stencil Write Mask", Float) = 255 12 | _StencilReadMask ("Stencil Read Mask", Float) = 255 13 | 14 | _ColorMask ("Color Mask", Float) = 15 15 | 16 | [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0 17 | 18 | _ParamTex ("Parameter Texture", 2D) = "white" {} 19 | } 20 | 21 | SubShader 22 | { 23 | Tags 24 | { 25 | "Queue"="Transparent" 26 | "IgnoreProjector"="True" 27 | "RenderType"="Transparent" 28 | "PreviewType"="Plane" 29 | "CanUseSpriteAtlas"="True" 30 | } 31 | 32 | Stencil 33 | { 34 | Ref [_Stencil] 35 | Comp [_StencilComp] 36 | Pass [_StencilOp] 37 | ReadMask [_StencilReadMask] 38 | WriteMask [_StencilWriteMask] 39 | } 40 | 41 | Cull Off 42 | Lighting Off 43 | ZWrite Off 44 | ZTest [unity_GUIZTestMode] 45 | Blend SrcAlpha OneMinusSrcAlpha 46 | ColorMask [_ColorMask] 47 | 48 | Pass 49 | { 50 | Name "Default" 51 | 52 | CGPROGRAM 53 | #pragma vertex vert 54 | #pragma fragment frag 55 | #pragma target 2.0 56 | 57 | #pragma multi_compile __ UNITY_UI_ALPHACLIP 58 | 59 | #include "UnityCG.cginc" 60 | #include "UnityUI.cginc" 61 | 62 | #define UI_SHINY 1 63 | #include "UIEffect.cginc" 64 | #include "UIEffectSprite.cginc" 65 | 66 | fixed4 frag(v2f IN) : SV_Target 67 | { 68 | half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color; 69 | color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect); 70 | 71 | color = ApplyShinyEffect(color, IN.eParam); 72 | 73 | #ifdef UNITY_UI_ALPHACLIP 74 | clip (color.a - 0.001); 75 | #endif 76 | 77 | return color; 78 | } 79 | ENDCG 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Resources/UIShiny.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 20ffe76c2439c403aabdd25bd94bf011 3 | timeCreated: 1523859834 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Resources/UITtransition.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/UI/Default (UITransition)" 2 | { 3 | Properties 4 | { 5 | [PerRendererData] _MainTex ("Main Texture", 2D) = "white" {} 6 | _Color ("Tint", Color) = (1,1,1,1) 7 | 8 | _StencilComp ("Stencil Comparison", Float) = 8 9 | _Stencil ("Stencil ID", Float) = 0 10 | _StencilOp ("Stencil Operation", Float) = 0 11 | _StencilWriteMask ("Stencil Write Mask", Float) = 255 12 | _StencilReadMask ("Stencil Read Mask", Float) = 255 13 | 14 | _ColorMask ("Color Mask", Float) = 15 15 | 16 | [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0 17 | 18 | [Header(Transition)] 19 | _TransitionTex ("Transition Texture (A)", 2D) = "white" {} 20 | _ParamTex ("Parameter Texture", 2D) = "white" {} 21 | } 22 | 23 | SubShader 24 | { 25 | Tags 26 | { 27 | "Queue"="Transparent" 28 | "IgnoreProjector"="True" 29 | "RenderType"="Transparent" 30 | "PreviewType"="Plane" 31 | "CanUseSpriteAtlas"="True" 32 | } 33 | 34 | Stencil 35 | { 36 | Ref [_Stencil] 37 | Comp [_StencilComp] 38 | Pass [_StencilOp] 39 | ReadMask [_StencilReadMask] 40 | WriteMask [_StencilWriteMask] 41 | } 42 | 43 | Cull Off 44 | Lighting Off 45 | ZWrite Off 46 | ZTest [unity_GUIZTestMode] 47 | Blend SrcAlpha OneMinusSrcAlpha 48 | ColorMask [_ColorMask] 49 | 50 | Pass 51 | { 52 | Name "Default" 53 | 54 | CGPROGRAM 55 | #pragma vertex vert 56 | #pragma fragment frag 57 | #pragma target 2.0 58 | 59 | #define REVERSE 1 60 | #define ADD 1 61 | #pragma multi_compile __ UNITY_UI_ALPHACLIP 62 | 63 | #pragma multi_compile __ FADE CUTOFF DISSOLVE 64 | #include "UnityCG.cginc" 65 | #include "UnityUI.cginc" 66 | 67 | #define UI_TRANSITION 1 68 | #include "UIEffect.cginc" 69 | #include "UIEffectSprite.cginc" 70 | 71 | fixed4 frag(v2f IN) : SV_Target 72 | { 73 | half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd); 74 | color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect); 75 | 76 | color = ApplyTransitionEffect(color, IN.eParam) * IN.color; 77 | 78 | #if UNITY_UI_ALPHACLIP 79 | clip (color.a - 0.001); 80 | #endif 81 | 82 | return color; 83 | } 84 | ENDCG 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Resources/UITtransition.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85ad24dd0759947ddb117625e108d49c 3 | timeCreated: 1548078121 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: 7 | - _MainTex: {instanceID: 0} 8 | - _NoiseTex: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3} 9 | - _ParamTex: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Samples~/Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1b972071582443e2845278a859a1533 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UIEffect_Demo", 3 | "references": [ 4 | "UIEffect" 5 | ], 6 | "optionalUnityReferences": [], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": false, 13 | "defineConstraints": [] 14 | } -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ef9215e2eb5a49b997be297ae25152e 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.UI; 6 | 7 | namespace Coffee.UIEffects 8 | { 9 | public class UIEffect_Demo : MonoBehaviour 10 | { 11 | // Use this for initialization 12 | void Start() 13 | { 14 | GetComponentInChildren().enabled = true; 15 | } 16 | 17 | public void SetTimeScale(float scale) 18 | { 19 | Time.timeScale = scale; 20 | } 21 | 22 | public void Open(Animator anim) 23 | { 24 | // anim.GetComponentInChildren().Capture(); 25 | anim.gameObject.SetActive(true); 26 | anim.SetTrigger("Open"); 27 | } 28 | 29 | public void Close(Animator anim) 30 | { 31 | anim.SetTrigger("Close"); 32 | } 33 | 34 | public void Capture(Animator anim) 35 | { 36 | // anim.GetComponentInChildren().Capture(); 37 | anim.SetTrigger("Capture"); 38 | } 39 | 40 | public void SetCanvasOverlay(bool isOverlay) 41 | { 42 | GetComponent().renderMode = 43 | isOverlay ? RenderMode.ScreenSpaceOverlay : RenderMode.ScreenSpaceCamera; 44 | } 45 | 46 | public void SetRenderMode(int mode) 47 | { 48 | var canvas = GetComponent(); 49 | var cam = canvas.worldCamera; 50 | var pos = new Vector3(0, 0, -25); 51 | var rot = new Vector3(0, 0, 0); 52 | 53 | if ((RenderMode) mode == RenderMode.WorldSpace) 54 | { 55 | SetRenderMode((int) RenderMode.ScreenSpaceCamera); 56 | canvas.renderMode = RenderMode.WorldSpace; 57 | pos.x = 45; 58 | rot.y = -20; 59 | } 60 | else 61 | { 62 | canvas.renderMode = (RenderMode) mode; 63 | } 64 | 65 | cam.transform.SetPositionAndRotation(pos, Quaternion.Euler(rot)); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e94f1a0bc56a14944aadc5064f5f485a 3 | timeCreated: 1525599611 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a96de44a548454578a545a818eb14344 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo_Atlas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ankh4396/UIEffect/b43e40508b167d143330d8b9eff0d5c9965cdf3c/Samples~/Demo/UIEffect_Demo_Atlas.png -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo_Atlas.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 975570a90d56c477582e12d440dc9931 3 | timeCreated: 1528964000 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: 7 | 21300000: old_detail 8 | 21300002: old_fast 9 | 21300004: old_medium 10 | 21300006: UIEffect_Demo_Dark_Silhouette 11 | 21300008: UIEffect_Demo_Pattern 12 | 21300010: UIEffect_Demo_red 13 | 21300012: UIEffect_Demo_Unity-chan 14 | serializedVersion: 4 15 | mipmaps: 16 | mipMapMode: 0 17 | enableMipMap: 0 18 | sRGBTexture: 1 19 | linearTexture: 0 20 | fadeOut: 0 21 | borderMipMap: 0 22 | mipMapFadeDistanceStart: 1 23 | mipMapFadeDistanceEnd: 3 24 | bumpmap: 25 | convertToNormalMap: 0 26 | externalNormalMap: 0 27 | heightScale: 0.25 28 | normalMapFilter: 0 29 | isReadable: 0 30 | grayScaleToAlpha: 0 31 | generateCubemap: 6 32 | cubemapConvolution: 0 33 | seamlessCubemap: 0 34 | textureFormat: 1 35 | maxTextureSize: 2048 36 | textureSettings: 37 | filterMode: 0 38 | aniso: -1 39 | mipBias: -1 40 | wrapMode: 1 41 | nPOTScale: 0 42 | lightmap: 0 43 | compressionQuality: 50 44 | spriteMode: 2 45 | spriteExtrude: 1 46 | spriteMeshType: 1 47 | alignment: 0 48 | spritePivot: {x: 0.5, y: 0.5} 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spritePixelsToUnits: 100 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | maxTextureSizeSet: 0 57 | compressionQualitySet: 0 58 | textureFormatSet: 0 59 | platformSettings: 60 | - buildTarget: DefaultTexturePlatform 61 | maxTextureSize: 2048 62 | textureFormat: -1 63 | textureCompression: 1 64 | compressionQuality: 50 65 | crunchedCompression: 0 66 | allowsAlphaSplitting: 0 67 | overridden: 0 68 | - buildTarget: Standalone 69 | maxTextureSize: 2048 70 | textureFormat: -1 71 | textureCompression: 1 72 | compressionQuality: 50 73 | crunchedCompression: 0 74 | allowsAlphaSplitting: 0 75 | overridden: 0 76 | - buildTarget: iPhone 77 | maxTextureSize: 2048 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | - buildTarget: Android 85 | maxTextureSize: 2048 86 | textureFormat: -1 87 | textureCompression: 1 88 | compressionQuality: 50 89 | crunchedCompression: 0 90 | allowsAlphaSplitting: 0 91 | overridden: 0 92 | - buildTarget: WebGL 93 | maxTextureSize: 2048 94 | textureFormat: -1 95 | textureCompression: 1 96 | compressionQuality: 50 97 | crunchedCompression: 0 98 | allowsAlphaSplitting: 0 99 | overridden: 0 100 | spriteSheet: 101 | serializedVersion: 2 102 | sprites: 103 | - serializedVersion: 2 104 | name: old_detail 105 | rect: 106 | serializedVersion: 2 107 | x: 0 108 | y: 192 109 | width: 106 110 | height: 159 111 | alignment: 0 112 | pivot: {x: 53, y: 79.5} 113 | border: {x: 0, y: 0, z: 0, w: 0} 114 | outline: [] 115 | tessellationDetail: -1 116 | - serializedVersion: 2 117 | name: old_fast 118 | rect: 119 | serializedVersion: 2 120 | x: 116 121 | y: 125 122 | width: 106 123 | height: 159 124 | alignment: 0 125 | pivot: {x: 53, y: 79.5} 126 | border: {x: 0, y: 0, z: 0, w: 0} 127 | outline: [] 128 | tessellationDetail: -1 129 | - serializedVersion: 2 130 | name: old_medium 131 | rect: 132 | serializedVersion: 2 133 | x: 116 134 | y: 288 135 | width: 106 136 | height: 159 137 | alignment: 0 138 | pivot: {x: 53, y: 79.5} 139 | border: {x: 0, y: 0, z: 0, w: 0} 140 | outline: [] 141 | tessellationDetail: -1 142 | - serializedVersion: 2 143 | name: UIEffect_Demo_Dark_Silhouette 144 | rect: 145 | serializedVersion: 2 146 | x: 116 147 | y: 0 148 | width: 140 149 | height: 121 150 | alignment: 0 151 | pivot: {x: 70, y: 60.5} 152 | border: {x: 0, y: 0, z: 0, w: 0} 153 | outline: [] 154 | tessellationDetail: -1 155 | - serializedVersion: 2 156 | name: UIEffect_Demo_red 157 | rect: 158 | serializedVersion: 2 159 | x: 0 160 | y: 355 161 | width: 100 162 | height: 100 163 | alignment: 0 164 | pivot: {x: 50, y: 50} 165 | border: {x: 0, y: 0, z: 0, w: 0} 166 | outline: [] 167 | tessellationDetail: -1 168 | - serializedVersion: 2 169 | name: UIEffect_Demo_Unity-chan 170 | rect: 171 | serializedVersion: 2 172 | x: 0 173 | y: 0 174 | width: 112 175 | height: 188 176 | alignment: 0 177 | pivot: {x: 56, y: 94} 178 | border: {x: 0, y: 0, z: 0, w: 0} 179 | outline: [] 180 | tessellationDetail: -1 181 | outline: [] 182 | spritePackingTag: 183 | userData: 184 | assetBundleName: 185 | assetBundleVariant: 186 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo_ColorControl.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | using UnityEngine.UI; 6 | 7 | public class UIEffect_Demo_ColorControl : MonoBehaviour 8 | { 9 | [SerializeField] private Color m_Color; 10 | [SerializeField] private ColorEvent m_ColorEvent = new ColorEvent(); 11 | 12 | [System.Serializable] 13 | public class ColorEvent : UnityEvent 14 | { 15 | } 16 | 17 | private void Start() 18 | { 19 | var sliders = GetComponentsInChildren(); 20 | for (var i = 0; i < sliders.Length; i++) 21 | { 22 | var channel = i; 23 | if (channel == 0) 24 | sliders[channel].value = m_Color.r; 25 | else if (channel == 1) 26 | sliders[channel].value = m_Color.g; 27 | else if (channel == 2) 28 | sliders[channel].value = m_Color.b; 29 | else 30 | sliders[channel].value = m_Color.a; 31 | sliders[i].onValueChanged.AddListener(value => ChangeColor(channel, value)); 32 | } 33 | } 34 | 35 | private void ChangeColor(int channel, float value) 36 | { 37 | var old = m_Color; 38 | if (channel == 0) 39 | m_Color.r = value; 40 | else if (channel == 1) 41 | m_Color.g = value; 42 | else if (channel == 2) 43 | m_Color.b = value; 44 | else 45 | m_Color.a = value; 46 | 47 | if (old != m_Color) 48 | m_ColorEvent.Invoke(m_Color); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo_ColorControl.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9ed27cb508874b4a8f71e05c9119c52 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo_For Thumbnail.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6407849c9ce4141a9b34a33fbfef3d78 3 | timeCreated: 1502936794 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo_Pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ankh4396/UIEffect/b43e40508b167d143330d8b9eff0d5c9965cdf3c/Samples~/Demo/UIEffect_Demo_Pattern.png -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo_Pattern.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 529a51ce456fc487db93a64ec7937211 3 | timeCreated: 1502934796 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 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: 1 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: -3 28 | maxTextureSize: 512 29 | textureSettings: 30 | filterMode: 1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 2 45 | alphaIsTransparency: 1 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 256 55 | textureFormat: -1 56 | textureCompression: 0 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 256 63 | textureFormat: -1 64 | textureCompression: 0 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: iPhone 70 | maxTextureSize: 256 71 | textureFormat: -1 72 | textureCompression: 0 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: Android 78 | maxTextureSize: 256 79 | textureFormat: -1 80 | textureCompression: 0 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | - buildTarget: WebGL 86 | maxTextureSize: 256 87 | textureFormat: -1 88 | textureCompression: 0 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | spriteSheet: 94 | serializedVersion: 2 95 | sprites: [] 96 | outline: [] 97 | spritePackingTag: 98 | userData: 99 | assetBundleName: 100 | assetBundleVariant: 101 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo_PropertyControl.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | using UnityEngine.UI; 6 | 7 | public class UIEffect_Demo_PropertyControl : MonoBehaviour 8 | { 9 | [SerializeField] private string m_PropertyName; 10 | [SerializeField] private Object[] m_Objects; 11 | 12 | public void ChangeValue(int value) 13 | { 14 | foreach (var o in m_Objects) 15 | { 16 | if (!o) continue; 17 | 18 | var p = o.GetType().GetProperty(m_PropertyName); 19 | Debug.LogFormat("{0} {1} {2}", o.GetType(), m_PropertyName, p); 20 | 21 | if (p == null) continue; 22 | p.SetValue(o, value, new object[0]); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo_PropertyControl.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 266ce43ae60024ca1844de5ee2a04ea7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Samples~/Demo/UIEffect_Demo_Transition.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3cb99c58283f294a9e51c0c30046b18 3 | timeCreated: 1515075779 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Demo/UITransitionTex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ankh4396/UIEffect/b43e40508b167d143330d8b9eff0d5c9965cdf3c/Samples~/Demo/UITransitionTex.png -------------------------------------------------------------------------------- /Samples~/Demo/UITransitionTex.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a74d3d4a498866d44b094d3d3717604d 3 | timeCreated: 1533229728 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 0 12 | linearTexture: 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: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 2 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 10 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 512 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 512 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: Android 70 | maxTextureSize: 512 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: WebGL 78 | maxTextureSize: 512 79 | textureFormat: -1 80 | textureCompression: 1 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | - buildTarget: iPhone 86 | maxTextureSize: 512 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | spriteSheet: 94 | serializedVersion: 2 95 | sprites: [] 96 | outline: [] 97 | spritePackingTag: 98 | userData: 99 | assetBundleName: 100 | assetBundleVariant: 101 | -------------------------------------------------------------------------------- /Samples~/Demo/UITransitionTex_Demo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ankh4396/UIEffect/b43e40508b167d143330d8b9eff0d5c9965cdf3c/Samples~/Demo/UITransitionTex_Demo1.png -------------------------------------------------------------------------------- /Samples~/Demo/UITransitionTex_Demo1.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04b808c8e7e2f114aa6bce179817e3b6 3 | timeCreated: 1533229821 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 0 12 | linearTexture: 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: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 2 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 10 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 512 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 512 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: Android 70 | maxTextureSize: 512 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: WebGL 78 | maxTextureSize: 512 79 | textureFormat: -1 80 | textureCompression: 1 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | - buildTarget: iPhone 86 | maxTextureSize: 512 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | spriteSheet: 94 | serializedVersion: 2 95 | sprites: [] 96 | outline: [] 97 | spritePackingTag: 98 | userData: 99 | assetBundleName: 100 | assetBundleVariant: 101 | -------------------------------------------------------------------------------- /Samples~/Demo/UITransitionTex_Demo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ankh4396/UIEffect/b43e40508b167d143330d8b9eff0d5c9965cdf3c/Samples~/Demo/UITransitionTex_Demo2.png -------------------------------------------------------------------------------- /Samples~/Demo/UITransitionTex_Demo2.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8f19718cccf14d4b829474ab19e0c7a 3 | timeCreated: 1533229825 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 0 12 | linearTexture: 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: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 2 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 10 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 512 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 512 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: Android 70 | maxTextureSize: 512 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: WebGL 78 | maxTextureSize: 512 79 | textureFormat: -1 80 | textureCompression: 1 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | - buildTarget: iPhone 86 | maxTextureSize: 512 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | spriteSheet: 94 | serializedVersion: 2 95 | sprites: [] 96 | outline: [] 97 | spritePackingTag: 98 | userData: 99 | assetBundleName: 100 | assetBundleVariant: 101 | -------------------------------------------------------------------------------- /Samples~/Demo/UITransitionTex_Demo3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ankh4396/UIEffect/b43e40508b167d143330d8b9eff0d5c9965cdf3c/Samples~/Demo/UITransitionTex_Demo3.png -------------------------------------------------------------------------------- /Samples~/Demo/UITransitionTex_Demo3.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87e2a5102f952174eb7505e5cff15bda 3 | timeCreated: 1533231485 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 0 12 | linearTexture: 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: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 2 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 10 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 512 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 512 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: Android 70 | maxTextureSize: 512 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: WebGL 78 | maxTextureSize: 512 79 | textureFormat: -1 80 | textureCompression: 1 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | - buildTarget: iPhone 86 | maxTextureSize: 512 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | spriteSheet: 94 | serializedVersion: 2 95 | sprites: [] 96 | outline: [] 97 | spritePackingTag: 98 | userData: 99 | assetBundleName: 100 | assetBundleVariant: 101 | -------------------------------------------------------------------------------- /Samples~/Demo/UITransitionTex_Demo4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ankh4396/UIEffect/b43e40508b167d143330d8b9eff0d5c9965cdf3c/Samples~/Demo/UITransitionTex_Demo4.png -------------------------------------------------------------------------------- /Samples~/Demo/UITransitionTex_Demo4.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24f06a4f5c47b464e9762d2887848f04 3 | timeCreated: 1533231480 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | sRGBTexture: 0 12 | linearTexture: 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: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 2 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 10 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 512 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 512 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: Android 70 | maxTextureSize: 512 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: WebGL 78 | maxTextureSize: 512 79 | textureFormat: -1 80 | textureCompression: 1 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | - buildTarget: iPhone 86 | maxTextureSize: 512 87 | textureFormat: -1 88 | textureCompression: 1 89 | compressionQuality: 50 90 | crunchedCompression: 0 91 | allowsAlphaSplitting: 0 92 | overridden: 0 93 | spriteSheet: 94 | serializedVersion: 2 95 | sprites: [] 96 | outline: [] 97 | spritePackingTag: 98 | userData: 99 | assetBundleName: 100 | assetBundleVariant: 101 | -------------------------------------------------------------------------------- /Samples~/Demo/UITransition_Art.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ankh4396/UIEffect/b43e40508b167d143330d8b9eff0d5c9965cdf3c/Samples~/Demo/UITransition_Art.png -------------------------------------------------------------------------------- /Samples~/Demo/UITransition_Art.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5e1e56d8affdfc47858b4e7000f1d60 3 | timeCreated: 1533229376 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 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: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: Android 70 | maxTextureSize: 2048 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | - buildTarget: WebGL 78 | maxTextureSize: 2048 79 | textureFormat: -1 80 | textureCompression: 1 81 | compressionQuality: 50 82 | crunchedCompression: 0 83 | allowsAlphaSplitting: 0 84 | overridden: 0 85 | spriteSheet: 86 | serializedVersion: 2 87 | sprites: [] 88 | outline: [] 89 | spritePackingTag: 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a75d49073646347b1955a9f9df36cc45 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Scripts/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04feaefc7cdee4c13abcd553a1a6e3a9 3 | folderAsset: yes 4 | timeCreated: 1528368324 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Scripts/Common/BaseMaterialEffect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using UnityEngine; 7 | using UnityEngine.UI; 8 | 9 | namespace Coffee.UIEffects 10 | { 11 | /// 12 | /// Abstract effect base for UI. 13 | /// 14 | [DisallowMultipleComponent] 15 | public abstract class BaseMaterialEffect : BaseMeshEffect, IParameterTexture, IMaterialModifier 16 | { 17 | protected static readonly Hash128 k_InvalidHash = new Hash128(); 18 | protected static readonly List s_TempVerts = new List(); 19 | private static readonly StringBuilder s_StringBuilder = new StringBuilder(); 20 | 21 | Hash128 _effectMaterialHash; 22 | 23 | /// 24 | /// Gets or sets the parameter index. 25 | /// 26 | public int parameterIndex { get; set; } 27 | 28 | /// 29 | /// Gets the parameter texture. 30 | /// 31 | public virtual ParameterTexture paramTex 32 | { 33 | get { return null; } 34 | } 35 | 36 | /// 37 | /// Mark the vertices as dirty. 38 | /// 39 | public void SetMaterialDirty() 40 | { 41 | connector.SetMaterialDirty(graphic); 42 | 43 | foreach (var effect in syncEffects) 44 | { 45 | effect.SetMaterialDirty(); 46 | } 47 | } 48 | 49 | public virtual Hash128 GetMaterialHash(Material baseMaterial) 50 | { 51 | return k_InvalidHash; 52 | } 53 | 54 | public Material GetModifiedMaterial(Material baseMaterial) 55 | { 56 | return GetModifiedMaterial(baseMaterial, graphic); 57 | } 58 | 59 | public virtual Material GetModifiedMaterial(Material baseMaterial, Graphic graphic) 60 | { 61 | if (!isActiveAndEnabled) return baseMaterial; 62 | 63 | var oldHash = _effectMaterialHash; 64 | _effectMaterialHash = GetMaterialHash(baseMaterial); 65 | var modifiedMaterial = baseMaterial; 66 | if (_effectMaterialHash.isValid) 67 | { 68 | modifiedMaterial = MaterialCache.Register(baseMaterial, _effectMaterialHash, ModifyMaterial, graphic); 69 | } 70 | 71 | MaterialCache.Unregister(oldHash); 72 | 73 | return modifiedMaterial; 74 | } 75 | 76 | // protected bool isTMProMobile (Material material) 77 | // { 78 | // return material && material.shader && material.shader.name.StartsWith ("TextMeshPro/Mobile/", StringComparison.Ordinal); 79 | // } 80 | 81 | public virtual void ModifyMaterial(Material newMaterial, Graphic graphic) 82 | { 83 | if (isActiveAndEnabled && paramTex != null) 84 | paramTex.RegisterMaterial(newMaterial); 85 | } 86 | 87 | protected void SetShaderVariants(Material newMaterial, params object[] variants) 88 | { 89 | // Set shader keywords as variants 90 | var keywords = variants.Where(x => 0 < (int) x) 91 | .Select(x => x.ToString().ToUpper()) 92 | .Concat(newMaterial.shaderKeywords) 93 | .Distinct() 94 | .ToArray(); 95 | newMaterial.shaderKeywords = keywords; 96 | 97 | // Add variant name 98 | s_StringBuilder.Length = 0; 99 | s_StringBuilder.Append(Path.GetFileName(newMaterial.shader.name)); 100 | foreach (var keyword in keywords) 101 | { 102 | s_StringBuilder.Append("-"); 103 | s_StringBuilder.Append(keyword); 104 | } 105 | 106 | newMaterial.name = s_StringBuilder.ToString(); 107 | } 108 | 109 | #if UNITY_EDITOR 110 | protected override void Reset() 111 | { 112 | if (!isActiveAndEnabled) return; 113 | SetMaterialDirty(); 114 | SetVerticesDirty(); 115 | SetEffectParamsDirty(); 116 | } 117 | 118 | protected override void OnValidate() 119 | { 120 | if (!isActiveAndEnabled) return; 121 | SetVerticesDirty(); 122 | SetEffectParamsDirty(); 123 | } 124 | #endif 125 | 126 | /// 127 | /// This function is called when the object becomes enabled and active. 128 | /// 129 | protected override void OnEnable() 130 | { 131 | base.OnEnable(); 132 | 133 | if (paramTex != null) 134 | { 135 | paramTex.Register(this); 136 | } 137 | 138 | SetMaterialDirty(); 139 | SetEffectParamsDirty(); 140 | 141 | // foreach (var mr in GetComponentsInChildren ()) 142 | // { 143 | // mr.GetComponent ().SetMaterialDirty (); 144 | // mr.GetComponent ().SetVerticesDirty (); 145 | // } 146 | } 147 | 148 | /// 149 | /// This function is called when the behaviour becomes disabled () or inactive. 150 | /// 151 | protected override void OnDisable() 152 | { 153 | base.OnDisable(); 154 | 155 | SetMaterialDirty(); 156 | 157 | if (paramTex != null) 158 | { 159 | paramTex.Unregister(this); 160 | } 161 | 162 | MaterialCache.Unregister(_effectMaterialHash); 163 | _effectMaterialHash = k_InvalidHash; 164 | } 165 | 166 | // protected override void OnDidApplyAnimationProperties() 167 | // { 168 | // SetEffectParamsDirty(); 169 | // } 170 | 171 | // protected override void OnTextChanged (UnityEngine.Object obj) 172 | // { 173 | // base.OnTextChanged (obj); 174 | // 175 | // 176 | // foreach (var sm in GetComponentsInChildren ()) 177 | // { 178 | // if(!sm.GetComponent()) 179 | // { 180 | // var mr = sm.gameObject.AddComponent (); 181 | // 182 | // targetGraphic.SetAllDirty (); 183 | // //targetGraphic.SetVerticesDirty (); 184 | // 185 | // //mr.GetComponent ().SetMaterialDirty (); 186 | // //mr.GetComponent ().SetVerticesDirty (); 187 | // 188 | // 189 | // } 190 | // } 191 | // } 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /Scripts/Common/BaseMaterialEffect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8b7ed62cf1444b4ebfc5e5338bc6682 3 | timeCreated: 1485321967 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Common/BaseMeshEffect.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using UnityEngine.EventSystems; 4 | using UnityEngine.UI; 5 | 6 | namespace Coffee.UIEffects 7 | { 8 | /// 9 | /// Base class for effects that modify the generated Mesh. 10 | /// It works well not only for standard Graphic components (Image, RawImage, Text, etc.) but also for TextMeshPro and TextMeshProUGUI. 11 | /// 12 | [RequireComponent(typeof(Graphic))] 13 | [RequireComponent(typeof(RectTransform))] 14 | [ExecuteInEditMode] 15 | public abstract class BaseMeshEffect : UIBehaviour, IMeshModifier 16 | { 17 | RectTransform _rectTransform; 18 | Graphic _graphic; 19 | GraphicConnector _connector; 20 | 21 | /// 22 | /// The Graphic attached to this GameObject. 23 | /// 24 | protected GraphicConnector connector 25 | { 26 | get { return _connector ?? (_connector = GraphicConnector.FindConnector(graphic)); } 27 | } 28 | 29 | /// 30 | /// The Graphic attached to this GameObject. 31 | /// 32 | public Graphic graphic 33 | { 34 | get { return _graphic ? _graphic : _graphic = GetComponent(); } 35 | } 36 | 37 | /// 38 | /// The RectTransform attached to this GameObject. 39 | /// 40 | protected RectTransform rectTransform 41 | { 42 | get { return _rectTransform ? _rectTransform : _rectTransform = GetComponent(); } 43 | } 44 | 45 | internal readonly List syncEffects = new List(0); 46 | 47 | /// 48 | /// Call used to modify mesh. (legacy) 49 | /// 50 | /// Mesh. 51 | public virtual void ModifyMesh(Mesh mesh) 52 | { 53 | } 54 | 55 | /// 56 | /// Call used to modify mesh. 57 | /// 58 | /// VertexHelper. 59 | public virtual void ModifyMesh(VertexHelper vh) 60 | { 61 | ModifyMesh(vh, graphic); 62 | } 63 | 64 | public virtual void ModifyMesh(VertexHelper vh, Graphic graphic) 65 | { 66 | } 67 | 68 | /// 69 | /// Mark the vertices as dirty. 70 | /// 71 | protected virtual void SetVerticesDirty() 72 | { 73 | connector.SetVerticesDirty(graphic); 74 | 75 | foreach (var effect in syncEffects) 76 | { 77 | effect.SetVerticesDirty(); 78 | } 79 | 80 | // #if TMP_PRESENT 81 | // if (textMeshPro) 82 | // { 83 | // foreach (var info in textMeshPro.textInfo.meshInfo) 84 | // { 85 | // var mesh = info.mesh; 86 | // if (mesh) 87 | // { 88 | // mesh.Clear(); 89 | // mesh.vertices = info.vertices; 90 | // mesh.uv = info.uvs0; 91 | // mesh.uv2 = info.uvs2; 92 | // mesh.colors32 = info.colors32; 93 | // mesh.normals = info.normals; 94 | // mesh.tangents = info.tangents; 95 | // mesh.triangles = info.triangles; 96 | // } 97 | // } 98 | // 99 | // if (canvasRenderer) 100 | // { 101 | // canvasRenderer.SetMesh(textMeshPro.mesh); 102 | // 103 | // GetComponentsInChildren(false, s_SubMeshUIs); 104 | // foreach (var sm in s_SubMeshUIs) 105 | // { 106 | // sm.canvasRenderer.SetMesh(sm.mesh); 107 | // } 108 | // 109 | // s_SubMeshUIs.Clear(); 110 | // } 111 | // 112 | // textMeshPro.havePropertiesChanged = true; 113 | // } 114 | // else 115 | // #endif 116 | // if (graphic) 117 | // { 118 | // graphic.SetVerticesDirty(); 119 | // } 120 | } 121 | 122 | 123 | //################################ 124 | // Protected Members. 125 | //################################ 126 | /// 127 | /// Should the effect modify the mesh directly for TMPro? 128 | /// 129 | // protected virtual bool isLegacyMeshModifier 130 | // { 131 | // get { return false; } 132 | // } 133 | // protected virtual void Initialize() 134 | // { 135 | // if (_initialized) return; 136 | // 137 | // _initialized = true; 138 | // _graphic = _graphic ? _graphic : GetComponent(); 139 | // 140 | // _connector = GraphicConnector.FindConnector(_graphic); 141 | // 142 | // // _canvasRenderer = _canvasRenderer ?? GetComponent (); 143 | // _rectTransform = _rectTransform ? _rectTransform : GetComponent(); 144 | // // #if TMP_PRESENT 145 | // // _textMeshPro = _textMeshPro ?? GetComponent (); 146 | // // #endif 147 | // } 148 | 149 | /// 150 | /// This function is called when the object becomes enabled and active. 151 | /// 152 | protected override void OnEnable() 153 | { 154 | connector.OnEnable(graphic); 155 | SetVerticesDirty(); 156 | 157 | // SetVerticesDirty(); 158 | // #if TMP_PRESENT 159 | // if (textMeshPro) 160 | // { 161 | // TMPro_EventManager.TEXT_CHANGED_EVENT.Add (OnTextChanged); 162 | // } 163 | // #endif 164 | // 165 | // #if UNITY_EDITOR && TMP_PRESENT 166 | // if (graphic && textMeshPro) 167 | // { 168 | // GraphicRebuildTracker.TrackGraphic (graphic); 169 | // } 170 | // #endif 171 | // 172 | // #if UNITY_5_6_OR_NEWER 173 | // if (graphic) 174 | // { 175 | // AdditionalCanvasShaderChannels channels = requiredChannels; 176 | // var canvas = graphic.canvas; 177 | // if (canvas && (canvas.additionalShaderChannels & channels) != channels) 178 | // { 179 | // Debug.LogWarningFormat (this, "Enable {1} of Canvas.additionalShaderChannels to use {0}.", GetType ().Name, channels); 180 | // } 181 | // } 182 | // #endif 183 | } 184 | 185 | /// 186 | /// This function is called when the behaviour becomes disabled () or inactive. 187 | /// 188 | protected override void OnDisable() 189 | { 190 | connector.OnDisable(graphic); 191 | SetVerticesDirty(); 192 | } 193 | 194 | /// 195 | /// Mark the effect parameters as dirty. 196 | /// 197 | protected virtual void SetEffectParamsDirty() 198 | { 199 | if (!isActiveAndEnabled) return; 200 | SetVerticesDirty(); 201 | } 202 | 203 | /// 204 | /// Callback for when properties have been changed by animation. 205 | /// 206 | protected override void OnDidApplyAnimationProperties() 207 | { 208 | if (!isActiveAndEnabled) return; 209 | SetEffectParamsDirty(); 210 | } 211 | 212 | #if UNITY_EDITOR 213 | protected override void Reset() 214 | { 215 | if (!isActiveAndEnabled) return; 216 | SetVerticesDirty(); 217 | } 218 | 219 | /// 220 | /// This function is called when the script is loaded or a value is changed in the inspector (Called in the editor only). 221 | /// 222 | protected override void OnValidate() 223 | { 224 | if (!isActiveAndEnabled) return; 225 | SetEffectParamsDirty(); 226 | } 227 | #endif 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /Scripts/Common/BaseMeshEffect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 229ee7044e2514b0e9bd9fd40a2baa3a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Common/EffectPlayer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace Coffee.UIEffects 6 | { 7 | /// 8 | /// Effect player. 9 | /// 10 | [Serializable] 11 | public class EffectPlayer 12 | { 13 | //################################ 14 | // Public Members. 15 | //################################ 16 | /// 17 | /// Gets or sets a value indicating whether is playing. 18 | /// 19 | [Header("Effect Player")] [Tooltip("Playing.")] 20 | public bool play = false; 21 | 22 | /// 23 | /// Gets or sets the delay before looping. 24 | /// 25 | [Tooltip("Initial play delay.")] [Range(0f, 10f)] 26 | public float initialPlayDelay = 0; 27 | 28 | /// 29 | /// Gets or sets the duration. 30 | /// 31 | [Tooltip("Duration.")] [Range(0.01f, 10f)] 32 | public float duration = 1; 33 | 34 | /// 35 | /// Gets or sets a value indicating whether can loop. 36 | /// 37 | [Tooltip("Loop.")] public bool loop = false; 38 | 39 | /// 40 | /// Gets or sets the delay before looping. 41 | /// 42 | [Tooltip("Delay before looping.")] [Range(0f, 10f)] 43 | public float loopDelay = 0; 44 | 45 | /// 46 | /// Gets or sets the update mode. 47 | /// 48 | [Tooltip("Update mode")] public AnimatorUpdateMode updateMode = AnimatorUpdateMode.Normal; 49 | 50 | static List s_UpdateActions; 51 | 52 | /// 53 | /// Register player. 54 | /// 55 | public void OnEnable(Action callback = null) 56 | { 57 | if (s_UpdateActions == null) 58 | { 59 | s_UpdateActions = new List(); 60 | Canvas.willRenderCanvases += () => 61 | { 62 | var count = s_UpdateActions.Count; 63 | for (int i = 0; i < count; i++) 64 | { 65 | s_UpdateActions[i].Invoke(); 66 | } 67 | }; 68 | } 69 | 70 | s_UpdateActions.Add(OnWillRenderCanvases); 71 | 72 | if (play) 73 | { 74 | _time = -initialPlayDelay; 75 | } 76 | else 77 | { 78 | _time = 0; 79 | } 80 | 81 | _callback = callback; 82 | } 83 | 84 | /// 85 | /// Unregister player. 86 | /// 87 | public void OnDisable() 88 | { 89 | _callback = null; 90 | s_UpdateActions.Remove(OnWillRenderCanvases); 91 | } 92 | 93 | /// 94 | /// Start playing. 95 | /// 96 | public void Play(bool reset, Action callback = null) 97 | { 98 | if (reset) 99 | { 100 | _time = 0; 101 | } 102 | 103 | play = true; 104 | if (callback != null) 105 | { 106 | _callback = callback; 107 | } 108 | } 109 | 110 | /// 111 | /// Stop playing. 112 | /// 113 | public void Stop(bool reset) 114 | { 115 | if (reset) 116 | { 117 | _time = 0; 118 | if (_callback != null) 119 | { 120 | _callback(_time); 121 | } 122 | } 123 | 124 | play = false; 125 | } 126 | 127 | //################################ 128 | // Private Members. 129 | //################################ 130 | float _time = 0; 131 | Action _callback; 132 | 133 | void OnWillRenderCanvases() 134 | { 135 | if (!play || !Application.isPlaying || _callback == null) 136 | { 137 | return; 138 | } 139 | 140 | _time += updateMode == AnimatorUpdateMode.UnscaledTime 141 | ? Time.unscaledDeltaTime 142 | : Time.deltaTime; 143 | var current = _time / duration; 144 | 145 | if (duration <= _time) 146 | { 147 | play = loop; 148 | _time = loop ? -loopDelay : 0; 149 | } 150 | 151 | _callback(current); 152 | } 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /Scripts/Common/EffectPlayer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1656fb67110cd44298010d95c324e87a 3 | timeCreated: 1528296875 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Common/GraphicConnector.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace Coffee.UIEffects 7 | { 8 | public class GraphicConnector 9 | { 10 | private static readonly List s_Connectors = new List(); 11 | 12 | private static readonly Dictionary s_ConnectorMap = 13 | new Dictionary(); 14 | 15 | private static readonly GraphicConnector s_EmptyConnector = new GraphicConnector(); 16 | 17 | #if UNITY_EDITOR 18 | [UnityEditor.InitializeOnLoadMethod] 19 | #endif 20 | [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] 21 | private static void Init() 22 | { 23 | AddConnector(new GraphicConnector()); 24 | } 25 | 26 | protected static void AddConnector(GraphicConnector connector) 27 | { 28 | s_Connectors.Add(connector); 29 | s_Connectors.Sort((x, y) => y.priority - x.priority); 30 | } 31 | 32 | public static GraphicConnector FindConnector(Graphic graphic) 33 | { 34 | if (!graphic) return s_EmptyConnector; 35 | 36 | var type = graphic.GetType(); 37 | GraphicConnector connector = null; 38 | if (s_ConnectorMap.TryGetValue(type, out connector)) return connector; 39 | 40 | foreach (var c in s_Connectors) 41 | { 42 | if (!c.IsValid(graphic)) continue; 43 | 44 | s_ConnectorMap.Add(type, c); 45 | return c; 46 | } 47 | 48 | return s_EmptyConnector; 49 | } 50 | 51 | /// 52 | /// Connector priority. 53 | /// 54 | protected virtual int priority 55 | { 56 | get { return -1; } 57 | } 58 | 59 | /// 60 | /// Extra channel. 61 | /// 62 | public virtual AdditionalCanvasShaderChannels extraChannel 63 | { 64 | get { return AdditionalCanvasShaderChannels.TexCoord1; } 65 | } 66 | 67 | /// 68 | /// The connector is valid for the component. 69 | /// 70 | protected virtual bool IsValid(Graphic graphic) 71 | { 72 | return true; 73 | } 74 | 75 | /// 76 | /// Find effect shader. 77 | /// 78 | public virtual Shader FindShader(string shaderName) 79 | { 80 | return Shader.Find("Hidden/" + shaderName); 81 | } 82 | 83 | /// 84 | /// This function is called when the object becomes enabled and active. 85 | /// 86 | public virtual void OnEnable(Graphic graphic) 87 | { 88 | } 89 | 90 | /// 91 | /// This function is called when the behaviour becomes disabled () or inactive. 92 | /// 93 | public virtual void OnDisable(Graphic graphic) 94 | { 95 | } 96 | 97 | /// 98 | /// Mark the vertices as dirty. 99 | /// 100 | public virtual void SetVerticesDirty(Graphic graphic) 101 | { 102 | if (graphic) 103 | graphic.SetVerticesDirty(); 104 | } 105 | 106 | /// 107 | /// Mark the material as dirty. 108 | /// 109 | public virtual void SetMaterialDirty(Graphic graphic) 110 | { 111 | if (graphic) 112 | graphic.SetMaterialDirty(); 113 | } 114 | 115 | /// 116 | /// Gets position factor for area. 117 | /// 118 | public virtual void GetPositionFactor(EffectArea area, int index, Rect rect, Vector2 position, out float x, out float y) 119 | { 120 | if (area == EffectArea.Fit) 121 | { 122 | x = Mathf.Clamp01((position.x - rect.xMin) / rect.width); 123 | y = Mathf.Clamp01((position.y - rect.yMin) / rect.height); 124 | } 125 | else 126 | { 127 | x = Mathf.Clamp01(position.x / rect.width + 0.5f); 128 | y = Mathf.Clamp01(position.y / rect.height + 0.5f); 129 | } 130 | } 131 | 132 | public virtual bool IsText(Graphic graphic) 133 | { 134 | return graphic && graphic is Text; 135 | } 136 | 137 | public virtual void SetExtraChannel(ref UIVertex vertex, Vector2 value) 138 | { 139 | vertex.uv1 = value; 140 | } 141 | 142 | /// 143 | /// Normalize vertex position by local matrix. 144 | /// 145 | public virtual void GetNormalizedFactor(EffectArea area, int index, Matrix2x3 matrix, Vector2 position, 146 | out Vector2 normalizedPos) 147 | { 148 | normalizedPos = matrix * position; 149 | } 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /Scripts/Common/GraphicConnector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 66636f82e05e6453781a33c8b7da8b93 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Common/MaterialCache.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System; 4 | using UnityEngine; 5 | using System.Text; 6 | using UnityEngine.UI; 7 | 8 | namespace Coffee.UIEffects 9 | { 10 | public class MaterialCache 11 | { 12 | static Dictionary materialMap = new Dictionary(); 13 | 14 | private class MaterialEntry 15 | { 16 | public Material material; 17 | public int referenceCount; 18 | 19 | public void Release() 20 | { 21 | if (material) 22 | { 23 | UnityEngine.Object.DestroyImmediate(material, false); 24 | } 25 | 26 | material = null; 27 | } 28 | } 29 | 30 | #if UNITY_EDITOR 31 | [UnityEditor.InitializeOnLoadMethod] 32 | private static void ClearCache() 33 | { 34 | foreach (var entry in materialMap.Values) 35 | { 36 | entry.Release(); 37 | } 38 | 39 | materialMap.Clear(); 40 | } 41 | #endif 42 | 43 | public static Material Register(Material baseMaterial, Hash128 hash, 44 | System.Action onModifyMaterial, Graphic graphic) 45 | { 46 | if (!hash.isValid) return null; 47 | 48 | MaterialEntry entry; 49 | if (!materialMap.TryGetValue(hash, out entry)) 50 | { 51 | entry = new MaterialEntry() 52 | { 53 | material = new Material(baseMaterial) 54 | { 55 | hideFlags = HideFlags.HideAndDontSave, 56 | }, 57 | }; 58 | 59 | onModifyMaterial(entry.material, graphic); 60 | materialMap.Add(hash, entry); 61 | } 62 | 63 | entry.referenceCount++; 64 | return entry.material; 65 | } 66 | 67 | public static void Unregister(Hash128 hash) 68 | { 69 | MaterialEntry entry; 70 | if (!hash.isValid || !materialMap.TryGetValue(hash, out entry)) return; 71 | if (--entry.referenceCount > 0) return; 72 | 73 | entry.Release(); 74 | materialMap.Remove(hash); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Scripts/Common/MaterialCache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2160d2c55a6100642b6c7ba09df935da 3 | timeCreated: 1528509206 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Common/Matrix2x3.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Coffee.UIEffects 4 | { 5 | /// 6 | /// Matrix2x3. 7 | /// 8 | public struct Matrix2x3 9 | { 10 | public float m00, m01, m02, m10, m11, m12; 11 | 12 | public Matrix2x3(Rect rect, float cos, float sin) 13 | { 14 | const float center = 0.5f; 15 | float dx = -rect.xMin / rect.width - center; 16 | float dy = -rect.yMin / rect.height - center; 17 | m00 = cos / rect.width; 18 | m01 = -sin / rect.height; 19 | m02 = dx * cos - dy * sin + center; 20 | m10 = sin / rect.width; 21 | m11 = cos / rect.height; 22 | m12 = dx * sin + dy * cos + center; 23 | } 24 | 25 | public static Vector2 operator *(Matrix2x3 m, Vector2 v) 26 | { 27 | return new Vector2( 28 | (m.m00 * v.x) + (m.m01 * v.y) + m.m02, 29 | (m.m10 * v.x) + (m.m11 * v.y) + m.m12 30 | ); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Scripts/Common/Matrix2x3.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a9b962044ca64867b713425f7e5daab 3 | timeCreated: 1527590245 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Common/Packer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public static class Packer 6 | { 7 | /// 8 | /// Pack 4 low-precision [0-1] floats values to a float. 9 | /// Each value [0-1] has 64 steps(6 bits). 10 | /// 11 | public static float ToFloat(float x, float y, float z, float w) 12 | { 13 | x = x < 0 ? 0 : 1 < x ? 1 : x; 14 | y = y < 0 ? 0 : 1 < y ? 1 : y; 15 | z = z < 0 ? 0 : 1 < z ? 1 : z; 16 | w = w < 0 ? 0 : 1 < w ? 1 : w; 17 | const int PRECISION = (1 << 6) - 1; 18 | return (Mathf.FloorToInt(w * PRECISION) << 18) 19 | + (Mathf.FloorToInt(z * PRECISION) << 12) 20 | + (Mathf.FloorToInt(y * PRECISION) << 6) 21 | + Mathf.FloorToInt(x * PRECISION); 22 | } 23 | 24 | /// 25 | /// Pack 4 low-precision [0-1] floats values to a float. 26 | /// Each value [0-1] has 64 steps(6 bits). 27 | /// 28 | public static float ToFloat(Vector4 factor) 29 | { 30 | return ToFloat(Mathf.Clamp01(factor.x), Mathf.Clamp01(factor.y), Mathf.Clamp01(factor.z), 31 | Mathf.Clamp01(factor.w)); 32 | } 33 | 34 | /// 35 | /// Pack 1 middle-precision & 2 low-precision [0-1] floats values to a float. 36 | /// z value [0-1] has 4096 steps(12 bits) and xy value [0-1] has 64 steps(6 bits). 37 | /// 38 | public static float ToFloat(float x, float y, float z) 39 | { 40 | x = x < 0 ? 0 : 1 < x ? 1 : x; 41 | y = y < 0 ? 0 : 1 < y ? 1 : y; 42 | z = z < 0 ? 0 : 1 < z ? 1 : z; 43 | const int PRECISION = (1 << 8) - 1; 44 | return (Mathf.FloorToInt(z * PRECISION) << 16) 45 | + (Mathf.FloorToInt(y * PRECISION) << 8) 46 | + Mathf.FloorToInt(x * PRECISION); 47 | } 48 | 49 | /// 50 | /// Pack 2 low-precision [0-1] floats values to a float. 51 | /// Each value [0-1] has 4096 steps(12 bits). 52 | /// 53 | public static float ToFloat(float x, float y) 54 | { 55 | x = x < 0 ? 0 : 1 < x ? 1 : x; 56 | y = y < 0 ? 0 : 1 < y ? 1 : y; 57 | const int PRECISION = (1 << 12) - 1; 58 | return (Mathf.FloorToInt(y * PRECISION) << 12) 59 | + Mathf.FloorToInt(x * PRECISION); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Scripts/Common/Packer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b4970b3a69d3b472b8d66c1d92ec7bad 3 | timeCreated: 1527590285 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Common/ParameterTexture.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using System; 6 | 7 | namespace Coffee.UIEffects 8 | { 9 | public interface IParameterTexture 10 | { 11 | int parameterIndex { get; set; } 12 | 13 | ParameterTexture paramTex { get; } 14 | } 15 | 16 | /// 17 | /// Parameter texture. 18 | /// 19 | [System.Serializable] 20 | public class ParameterTexture 21 | { 22 | //################################ 23 | // Public Members. 24 | //################################ 25 | 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | /// Channels. 30 | /// Instance limit. 31 | /// Property name. 32 | public ParameterTexture(int channels, int instanceLimit, string propertyName) 33 | { 34 | _propertyName = propertyName; 35 | _channels = ((channels - 1) / 4 + 1) * 4; 36 | _instanceLimit = ((instanceLimit - 1) / 2 + 1) * 2; 37 | _data = new byte[_channels * _instanceLimit]; 38 | 39 | _stack = new Stack(_instanceLimit); 40 | for (int i = 1; i < _instanceLimit + 1; i++) 41 | { 42 | _stack.Push(i); 43 | } 44 | } 45 | 46 | 47 | /// 48 | /// Register the specified target. 49 | /// 50 | /// Target. 51 | public void Register(IParameterTexture target) 52 | { 53 | Initialize(); 54 | if (target.parameterIndex <= 0 && 0 < _stack.Count) 55 | { 56 | target.parameterIndex = _stack.Pop(); 57 | // Debug.LogFormat("@@@ Register {0} : {1}", target, target.parameterIndex); 58 | } 59 | } 60 | 61 | /// 62 | /// Unregister the specified target. 63 | /// 64 | /// Target. 65 | public void Unregister(IParameterTexture target) 66 | { 67 | if (0 < target.parameterIndex) 68 | { 69 | // Debug.LogFormat("@@@ Unregister {0} : {1}", target, target.parameterIndex); 70 | _stack.Push(target.parameterIndex); 71 | target.parameterIndex = 0; 72 | } 73 | } 74 | 75 | /// 76 | /// Sets the data. 77 | /// 78 | /// Target. 79 | /// Channel identifier. 80 | /// Value. 81 | public void SetData(IParameterTexture target, int channelId, byte value) 82 | { 83 | int index = (target.parameterIndex - 1) * _channels + channelId; 84 | if (0 < target.parameterIndex && _data[index] != value) 85 | { 86 | _data[index] = value; 87 | _needUpload = true; 88 | } 89 | } 90 | 91 | /// 92 | /// Sets the data. 93 | /// 94 | /// Target. 95 | /// Channel identifier. 96 | /// Value. 97 | public void SetData(IParameterTexture target, int channelId, float value) 98 | { 99 | SetData(target, channelId, (byte) (Mathf.Clamp01(value) * 255)); 100 | } 101 | 102 | /// 103 | /// Registers the material. 104 | /// 105 | /// Mat. 106 | public void RegisterMaterial(Material mat) 107 | { 108 | if (_propertyId == 0) 109 | { 110 | _propertyId = Shader.PropertyToID(_propertyName); 111 | } 112 | 113 | if (mat) 114 | { 115 | mat.SetTexture(_propertyId, _texture); 116 | } 117 | } 118 | 119 | /// 120 | /// Gets the index of the normalized. 121 | /// 122 | /// The normalized index. 123 | /// Target. 124 | public float GetNormalizedIndex(IParameterTexture target) 125 | { 126 | return ((float) target.parameterIndex - 0.5f) / _instanceLimit; 127 | } 128 | 129 | 130 | //################################ 131 | // Private Members. 132 | //################################ 133 | 134 | Texture2D _texture; 135 | bool _needUpload; 136 | int _propertyId; 137 | readonly string _propertyName; 138 | readonly int _channels; 139 | readonly int _instanceLimit; 140 | readonly byte[] _data; 141 | readonly Stack _stack; 142 | static List updates; 143 | 144 | /// 145 | /// Initialize this instance. 146 | /// 147 | void Initialize() 148 | { 149 | #if UNITY_EDITOR 150 | if (!UnityEditor.EditorApplication.isPlaying && UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode) 151 | { 152 | return; 153 | } 154 | #endif 155 | if (updates == null) 156 | { 157 | updates = new List(); 158 | Canvas.willRenderCanvases += () => 159 | { 160 | var count = updates.Count; 161 | for (int i = 0; i < count; i++) 162 | { 163 | updates[i].Invoke(); 164 | } 165 | }; 166 | } 167 | 168 | if (!_texture) 169 | { 170 | bool isLinear = QualitySettings.activeColorSpace == ColorSpace.Linear; 171 | _texture = new Texture2D(_channels / 4, _instanceLimit, TextureFormat.RGBA32, false, isLinear); 172 | _texture.filterMode = FilterMode.Point; 173 | _texture.wrapMode = TextureWrapMode.Clamp; 174 | 175 | updates.Add(UpdateParameterTexture); 176 | _needUpload = true; 177 | } 178 | } 179 | 180 | void UpdateParameterTexture() 181 | { 182 | if (_needUpload && _texture) 183 | { 184 | _needUpload = false; 185 | _texture.LoadRawTextureData(_data); 186 | _texture.Apply(false, false); 187 | } 188 | } 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /Scripts/Common/ParameterTexture.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65eafa89b3a3a494a99e185423ba6cad 3 | timeCreated: 1533006319 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee1bfc8c299e6482cb7175ba2f94495a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Scripts/Editor/ImportSampleMenu.cs: -------------------------------------------------------------------------------- 1 | #if !UNITY_2019_1_OR_NEWER 2 | using System.IO; 3 | using System.Linq; 4 | using System.Text.RegularExpressions; 5 | using UnityEditor; 6 | 7 | namespace Coffee.UIEffects 8 | { 9 | public static class ImportSampleMenu 10 | { 11 | private const string jsonGuid = "546af75b6221c4768be79d67c9cea1fb"; 12 | 13 | [MenuItem("Assets/Samples/UIEffect/Import Demo")] 14 | private static void ImportDemo() 15 | { 16 | ImportSample(jsonGuid, "Demo"); 17 | } 18 | 19 | private static void ImportSample(string jsonGuid, string sampleName) 20 | { 21 | var jsonPath = AssetDatabase.GUIDToAssetPath(jsonGuid); 22 | var json = File.ReadAllText(jsonPath); 23 | var version = Regex.Match(json, "\"version\"\\s*:\\s*\"([^\"]+)\"").Groups[1].Value; 24 | var displayName = Regex.Match(json, "\"displayName\"\\s*:\\s*\"([^\"]+)\"").Groups[1].Value; 25 | var src = string.Format("{0}/Samples~/{1}", Path.GetDirectoryName(jsonPath), sampleName); 26 | var srcAlt = string.Format("{0}/Samples/{1}", Path.GetDirectoryName(jsonPath), sampleName); 27 | var dst = string.Format("Assets/Samples/{0}/{1}/{2}", displayName, version, sampleName); 28 | var previousPath = GetPreviousSamplePath(displayName, sampleName); 29 | 30 | // Remove the previous sample directory. 31 | if (!string.IsNullOrEmpty(previousPath)) 32 | { 33 | var msg = "A different version of the sample is already imported at\n\n" 34 | + previousPath 35 | + "\n\nIt will be deleted when you update. Are you sure you want to continue?"; 36 | if (!EditorUtility.DisplayDialog("Sample Importer", msg, "OK", "Cancel")) 37 | return; 38 | 39 | FileUtil.DeleteFileOrDirectory(previousPath); 40 | 41 | var metaFile = previousPath + ".meta"; 42 | if (File.Exists(metaFile)) 43 | FileUtil.DeleteFileOrDirectory(metaFile); 44 | } 45 | 46 | if (!Directory.Exists(dst)) 47 | FileUtil.DeleteFileOrDirectory(dst); 48 | 49 | var dstDir = Path.GetDirectoryName(dst); 50 | if (!Directory.Exists(dstDir)) 51 | Directory.CreateDirectory(dstDir); 52 | 53 | if (Directory.Exists(src)) 54 | FileUtil.CopyFileOrDirectory(src, dst); 55 | else if (Directory.Exists(srcAlt)) 56 | FileUtil.CopyFileOrDirectory(srcAlt, dst); 57 | else 58 | throw new DirectoryNotFoundException(src); 59 | 60 | AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive); 61 | } 62 | 63 | private static string GetPreviousSamplePath(string displayName, string sampleName) 64 | { 65 | var sampleRoot = string.Format("Assets/Samples/{0}", displayName); 66 | var sampleRootInfo = new DirectoryInfo(sampleRoot); 67 | if (!sampleRootInfo.Exists) return null; 68 | 69 | return sampleRootInfo.GetDirectories() 70 | .Select(versionDir => Path.Combine(versionDir.ToString(), sampleName)) 71 | .FirstOrDefault(Directory.Exists); 72 | } 73 | } 74 | } 75 | #endif 76 | -------------------------------------------------------------------------------- /Scripts/Editor/ImportSampleMenu.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1d002a431e7c4b1ca5db78469cb0d1c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Editor/MaterialDirtyScope.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace Coffee.UIEffects.Editors 6 | { 7 | /// 8 | /// Changes in this scope cause the graphic's material to be dirty. 9 | /// When you change a property, it marks the material as dirty. 10 | /// 11 | internal class MaterialDirtyScope : EditorGUI.ChangeCheckScope 12 | { 13 | readonly Object[] targets; 14 | 15 | public MaterialDirtyScope(Object[] targets) 16 | { 17 | this.targets = targets; 18 | } 19 | 20 | protected override void CloseScope() 21 | { 22 | if (changed) 23 | { 24 | foreach (var effect in targets.OfType()) 25 | { 26 | effect.SetMaterialDirty(); 27 | } 28 | } 29 | 30 | base.CloseScope(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Scripts/Editor/MaterialDirtyScope.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16857cac7da564347876420ef55a734a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/Editor/UIDissolveEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEditorInternal; 3 | using UnityEngine; 4 | using System.Linq; 5 | using System.Collections.Generic; 6 | using UnityEngine.UI; 7 | 8 | namespace Coffee.UIEffects.Editors 9 | { 10 | /// 11 | /// UIEffect editor. 12 | /// 13 | [CustomEditor(typeof(UIDissolve))] 14 | [CanEditMultipleObjects] 15 | public class UIDissolveEditor : Editor 16 | { 17 | SerializedProperty _spEffectFactor; 18 | SerializedProperty _spWidth; 19 | SerializedProperty _spColor; 20 | SerializedProperty _spSoftness; 21 | SerializedProperty _spColorMode; 22 | SerializedProperty _spTransitionTexture; 23 | SerializedProperty _spEffectArea; 24 | SerializedProperty _spKeepAspectRatio; 25 | SerializedProperty _spReverse; 26 | SerializedProperty _spPlay; 27 | SerializedProperty _spLoop; 28 | SerializedProperty _spLoopDelay; 29 | SerializedProperty _spDuration; 30 | SerializedProperty _spInitialPlayDelay; 31 | SerializedProperty _spUpdateMode; 32 | 33 | //################################ 34 | // Public/Protected Members. 35 | //################################ 36 | /// 37 | /// This function is called when the object becomes enabled and active. 38 | /// 39 | protected void OnEnable() 40 | { 41 | _spEffectFactor = serializedObject.FindProperty("m_EffectFactor"); 42 | _spEffectArea = serializedObject.FindProperty("m_EffectArea"); 43 | _spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio"); 44 | _spWidth = serializedObject.FindProperty("m_Width"); 45 | _spColor = serializedObject.FindProperty("m_Color"); 46 | _spSoftness = serializedObject.FindProperty("m_Softness"); 47 | _spColorMode = serializedObject.FindProperty("m_ColorMode"); 48 | _spTransitionTexture = serializedObject.FindProperty("m_TransitionTexture"); 49 | _spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio"); 50 | _spReverse = serializedObject.FindProperty("m_Reverse"); 51 | var player = serializedObject.FindProperty("m_Player"); 52 | _spPlay = player.FindPropertyRelative("play"); 53 | _spDuration = player.FindPropertyRelative("duration"); 54 | _spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay"); 55 | _spLoop = player.FindPropertyRelative("loop"); 56 | _spLoopDelay = player.FindPropertyRelative("loopDelay"); 57 | _spUpdateMode = player.FindPropertyRelative("updateMode"); 58 | } 59 | 60 | /// 61 | /// Implement this function to make a custom inspector. 62 | /// 63 | public override void OnInspectorGUI() 64 | { 65 | serializedObject.Update(); 66 | 67 | //================ 68 | // Effect setting. 69 | //================ 70 | EditorGUILayout.PropertyField(_spEffectFactor); 71 | EditorGUILayout.PropertyField(_spWidth); 72 | EditorGUILayout.PropertyField(_spSoftness); 73 | EditorGUILayout.PropertyField(_spColor); 74 | 75 | using (new MaterialDirtyScope(targets)) 76 | { 77 | EditorGUILayout.PropertyField(_spColorMode); 78 | EditorGUILayout.PropertyField(_spTransitionTexture); 79 | } 80 | 81 | 82 | //================ 83 | // Advanced option. 84 | //================ 85 | EditorGUILayout.PropertyField(_spEffectArea); 86 | EditorGUILayout.PropertyField(_spKeepAspectRatio); 87 | 88 | 89 | //================ 90 | // Effect player. 91 | //================ 92 | EditorGUILayout.PropertyField(_spPlay); 93 | EditorGUILayout.PropertyField(_spDuration); 94 | EditorGUILayout.PropertyField(_spInitialPlayDelay); 95 | EditorGUILayout.PropertyField(_spLoop); 96 | EditorGUILayout.PropertyField(_spLoopDelay); 97 | EditorGUILayout.PropertyField(_spUpdateMode); 98 | EditorGUILayout.PropertyField(_spReverse); 99 | 100 | 101 | // Debug. 102 | using (new EditorGUI.DisabledGroupScope(!Application.isPlaying)) 103 | using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox)) 104 | { 105 | GUILayout.Label("Debug"); 106 | 107 | if (GUILayout.Button("Play", "ButtonLeft")) 108 | { 109 | (target as UIDissolve).Play(); 110 | } 111 | 112 | if (GUILayout.Button("Stop", "ButtonRight")) 113 | { 114 | (target as UIDissolve).Stop(); 115 | } 116 | } 117 | 118 | serializedObject.ApplyModifiedProperties(); 119 | } 120 | } 121 | } -------------------------------------------------------------------------------- /Scripts/Editor/UIDissolveEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f7f7349a5d61649b69946853317db047 3 | timeCreated: 1538806040 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Editor/UIEffect-Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UIEffect-Editor", 3 | "references": [ 4 | "UIEffect" 5 | ], 6 | "optionalUnityReferences": [], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": false, 15 | "defineConstraints": [] 16 | } -------------------------------------------------------------------------------- /Scripts/Editor/UIEffect-Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a03bd468489b4da08c028255886b30d 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Scripts/Editor/UIEffectEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEditorInternal; 3 | using UnityEngine; 4 | using System.Linq; 5 | using System; 6 | 7 | namespace Coffee.UIEffects.Editors 8 | { 9 | /// 10 | /// UIEffect editor. 11 | /// 12 | [CustomEditor(typeof(UIEffect))] 13 | [CanEditMultipleObjects] 14 | public class UIEffectEditor : Editor 15 | { 16 | SerializedProperty _spEffectMode; 17 | SerializedProperty _spEffectFactor; 18 | SerializedProperty _spColorMode; 19 | SerializedProperty _spColorFactor; 20 | SerializedProperty _spBlurMode; 21 | SerializedProperty _spBlurFactor; 22 | SerializedProperty _spAdvancedBlur; 23 | 24 | protected void OnEnable() 25 | { 26 | _spEffectMode = serializedObject.FindProperty("m_EffectMode"); 27 | _spEffectFactor = serializedObject.FindProperty("m_EffectFactor"); 28 | _spColorMode = serializedObject.FindProperty("m_ColorMode"); 29 | _spColorFactor = serializedObject.FindProperty("m_ColorFactor"); 30 | _spBlurMode = serializedObject.FindProperty("m_BlurMode"); 31 | _spBlurFactor = serializedObject.FindProperty("m_BlurFactor"); 32 | _spAdvancedBlur = serializedObject.FindProperty("m_AdvancedBlur"); 33 | } 34 | 35 | public override void OnInspectorGUI() 36 | { 37 | //================ 38 | // Effect setting. 39 | //================ 40 | using (new MaterialDirtyScope(targets)) 41 | EditorGUILayout.PropertyField(_spEffectMode); 42 | 43 | // When effect is enable, show parameters. 44 | if (_spEffectMode.intValue != (int) EffectMode.None) 45 | { 46 | EditorGUI.indentLevel++; 47 | EditorGUILayout.PropertyField(_spEffectFactor); 48 | EditorGUI.indentLevel--; 49 | } 50 | 51 | 52 | //================ 53 | // Color setting. 54 | //================ 55 | using (new MaterialDirtyScope(targets)) 56 | EditorGUILayout.PropertyField(_spColorMode); 57 | 58 | // When color is enable, show parameters. 59 | { 60 | EditorGUI.indentLevel++; 61 | EditorGUILayout.PropertyField(_spColorFactor); 62 | EditorGUI.indentLevel--; 63 | } 64 | 65 | 66 | //================ 67 | // Blur setting. 68 | //================ 69 | using (new MaterialDirtyScope(targets)) 70 | EditorGUILayout.PropertyField(_spBlurMode); 71 | 72 | // When blur is enable, show parameters. 73 | if (_spBlurMode.intValue != (int) BlurMode.None) 74 | { 75 | EditorGUI.indentLevel++; 76 | EditorGUILayout.PropertyField(_spBlurFactor); 77 | 78 | // When you change a property, it marks the material as dirty. 79 | using (new MaterialDirtyScope(targets)) 80 | EditorGUILayout.PropertyField(_spAdvancedBlur); 81 | EditorGUI.indentLevel--; 82 | 83 | // Advanced blur requires uv2 channel. 84 | if (_spAdvancedBlur.boolValue) 85 | { 86 | ShowCanvasChannelsWarning(); 87 | } 88 | } 89 | 90 | serializedObject.ApplyModifiedProperties(); 91 | } 92 | 93 | void ShowCanvasChannelsWarning() 94 | { 95 | var effect = target as UIEffect; 96 | if (effect == null || !effect.graphic) return; 97 | 98 | var channel = effect.uvMaskChannel; 99 | var canvas = effect.graphic.canvas; 100 | if (canvas == null || (canvas.additionalShaderChannels & channel) == channel) return; 101 | 102 | EditorGUILayout.BeginHorizontal(); 103 | { 104 | var msg = string.Format("Enable '{0}' of Canvas.additionalShaderChannels to use 'UIEffect'.", channel); 105 | EditorGUILayout.HelpBox(msg, MessageType.Warning); 106 | if (GUILayout.Button("Fix")) 107 | { 108 | canvas.additionalShaderChannels |= channel; 109 | } 110 | } 111 | EditorGUILayout.EndHorizontal(); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /Scripts/Editor/UIEffectEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f7e9f2ce1cb543ca88606769affbe24 3 | timeCreated: 1487152293 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Editor/UIGradientEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using UnityEngine.UI; 4 | 5 | namespace Coffee.UIEffects.Editors 6 | { 7 | /// 8 | /// UIEffect editor. 9 | /// 10 | [CustomEditor(typeof(UIGradient))] 11 | [CanEditMultipleObjects] 12 | public class UIGradientEditor : Editor 13 | { 14 | private static readonly GUIContent k_TextVerticalOffset = new GUIContent("Vertical Offset"); 15 | private static readonly GUIContent k_TextHorizontalOffset = new GUIContent("Horizontal Offset"); 16 | private static readonly GUIContent k_TextOffset = new GUIContent("Offset"); 17 | private static readonly GUIContent k_TextLeft = new GUIContent("Left"); 18 | private static readonly GUIContent k_TextRight = new GUIContent("Right"); 19 | private static readonly GUIContent k_TextTop = new GUIContent("Top"); 20 | private static readonly GUIContent k_TextBottom = new GUIContent("Bottom"); 21 | private static readonly GUIContent k_TextColor1 = new GUIContent("Color 1"); 22 | private static readonly GUIContent k_TextColor2 = new GUIContent("Color 2"); 23 | private static readonly GUIContent k_TextDiagonalColor = new GUIContent("Diagonal Color"); 24 | 25 | SerializedProperty _spDirection; 26 | SerializedProperty _spColor1; 27 | SerializedProperty _spColor2; 28 | SerializedProperty _spColor3; 29 | SerializedProperty _spColor4; 30 | SerializedProperty _spRotation; 31 | SerializedProperty _spOffset1; 32 | SerializedProperty _spOffset2; 33 | SerializedProperty _spIgnoreAspectRatio; 34 | SerializedProperty _spGradientStyle; 35 | SerializedProperty _spColorSpace; 36 | 37 | //################################ 38 | // Public/Protected Members. 39 | //################################ 40 | /// 41 | /// This function is called when the object becomes enabled and active. 42 | /// 43 | protected void OnEnable() 44 | { 45 | _spIgnoreAspectRatio = serializedObject.FindProperty("m_IgnoreAspectRatio"); 46 | _spDirection = serializedObject.FindProperty("m_Direction"); 47 | _spColor1 = serializedObject.FindProperty("m_Color1"); 48 | _spColor2 = serializedObject.FindProperty("m_Color2"); 49 | _spColor3 = serializedObject.FindProperty("m_Color3"); 50 | _spColor4 = serializedObject.FindProperty("m_Color4"); 51 | _spRotation = serializedObject.FindProperty("m_Rotation"); 52 | _spOffset1 = serializedObject.FindProperty("m_Offset1"); 53 | _spOffset2 = serializedObject.FindProperty("m_Offset2"); 54 | _spGradientStyle = serializedObject.FindProperty("m_GradientStyle"); 55 | _spColorSpace = serializedObject.FindProperty("m_ColorSpace"); 56 | } 57 | 58 | public override void OnInspectorGUI() 59 | { 60 | serializedObject.Update(); 61 | 62 | //================ 63 | // Direction. 64 | //================ 65 | EditorGUILayout.PropertyField(_spDirection); 66 | 67 | 68 | //================ 69 | // Color. 70 | //================ 71 | switch ((UIGradient.Direction) _spDirection.intValue) 72 | { 73 | case UIGradient.Direction.Horizontal: 74 | EditorGUILayout.PropertyField(_spColor1, k_TextLeft); 75 | EditorGUILayout.PropertyField(_spColor2, k_TextRight); 76 | break; 77 | case UIGradient.Direction.Vertical: 78 | EditorGUILayout.PropertyField(_spColor1, k_TextTop); 79 | EditorGUILayout.PropertyField(_spColor2, k_TextBottom); 80 | break; 81 | case UIGradient.Direction.Angle: 82 | EditorGUILayout.PropertyField(_spColor1, k_TextColor1); 83 | EditorGUILayout.PropertyField(_spColor2, k_TextColor2); 84 | break; 85 | case UIGradient.Direction.Diagonal: 86 | Rect r = EditorGUILayout.GetControlRect(false, 34); 87 | 88 | r = EditorGUI.PrefixLabel(r, k_TextDiagonalColor); 89 | float w = r.width / 2; 90 | 91 | EditorGUI.PropertyField(new Rect(r.x, r.y, w, 16), _spColor3, GUIContent.none); 92 | EditorGUI.PropertyField(new Rect(r.x + w, r.y, w, 16), _spColor4, GUIContent.none); 93 | EditorGUI.PropertyField(new Rect(r.x, r.y + 18, w, 16), _spColor1, GUIContent.none); 94 | EditorGUI.PropertyField(new Rect(r.x + w, r.y + 18, w, 16), _spColor2, GUIContent.none); 95 | break; 96 | } 97 | 98 | 99 | //================ 100 | // Angle. 101 | //================ 102 | if ((int) UIGradient.Direction.Angle <= _spDirection.intValue) 103 | { 104 | EditorGUILayout.PropertyField(_spRotation); 105 | } 106 | 107 | 108 | //================ 109 | // Offset. 110 | //================ 111 | if ((int) UIGradient.Direction.Diagonal == _spDirection.intValue) 112 | { 113 | EditorGUILayout.PropertyField(_spOffset1, k_TextVerticalOffset); 114 | EditorGUILayout.PropertyField(_spOffset2, k_TextHorizontalOffset); 115 | } 116 | else 117 | { 118 | EditorGUILayout.PropertyField(_spOffset1, k_TextOffset); 119 | } 120 | 121 | 122 | //================ 123 | // Advanced options. 124 | //================ 125 | EditorGUILayout.Space(); 126 | EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel); 127 | EditorGUI.indentLevel++; 128 | { 129 | //if ((target as UIGradient).targetGraphic is Text) 130 | EditorGUILayout.PropertyField(_spGradientStyle); 131 | 132 | EditorGUILayout.PropertyField(_spColorSpace); 133 | EditorGUILayout.PropertyField(_spIgnoreAspectRatio); 134 | } 135 | EditorGUI.indentLevel--; 136 | 137 | serializedObject.ApplyModifiedProperties(); 138 | } 139 | } 140 | } -------------------------------------------------------------------------------- /Scripts/Editor/UIGradientEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c28dcc885fbba4a5187a6a1aa5fb1b3b 3 | timeCreated: 1515895646 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Editor/UIHsvModifierEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEditorInternal; 3 | using UnityEngine; 4 | using System.Linq; 5 | 6 | namespace Coffee.UIEffects.Editors 7 | { 8 | /// 9 | /// UIEffect editor. 10 | /// 11 | [CustomEditor(typeof(UIHsvModifier))] 12 | [CanEditMultipleObjects] 13 | public class UIHsvModifierEditor : Editor 14 | { 15 | SerializedProperty _spTargetColor; 16 | SerializedProperty _spRange; 17 | SerializedProperty _spHue; 18 | SerializedProperty _spSaturation; 19 | SerializedProperty _spValue; 20 | 21 | /// 22 | /// This function is called when the object becomes enabled and active. 23 | /// 24 | protected void OnEnable() 25 | { 26 | _spTargetColor = serializedObject.FindProperty("m_TargetColor"); 27 | _spRange = serializedObject.FindProperty("m_Range"); 28 | _spHue = serializedObject.FindProperty("m_Hue"); 29 | _spSaturation = serializedObject.FindProperty("m_Saturation"); 30 | _spValue = serializedObject.FindProperty("m_Value"); 31 | } 32 | 33 | 34 | /// 35 | /// Implement this function to make a custom inspector. 36 | /// 37 | public override void OnInspectorGUI() 38 | { 39 | serializedObject.Update(); 40 | 41 | //================ 42 | // Effect setting. 43 | //================ 44 | EditorGUILayout.PropertyField(_spTargetColor); 45 | EditorGUILayout.PropertyField(_spRange); 46 | EditorGUILayout.PropertyField(_spHue); 47 | EditorGUILayout.PropertyField(_spSaturation); 48 | EditorGUILayout.PropertyField(_spValue); 49 | 50 | serializedObject.ApplyModifiedProperties(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Scripts/Editor/UIHsvModifierEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f002ba0ac474d487b936bc046dda56b4 3 | timeCreated: 1538806052 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Editor/UIShadowEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEditorInternal; 3 | using UnityEngine; 4 | 5 | namespace Coffee.UIEffects.Editors 6 | { 7 | /// 8 | /// UIShadow editor. 9 | /// 10 | [CustomEditor(typeof(UIShadow))] 11 | [CanEditMultipleObjects] 12 | public class UIShadowEditor : Editor 13 | { 14 | UIEffect uiEffect; 15 | SerializedProperty _spStyle; 16 | SerializedProperty _spEffectDistance; 17 | SerializedProperty _spEffectColor; 18 | SerializedProperty _spUseGraphicAlpha; 19 | SerializedProperty _spBlurFactor; 20 | 21 | void OnEnable() 22 | { 23 | uiEffect = (target as UIShadow).GetComponent(); 24 | _spStyle = serializedObject.FindProperty("m_Style"); 25 | _spEffectDistance = serializedObject.FindProperty("m_EffectDistance"); 26 | _spEffectColor = serializedObject.FindProperty("m_EffectColor"); 27 | _spUseGraphicAlpha = serializedObject.FindProperty("m_UseGraphicAlpha"); 28 | _spBlurFactor = serializedObject.FindProperty("m_BlurFactor"); 29 | } 30 | 31 | /// 32 | /// Implement this function to make a custom inspector. 33 | /// 34 | public override void OnInspectorGUI() 35 | { 36 | serializedObject.Update(); 37 | 38 | //================ 39 | // Shadow setting. 40 | //================ 41 | EditorGUILayout.PropertyField(_spStyle); 42 | 43 | // When shadow is enable, show parameters. 44 | if (_spStyle.intValue != (int) ShadowStyle.None) 45 | { 46 | EditorGUI.indentLevel++; 47 | EditorGUILayout.PropertyField(_spEffectDistance); 48 | EditorGUILayout.PropertyField(_spEffectColor); 49 | EditorGUILayout.PropertyField(_spUseGraphicAlpha); 50 | 51 | if (uiEffect && uiEffect.blurMode != BlurMode.None) 52 | { 53 | EditorGUILayout.PropertyField(_spBlurFactor); 54 | } 55 | 56 | EditorGUI.indentLevel--; 57 | } 58 | 59 | serializedObject.ApplyModifiedProperties(); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Scripts/Editor/UIShadowEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e76e7f628f09af449321b4776123f13 3 | timeCreated: 1487152293 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Editor/UIShinyEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEditorInternal; 3 | using UnityEngine; 4 | using System.Linq; 5 | 6 | namespace Coffee.UIEffects.Editors 7 | { 8 | /// 9 | /// UIEffect editor. 10 | /// 11 | [CustomEditor(typeof(UIShiny))] 12 | [CanEditMultipleObjects] 13 | public class UIShinyEditor : Editor 14 | { 15 | SerializedProperty _spEffectFactor; 16 | SerializedProperty _spWidth; 17 | SerializedProperty _spRotation; 18 | SerializedProperty _spSoftness; 19 | SerializedProperty _spBrightness; 20 | SerializedProperty _spGloss; 21 | SerializedProperty _spEffectArea; 22 | SerializedProperty _spPlay; 23 | SerializedProperty _spLoop; 24 | SerializedProperty _spLoopDelay; 25 | SerializedProperty _spDuration; 26 | SerializedProperty _spInitialPlayDelay; 27 | SerializedProperty _spUpdateMode; 28 | 29 | /// 30 | /// This function is called when the object becomes enabled and active. 31 | /// 32 | protected void OnEnable() 33 | { 34 | _spEffectFactor = serializedObject.FindProperty("m_EffectFactor"); 35 | _spEffectArea = serializedObject.FindProperty("m_EffectArea"); 36 | _spWidth = serializedObject.FindProperty("m_Width"); 37 | _spRotation = serializedObject.FindProperty("m_Rotation"); 38 | _spSoftness = serializedObject.FindProperty("m_Softness"); 39 | _spBrightness = serializedObject.FindProperty("m_Brightness"); 40 | _spGloss = serializedObject.FindProperty("m_Gloss"); 41 | var player = serializedObject.FindProperty("m_Player"); 42 | _spPlay = player.FindPropertyRelative("play"); 43 | _spDuration = player.FindPropertyRelative("duration"); 44 | _spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay"); 45 | _spLoop = player.FindPropertyRelative("loop"); 46 | _spLoopDelay = player.FindPropertyRelative("loopDelay"); 47 | _spUpdateMode = player.FindPropertyRelative("updateMode"); 48 | } 49 | 50 | /// 51 | /// Implement this function to make a custom inspector. 52 | /// 53 | public override void OnInspectorGUI() 54 | { 55 | serializedObject.Update(); 56 | 57 | //================ 58 | // Effect setting. 59 | //================ 60 | EditorGUILayout.PropertyField(_spEffectFactor); 61 | EditorGUILayout.PropertyField(_spWidth); 62 | EditorGUILayout.PropertyField(_spRotation); 63 | EditorGUILayout.PropertyField(_spSoftness); 64 | EditorGUILayout.PropertyField(_spBrightness); 65 | EditorGUILayout.PropertyField(_spGloss); 66 | 67 | //================ 68 | // Advanced option. 69 | //================ 70 | EditorGUILayout.PropertyField(_spEffectArea); 71 | 72 | //================ 73 | // Effect player. 74 | //================ 75 | EditorGUILayout.PropertyField(_spPlay); 76 | EditorGUILayout.PropertyField(_spDuration); 77 | EditorGUILayout.PropertyField(_spInitialPlayDelay); 78 | EditorGUILayout.PropertyField(_spLoop); 79 | EditorGUILayout.PropertyField(_spLoopDelay); 80 | EditorGUILayout.PropertyField(_spUpdateMode); 81 | 82 | // Debug. 83 | using (new EditorGUI.DisabledGroupScope(!Application.isPlaying)) 84 | using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox)) 85 | { 86 | GUILayout.Label("Debug"); 87 | 88 | if (GUILayout.Button("Play", "ButtonLeft")) 89 | { 90 | (target as UIShiny).Play(); 91 | } 92 | 93 | if (GUILayout.Button("Stop", "ButtonRight")) 94 | { 95 | (target as UIShiny).Stop(); 96 | } 97 | } 98 | 99 | serializedObject.ApplyModifiedProperties(); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Scripts/Editor/UIShinyEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0080e984bad7545cd957d9121e99f988 3 | timeCreated: 1538806052 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Editor/UITransitionEffectEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEditorInternal; 3 | using UnityEngine; 4 | using System.Linq; 5 | 6 | namespace Coffee.UIEffects.Editors 7 | { 8 | /// 9 | /// UIEffect editor. 10 | /// 11 | [CustomEditor(typeof(UITransitionEffect))] 12 | [CanEditMultipleObjects] 13 | public class UITransitionEffectEditor : Editor 14 | { 15 | SerializedProperty _spEffectMode; 16 | SerializedProperty _spEffectFactor; 17 | SerializedProperty _spEffectArea; 18 | SerializedProperty _spKeepAspectRatio; 19 | SerializedProperty _spDissolveWidth; 20 | SerializedProperty _spDissolveSoftness; 21 | SerializedProperty _spDissolveColor; 22 | SerializedProperty _spTransitionTexture; 23 | SerializedProperty _spPlay; 24 | SerializedProperty _spLoop; 25 | SerializedProperty _spLoopDelay; 26 | SerializedProperty _spDuration; 27 | SerializedProperty _spInitialPlayDelay; 28 | SerializedProperty _spUpdateMode; 29 | SerializedProperty _spPassRayOnHidden; 30 | 31 | /// 32 | /// This function is called when the object becomes enabled and active. 33 | /// 34 | protected void OnEnable() 35 | { 36 | _spEffectMode = serializedObject.FindProperty("m_EffectMode"); 37 | _spEffectFactor = serializedObject.FindProperty("m_EffectFactor"); 38 | _spEffectArea = serializedObject.FindProperty("m_EffectArea"); 39 | _spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio"); 40 | _spDissolveWidth = serializedObject.FindProperty("m_DissolveWidth"); 41 | _spDissolveSoftness = serializedObject.FindProperty("m_DissolveSoftness"); 42 | _spDissolveColor = serializedObject.FindProperty("m_DissolveColor"); 43 | _spTransitionTexture = serializedObject.FindProperty("m_TransitionTexture"); 44 | var player = serializedObject.FindProperty("m_Player"); 45 | _spPlay = player.FindPropertyRelative("play"); 46 | _spDuration = player.FindPropertyRelative("duration"); 47 | _spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay"); 48 | _spLoop = player.FindPropertyRelative("loop"); 49 | _spLoopDelay = player.FindPropertyRelative("loopDelay"); 50 | _spUpdateMode = player.FindPropertyRelative("updateMode"); 51 | _spPassRayOnHidden = serializedObject.FindProperty("m_PassRayOnHidden"); 52 | } 53 | 54 | /// 55 | /// Implement this function to make a custom inspector. 56 | /// 57 | public override void OnInspectorGUI() 58 | { 59 | //================ 60 | // Effect setting. 61 | //================ 62 | using (new MaterialDirtyScope(targets)) 63 | EditorGUILayout.PropertyField(_spEffectMode); 64 | 65 | EditorGUI.indentLevel++; 66 | EditorGUILayout.PropertyField(_spEffectFactor); 67 | if (_spEffectMode.intValue == (int) UITransitionEffect.EffectMode.Dissolve) 68 | { 69 | EditorGUILayout.PropertyField(_spDissolveWidth); 70 | EditorGUILayout.PropertyField(_spDissolveSoftness); 71 | EditorGUILayout.PropertyField(_spDissolveColor); 72 | } 73 | 74 | EditorGUI.indentLevel--; 75 | 76 | //================ 77 | // Advanced option. 78 | //================ 79 | EditorGUILayout.PropertyField(_spEffectArea); 80 | using (new MaterialDirtyScope(targets)) 81 | EditorGUILayout.PropertyField(_spTransitionTexture); 82 | EditorGUILayout.PropertyField(_spKeepAspectRatio); 83 | EditorGUILayout.PropertyField(_spPassRayOnHidden); 84 | 85 | //================ 86 | // Effect player. 87 | //================ 88 | EditorGUILayout.PropertyField(_spPlay); 89 | EditorGUILayout.PropertyField(_spDuration); 90 | EditorGUILayout.PropertyField(_spInitialPlayDelay); 91 | EditorGUILayout.PropertyField(_spLoop); 92 | EditorGUILayout.PropertyField(_spLoopDelay); 93 | EditorGUILayout.PropertyField(_spUpdateMode); 94 | 95 | // Debug. 96 | using (new EditorGUI.DisabledGroupScope(!Application.isPlaying)) 97 | using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox)) 98 | { 99 | GUILayout.Label("Debug"); 100 | 101 | if (GUILayout.Button("Show", "ButtonLeft")) 102 | { 103 | (target as UITransitionEffect).Show(); 104 | } 105 | 106 | if (GUILayout.Button("Hide", "ButtonRight")) 107 | { 108 | (target as UITransitionEffect).Hide(); 109 | } 110 | } 111 | 112 | serializedObject.ApplyModifiedProperties(); 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Scripts/Editor/UITransitionEffectEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 631f363a54c834f1f846f823b31bd321 3 | timeCreated: 1538806067 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Enums.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78cc1478fd16a484ba11857d5c4f4912 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Scripts/Enums/BlurMode.cs: -------------------------------------------------------------------------------- 1 | namespace Coffee.UIEffects 2 | { 3 | /// 4 | /// Blur effect mode. 5 | /// 6 | public enum BlurMode 7 | { 8 | None = 0, 9 | FastBlur = 1, 10 | MediumBlur = 2, 11 | DetailBlur = 3, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Scripts/Enums/BlurMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5645838b01af8764d8f381f04b62b9a2 3 | timeCreated: 1528296875 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Enums/ColorMode.cs: -------------------------------------------------------------------------------- 1 | namespace Coffee.UIEffects 2 | { 3 | /// 4 | /// Color effect mode. 5 | /// 6 | public enum ColorMode 7 | { 8 | Multiply = 0, 9 | Fill = 1, 10 | Add = 2, 11 | Subtract = 3, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Scripts/Enums/ColorMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6ba1e487e0a19644afde2bd5531bd04 3 | timeCreated: 1528296875 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Enums/EffectArea.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | 4 | namespace Coffee.UIEffects 5 | { 6 | /// 7 | /// Area for effect. 8 | /// 9 | public enum EffectArea 10 | { 11 | RectTransform, 12 | Fit, 13 | Character, 14 | } 15 | 16 | public static class EffectAreaExtensions 17 | { 18 | static readonly Rect rectForCharacter = new Rect(0, 0, 1, 1); 19 | static readonly Vector2[] splitedCharacterPosition = {Vector2.up, Vector2.one, Vector2.right, Vector2.zero}; 20 | 21 | /// 22 | /// Gets effect for area. 23 | /// 24 | public static Rect GetEffectArea(this EffectArea area, VertexHelper vh, Rect rectangle, float aspectRatio = -1) 25 | { 26 | Rect rect = default(Rect); 27 | switch (area) 28 | { 29 | case EffectArea.RectTransform: 30 | rect = rectangle; 31 | break; 32 | case EffectArea.Character: 33 | rect = rectForCharacter; 34 | break; 35 | case EffectArea.Fit: 36 | // Fit to contents. 37 | UIVertex vertex = default(UIVertex); 38 | float xMin = float.MaxValue; 39 | float yMin = float.MaxValue; 40 | float xMax = float.MinValue; 41 | float yMax = float.MinValue; 42 | for (int i = 0; i < vh.currentVertCount; i++) 43 | { 44 | vh.PopulateUIVertex(ref vertex, i); 45 | float x = vertex.position.x; 46 | float y = vertex.position.y; 47 | xMin = Mathf.Min(xMin, x); 48 | yMin = Mathf.Min(yMin, y); 49 | xMax = Mathf.Max(xMax, x); 50 | yMax = Mathf.Max(yMax, y); 51 | } 52 | 53 | rect.Set(xMin, yMin, xMax - xMin, yMax - yMin); 54 | break; 55 | default: 56 | rect = rectangle; 57 | break; 58 | } 59 | 60 | 61 | if (0 < aspectRatio) 62 | { 63 | if (rect.width < rect.height) 64 | { 65 | rect.width = rect.height * aspectRatio; 66 | } 67 | else 68 | { 69 | rect.height = rect.width / aspectRatio; 70 | } 71 | } 72 | 73 | return rect; 74 | } 75 | 76 | /// 77 | /// Gets position factor for area. 78 | /// 79 | public static void GetPositionFactor(this EffectArea area, int index, Rect rect, Vector2 position, bool isText, 80 | bool isTMPro, out float x, out float y) 81 | { 82 | if (isText && area == EffectArea.Character) 83 | { 84 | index = isTMPro ? (index + 3) % 4 : index % 4; 85 | x = splitedCharacterPosition[index].x; 86 | y = splitedCharacterPosition[index].y; 87 | } 88 | else if (area == EffectArea.Fit) 89 | { 90 | x = Mathf.Clamp01((position.x - rect.xMin) / rect.width); 91 | y = Mathf.Clamp01((position.y - rect.yMin) / rect.height); 92 | } 93 | else 94 | { 95 | x = Mathf.Clamp01(position.x / rect.width + 0.5f); 96 | y = Mathf.Clamp01(position.y / rect.height + 0.5f); 97 | } 98 | } 99 | 100 | /// 101 | /// Normalize vertex position by local matrix. 102 | /// 103 | public static void GetNormalizedFactor(this EffectArea area, int index, Matrix2x3 matrix, Vector2 position, 104 | bool isText, out Vector2 nomalizedPos) 105 | { 106 | if (isText && area == EffectArea.Character) 107 | { 108 | nomalizedPos = matrix * splitedCharacterPosition[(index + 3) % 4]; 109 | } 110 | else 111 | { 112 | nomalizedPos = matrix * position; 113 | } 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Scripts/Enums/EffectArea.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a78f43d1382a048a99411472ca714e1b 3 | timeCreated: 1528636556 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Enums/EffectMode.cs: -------------------------------------------------------------------------------- 1 | namespace Coffee.UIEffects 2 | { 3 | /// 4 | /// Effect mode. 5 | /// 6 | public enum EffectMode 7 | { 8 | None = 0, 9 | Grayscale = 1, 10 | Sepia = 2, 11 | Nega = 3, 12 | Pixel = 4, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Scripts/Enums/EffectMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 092769547c242d74cbad96631a00963f 3 | timeCreated: 1528296875 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/Enums/ShadowStyle.cs: -------------------------------------------------------------------------------- 1 | namespace Coffee.UIEffects 2 | { 3 | /// 4 | /// Shadow effect style. 5 | /// 6 | public enum ShadowStyle 7 | { 8 | None = 0, 9 | Shadow, 10 | Outline, 11 | Outline8, 12 | Shadow3, 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Scripts/Enums/ShadowStyle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0eda5bf10146491c9cfe6a31c66f9a7 3 | timeCreated: 1528296875 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/UIDissolve.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEditor; 4 | using UnityEngine.UI; 5 | using UnityEngine.Serialization; 6 | using System.Text; 7 | using System.Linq; 8 | using System.IO; 9 | 10 | namespace Coffee.UIEffects 11 | { 12 | /// 13 | /// Dissolve effect for uGUI. 14 | /// 15 | [AddComponentMenu("UI/UIEffects/UIDissolve", 3)] 16 | public class UIDissolve : BaseMaterialEffect, IMaterialModifier 17 | { 18 | private const uint k_ShaderId = 0 << 3; 19 | private static readonly ParameterTexture s_ParamTex = new ParameterTexture(8, 128, "_ParamTex"); 20 | private static readonly int k_TransitionTexId = Shader.PropertyToID("_TransitionTex"); 21 | 22 | private bool _lastKeepAspectRatio; 23 | private EffectArea _lastEffectArea; 24 | private static Texture _defaultTransitionTexture; 25 | 26 | [Tooltip("Current location[0-1] for dissolve effect. 0 is not dissolved, 1 is completely dissolved.")] 27 | [FormerlySerializedAs("m_Location")] 28 | [SerializeField] 29 | [Range(0, 1)] 30 | float m_EffectFactor = 0.5f; 31 | 32 | [Tooltip("Edge width.")] [SerializeField] [Range(0, 1)] 33 | float m_Width = 0.5f; 34 | 35 | [Tooltip("Edge softness.")] [SerializeField] [Range(0, 1)] 36 | float m_Softness = 0.5f; 37 | 38 | [Tooltip("Edge color.")] [SerializeField] [ColorUsage(false)] 39 | Color m_Color = new Color(0.0f, 0.25f, 1.0f); 40 | 41 | [Tooltip("Edge color effect mode.")] [SerializeField] 42 | ColorMode m_ColorMode = ColorMode.Add; 43 | 44 | [Tooltip("Noise texture for dissolving (single channel texture).")] 45 | [SerializeField] 46 | [FormerlySerializedAs("m_NoiseTexture")] 47 | Texture m_TransitionTexture; 48 | 49 | [Header("Advanced Option")] [Tooltip("The area for effect.")] [SerializeField] 50 | protected EffectArea m_EffectArea; 51 | 52 | [Tooltip("Keep effect aspect ratio.")] [SerializeField] 53 | bool m_KeepAspectRatio; 54 | 55 | [Header("Effect Player")] [SerializeField] 56 | EffectPlayer m_Player; 57 | 58 | [Tooltip("Reverse the dissolve effect.")] [FormerlySerializedAs("m_ReverseAnimation")] [SerializeField] 59 | bool m_Reverse = false; 60 | 61 | /// 62 | /// Effect factor between 0(start) and 1(end). 63 | /// 64 | public float effectFactor 65 | { 66 | get { return m_EffectFactor; } 67 | set 68 | { 69 | value = Mathf.Clamp(value, 0, 1); 70 | if (Mathf.Approximately(m_EffectFactor, value)) return; 71 | m_EffectFactor = value; 72 | SetEffectParamsDirty(); 73 | } 74 | } 75 | 76 | /// 77 | /// Edge width. 78 | /// 79 | public float width 80 | { 81 | get { return m_Width; } 82 | set 83 | { 84 | value = Mathf.Clamp(value, 0, 1); 85 | if (Mathf.Approximately(m_Width, value)) return; 86 | m_Width = value; 87 | SetEffectParamsDirty(); 88 | } 89 | } 90 | 91 | /// 92 | /// Edge softness. 93 | /// 94 | public float softness 95 | { 96 | get { return m_Softness; } 97 | set 98 | { 99 | value = Mathf.Clamp(value, 0, 1); 100 | if (Mathf.Approximately(m_Softness, value)) return; 101 | m_Softness = value; 102 | SetEffectParamsDirty(); 103 | } 104 | } 105 | 106 | /// 107 | /// Edge color. 108 | /// 109 | public Color color 110 | { 111 | get { return m_Color; } 112 | set 113 | { 114 | if (m_Color == value) return; 115 | m_Color = value; 116 | SetEffectParamsDirty(); 117 | } 118 | } 119 | 120 | /// 121 | /// Noise texture. 122 | /// 123 | public Texture transitionTexture 124 | { 125 | get 126 | { 127 | return m_TransitionTexture 128 | ? m_TransitionTexture 129 | : defaultTransitionTexture; 130 | } 131 | set 132 | { 133 | if (m_TransitionTexture == value) return; 134 | m_TransitionTexture = value; 135 | SetMaterialDirty(); 136 | } 137 | } 138 | 139 | private static Texture defaultTransitionTexture 140 | { 141 | get 142 | { 143 | return _defaultTransitionTexture 144 | ? _defaultTransitionTexture 145 | : (_defaultTransitionTexture = Resources.Load("Default-Transition")); 146 | } 147 | } 148 | 149 | /// 150 | /// The area for effect. 151 | /// 152 | public EffectArea effectArea 153 | { 154 | get { return m_EffectArea; } 155 | set 156 | { 157 | if (m_EffectArea == value) return; 158 | m_EffectArea = value; 159 | SetVerticesDirty(); 160 | } 161 | } 162 | 163 | /// 164 | /// Keep aspect ratio. 165 | /// 166 | public bool keepAspectRatio 167 | { 168 | get { return m_KeepAspectRatio; } 169 | set 170 | { 171 | if (m_KeepAspectRatio == value) return; 172 | m_KeepAspectRatio = value; 173 | SetVerticesDirty(); 174 | } 175 | } 176 | 177 | /// 178 | /// Color effect mode. 179 | /// 180 | public ColorMode colorMode 181 | { 182 | get { return m_ColorMode; } 183 | set 184 | { 185 | if (m_ColorMode == value) return; 186 | m_ColorMode = value; 187 | SetMaterialDirty(); 188 | } 189 | } 190 | 191 | /// 192 | /// Gets the parameter texture. 193 | /// 194 | public override ParameterTexture paramTex 195 | { 196 | get { return s_ParamTex; } 197 | } 198 | 199 | public EffectPlayer effectPlayer 200 | { 201 | get { return m_Player ?? (m_Player = new EffectPlayer()); } 202 | } 203 | 204 | public override Hash128 GetMaterialHash(Material material) 205 | { 206 | if (!isActiveAndEnabled || !material || !material.shader) 207 | return k_InvalidHash; 208 | 209 | var shaderVariantId = (uint) ((int) m_ColorMode << 6); 210 | var resourceId = (uint) transitionTexture.GetInstanceID(); 211 | return new Hash128( 212 | (uint) material.GetInstanceID(), 213 | k_ShaderId + shaderVariantId, 214 | resourceId, 215 | 0 216 | ); 217 | } 218 | 219 | public override void ModifyMaterial(Material newMaterial, Graphic graphic) 220 | { 221 | var connector = GraphicConnector.FindConnector(graphic); 222 | newMaterial.shader = Shader.Find(string.Format("Hidden/{0} (UIDissolve)", newMaterial.shader.name)); 223 | SetShaderVariants(newMaterial, m_ColorMode); 224 | 225 | newMaterial.SetTexture(k_TransitionTexId, transitionTexture); 226 | paramTex.RegisterMaterial(newMaterial); 227 | } 228 | 229 | /// 230 | /// Modifies the mesh. 231 | /// 232 | public override void ModifyMesh(VertexHelper vh, Graphic graphic) 233 | { 234 | if (!isActiveAndEnabled) 235 | return; 236 | 237 | // bool isText = isTMPro || graphic is Text; 238 | var normalizedIndex = paramTex.GetNormalizedIndex(this); 239 | 240 | // rect. 241 | var tex = transitionTexture; 242 | var aspectRatio = m_KeepAspectRatio && tex ? ((float) tex.width) / tex.height : -1; 243 | var rect = m_EffectArea.GetEffectArea(vh, rectTransform.rect, aspectRatio); 244 | 245 | // Calculate vertex position. 246 | var vertex = default(UIVertex); 247 | var count = vh.currentVertCount; 248 | for (var i = 0; i < count; i++) 249 | { 250 | vh.PopulateUIVertex(ref vertex, i); 251 | float x; 252 | float y; 253 | connector.GetPositionFactor(m_EffectArea, i, rect, vertex.position, out x, out y); 254 | 255 | vertex.uv0 = new Vector2( 256 | Packer.ToFloat(vertex.uv0.x, vertex.uv0.y), 257 | Packer.ToFloat(x, y, normalizedIndex) 258 | ); 259 | 260 | vh.SetUIVertex(vertex, i); 261 | } 262 | } 263 | 264 | protected override void SetEffectParamsDirty() 265 | { 266 | paramTex.SetData(this, 0, m_EffectFactor); // param1.x : location 267 | paramTex.SetData(this, 1, m_Width); // param1.y : width 268 | paramTex.SetData(this, 2, m_Softness); // param1.z : softness 269 | paramTex.SetData(this, 4, m_Color.r); // param2.x : red 270 | paramTex.SetData(this, 5, m_Color.g); // param2.y : green 271 | paramTex.SetData(this, 6, m_Color.b); // param2.z : blue 272 | } 273 | 274 | protected override void SetVerticesDirty() 275 | { 276 | base.SetVerticesDirty(); 277 | 278 | _lastKeepAspectRatio = m_KeepAspectRatio; 279 | _lastEffectArea = m_EffectArea; 280 | } 281 | 282 | protected override void OnDidApplyAnimationProperties() 283 | { 284 | base.OnDidApplyAnimationProperties(); 285 | 286 | if (_lastKeepAspectRatio != m_KeepAspectRatio 287 | || _lastEffectArea != m_EffectArea) 288 | SetVerticesDirty(); 289 | } 290 | 291 | /// 292 | /// Play effect. 293 | /// 294 | public void Play(bool reset = true) 295 | { 296 | effectPlayer.Play(reset); 297 | } 298 | 299 | /// 300 | /// Stop effect. 301 | /// 302 | public void Stop(bool reset = true) 303 | { 304 | effectPlayer.Stop(reset); 305 | } 306 | 307 | protected override void OnEnable() 308 | { 309 | base.OnEnable(); 310 | effectPlayer.OnEnable((f) => effectFactor = m_Reverse ? 1f - f : f); 311 | } 312 | 313 | protected override void OnDisable() 314 | { 315 | base.OnDisable(); 316 | effectPlayer.OnDisable(); 317 | } 318 | } 319 | } 320 | -------------------------------------------------------------------------------- /Scripts/UIDissolve.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce76b7a490bd74f34a2f2752641aea24 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - m_TransitionTexture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, 8 | type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Scripts/UIEffect.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UIEffect" 3 | } 4 | -------------------------------------------------------------------------------- /Scripts/UIEffect.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 735c8f008d0ad4caa9cdc4306f1c3042 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Scripts/UIEffect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8b2ed11d675446c5a49da1ea296d490 3 | timeCreated: 1485321967 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/UIFlip.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | namespace Coffee.UIEffects 7 | { 8 | [DisallowMultipleComponent] 9 | [AddComponentMenu("UI/UIEffects/UIFlip", 102)] 10 | public class UIFlip : BaseMeshEffect 11 | { 12 | [Tooltip("Flip horizontally.")] [SerializeField] 13 | private bool m_Horizontal = false; 14 | 15 | [Tooltip("Flip vertically.")] [SerializeField] 16 | private bool m_Veritical = false; 17 | 18 | /// 19 | /// Gets or sets a value indicating whether this should be flipped horizontally. 20 | /// 21 | /// true if be flipped horizontally; otherwise, false. 22 | public bool horizontal 23 | { 24 | get { return m_Horizontal; } 25 | set 26 | { 27 | if (m_Horizontal == value) return; 28 | m_Horizontal = value; 29 | SetEffectParamsDirty(); 30 | } 31 | } 32 | 33 | /// 34 | /// Gets or sets a value indicating whether this should be flipped vertically. 35 | /// 36 | /// true if be flipped horizontally; otherwise, false. 37 | public bool vertical 38 | { 39 | get { return m_Veritical; } 40 | set 41 | { 42 | if (m_Veritical == value) return; 43 | m_Veritical = value; 44 | SetEffectParamsDirty(); 45 | } 46 | } 47 | 48 | /// 49 | /// Call used to modify mesh. 50 | /// 51 | /// VertexHelper. 52 | public override void ModifyMesh(VertexHelper vh, Graphic graphic) 53 | { 54 | if (!isActiveAndEnabled) return; 55 | 56 | var vt = default(UIVertex); 57 | for (var i = 0; i < vh.currentVertCount; i++) 58 | { 59 | vh.PopulateUIVertex(ref vt, i); 60 | var pos = vt.position; 61 | vt.position = new Vector3( 62 | m_Horizontal ? -pos.x : pos.x, 63 | m_Veritical ? -pos.y : pos.y 64 | ); 65 | vh.SetUIVertex(vt, i); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Scripts/UIFlip.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9bb4e59514e90489d985e9a17c838085 3 | timeCreated: 1525607243 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/UIGradient.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | 4 | namespace Coffee.UIEffects 5 | { 6 | /// 7 | /// UIGradient. 8 | /// 9 | [DisallowMultipleComponent] 10 | [AddComponentMenu("UI/UIEffects/UIGradient", 101)] 11 | public class UIGradient : BaseMeshEffect 12 | { 13 | static readonly Vector2[] s_SplitedCharacterPosition = {Vector2.up, Vector2.one, Vector2.right, Vector2.zero}; 14 | 15 | /// 16 | /// Gradient direction. 17 | /// 18 | public enum Direction 19 | { 20 | Horizontal, 21 | Vertical, 22 | Angle, 23 | Diagonal, 24 | } 25 | 26 | /// 27 | /// Gradient space for Text. 28 | /// 29 | public enum GradientStyle 30 | { 31 | Rect, 32 | Fit, 33 | Split, 34 | } 35 | 36 | 37 | [Tooltip("Gradient Direction.")] [SerializeField] 38 | Direction m_Direction; 39 | 40 | [Tooltip("Color1: Top or Left.")] [SerializeField] 41 | Color m_Color1 = Color.white; 42 | 43 | [Tooltip("Color2: Bottom or Right.")] [SerializeField] 44 | Color m_Color2 = Color.white; 45 | 46 | [Tooltip("Color3: For diagonal.")] [SerializeField] 47 | Color m_Color3 = Color.white; 48 | 49 | [Tooltip("Color4: For diagonal.")] [SerializeField] 50 | Color m_Color4 = Color.white; 51 | 52 | [Tooltip("Gradient rotation.")] [SerializeField] [Range(-180, 180)] 53 | float m_Rotation; 54 | 55 | [Tooltip("Gradient offset for Horizontal, Vertical or Angle.")] [SerializeField] [Range(-1, 1)] 56 | float m_Offset1; 57 | 58 | [Tooltip("Gradient offset for Diagonal.")] [SerializeField] [Range(-1, 1)] 59 | float m_Offset2; 60 | 61 | [Tooltip("Gradient style for Text.")] [SerializeField] 62 | GradientStyle m_GradientStyle; 63 | 64 | [Tooltip("Color space to correct color.")] [SerializeField] 65 | ColorSpace m_ColorSpace = ColorSpace.Uninitialized; 66 | 67 | [Tooltip("Ignore aspect ratio.")] [SerializeField] 68 | bool m_IgnoreAspectRatio = true; 69 | 70 | /// 71 | /// Gradient Direction. 72 | /// 73 | public Direction direction 74 | { 75 | get { return m_Direction; } 76 | set 77 | { 78 | if (m_Direction == value) return; 79 | m_Direction = value; 80 | SetVerticesDirty(); 81 | } 82 | } 83 | 84 | /// 85 | /// Color1: Top or Left. 86 | /// 87 | public Color color1 88 | { 89 | get { return m_Color1; } 90 | set 91 | { 92 | if (m_Color1 == value) return; 93 | m_Color1 = value; 94 | SetVerticesDirty(); 95 | } 96 | } 97 | 98 | /// 99 | /// Color2: Bottom or Right. 100 | /// 101 | public Color color2 102 | { 103 | get { return m_Color2; } 104 | set 105 | { 106 | if (m_Color2 == value) return; 107 | m_Color2 = value; 108 | SetVerticesDirty(); 109 | } 110 | } 111 | 112 | /// 113 | /// Color3: For diagonal. 114 | /// 115 | public Color color3 116 | { 117 | get { return m_Color3; } 118 | set 119 | { 120 | if (m_Color3 == value) return; 121 | m_Color3 = value; 122 | SetVerticesDirty(); 123 | } 124 | } 125 | 126 | /// 127 | /// Color4: For diagonal. 128 | /// 129 | public Color color4 130 | { 131 | get { return m_Color4; } 132 | set 133 | { 134 | if (m_Color4 == value) return; 135 | m_Color4 = value; 136 | SetVerticesDirty(); 137 | } 138 | } 139 | 140 | /// 141 | /// Gradient rotation. 142 | /// 143 | public float rotation 144 | { 145 | get 146 | { 147 | return m_Direction == Direction.Horizontal ? -90 148 | : m_Direction == Direction.Vertical ? 0 149 | : m_Rotation; 150 | } 151 | set 152 | { 153 | if (Mathf.Approximately(m_Rotation, value)) return; 154 | m_Rotation = value; 155 | SetVerticesDirty(); 156 | } 157 | } 158 | 159 | /// 160 | /// Gradient offset for Horizontal, Vertical or Angle. 161 | /// 162 | public float offset 163 | { 164 | get { return m_Offset1; } 165 | set 166 | { 167 | if (Mathf.Approximately(m_Offset1, value)) return; 168 | m_Offset1 = value; 169 | SetVerticesDirty(); 170 | } 171 | } 172 | 173 | /// 174 | /// Gradient offset for Diagonal. 175 | /// 176 | public Vector2 offset2 177 | { 178 | get { return new Vector2(m_Offset2, m_Offset1); } 179 | set 180 | { 181 | if (Mathf.Approximately(m_Offset1, value.y) && Mathf.Approximately(m_Offset2, value.x)) return; 182 | m_Offset1 = value.y; 183 | m_Offset2 = value.x; 184 | SetVerticesDirty(); 185 | } 186 | } 187 | 188 | /// 189 | /// Gradient style for Text. 190 | /// 191 | public GradientStyle gradientStyle 192 | { 193 | get { return m_GradientStyle; } 194 | set 195 | { 196 | if (m_GradientStyle == value) return; 197 | m_GradientStyle = value; 198 | SetVerticesDirty(); 199 | } 200 | } 201 | 202 | /// 203 | /// Color space to correct color. 204 | /// 205 | public ColorSpace colorSpace 206 | { 207 | get { return m_ColorSpace; } 208 | set 209 | { 210 | if (m_ColorSpace == value) return; 211 | m_ColorSpace = value; 212 | SetVerticesDirty(); 213 | } 214 | } 215 | 216 | /// 217 | /// Ignore aspect ratio. 218 | /// 219 | public bool ignoreAspectRatio 220 | { 221 | get { return m_IgnoreAspectRatio; } 222 | set 223 | { 224 | if (m_IgnoreAspectRatio == value) return; 225 | m_IgnoreAspectRatio = value; 226 | SetVerticesDirty(); 227 | } 228 | } 229 | 230 | /// 231 | /// Call used to modify mesh. 232 | /// 233 | public override void ModifyMesh(VertexHelper vh, Graphic graphic) 234 | { 235 | if (!isActiveAndEnabled) 236 | return; 237 | 238 | // Gradient space. 239 | var rect = default(Rect); 240 | var vertex = default(UIVertex); 241 | switch (m_GradientStyle) 242 | { 243 | case GradientStyle.Rect: 244 | // RectTransform. 245 | rect = graphic.rectTransform.rect; 246 | break; 247 | case GradientStyle.Split: 248 | // Each characters. 249 | rect.Set(0, 0, 1, 1); 250 | break; 251 | case GradientStyle.Fit: 252 | { 253 | // Fit to contents. 254 | rect.xMin = rect.yMin = float.MaxValue; 255 | rect.xMax = rect.yMax = float.MinValue; 256 | for (var i = 0; i < vh.currentVertCount; i++) 257 | { 258 | vh.PopulateUIVertex(ref vertex, i); 259 | rect.xMin = Mathf.Min(rect.xMin, vertex.position.x); 260 | rect.yMin = Mathf.Min(rect.yMin, vertex.position.y); 261 | rect.xMax = Mathf.Max(rect.xMax, vertex.position.x); 262 | rect.yMax = Mathf.Max(rect.yMax, vertex.position.y); 263 | } 264 | 265 | break; 266 | } 267 | } 268 | 269 | // Gradient rotation. 270 | var rad = rotation * Mathf.Deg2Rad; 271 | var dir = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad)); 272 | if (!m_IgnoreAspectRatio && Direction.Angle <= m_Direction) 273 | { 274 | dir.x *= rect.height / rect.width; 275 | dir = dir.normalized; 276 | } 277 | 278 | // Calculate vertex color. 279 | var localMatrix = new Matrix2x3(rect, dir.x, dir.y); // Get local matrix. 280 | for (var i = 0; i < vh.currentVertCount; i++) 281 | { 282 | vh.PopulateUIVertex(ref vertex, i); 283 | 284 | // Normalize vertex position by local matrix. 285 | Vector2 normalizedPos; 286 | if (m_GradientStyle == GradientStyle.Split) 287 | { 288 | // Each characters. 289 | normalizedPos = localMatrix * s_SplitedCharacterPosition[i % 4] + offset2; 290 | } 291 | else 292 | { 293 | normalizedPos = localMatrix * vertex.position + offset2; 294 | } 295 | 296 | // Interpolate vertex color. 297 | Color color; 298 | if (direction == Direction.Diagonal) 299 | { 300 | color = Color.LerpUnclamped( 301 | Color.LerpUnclamped(m_Color1, m_Color2, normalizedPos.x), 302 | Color.LerpUnclamped(m_Color3, m_Color4, normalizedPos.x), 303 | normalizedPos.y); 304 | } 305 | else 306 | { 307 | color = Color.LerpUnclamped(m_Color2, m_Color1, normalizedPos.y); 308 | } 309 | 310 | // Correct color. 311 | vertex.color *= (m_ColorSpace == ColorSpace.Gamma) ? color.gamma 312 | : (m_ColorSpace == ColorSpace.Linear) ? color.linear 313 | : color; 314 | 315 | vh.SetUIVertex(vertex, i); 316 | } 317 | } 318 | } 319 | } 320 | -------------------------------------------------------------------------------- /Scripts/UIGradient.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fb48d82dc0e94a2b9246d17d04f8748 3 | timeCreated: 1515744842 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/UIHsvModifier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Serialization; 4 | using UnityEngine.UI; 5 | 6 | 7 | namespace Coffee.UIEffects 8 | { 9 | /// 10 | /// HSV Modifier. 11 | /// 12 | [AddComponentMenu("UI/UIEffects/UIHsvModifier", 4)] 13 | public class UIHsvModifier : BaseMaterialEffect 14 | { 15 | private const uint k_ShaderId = 6 << 3; 16 | private static readonly ParameterTexture s_ParamTex = new ParameterTexture(7, 128, "_ParamTex"); 17 | 18 | [Header("Target")] [Tooltip("Target color to affect hsv shift.")] [SerializeField] [ColorUsage(false)] 19 | Color m_TargetColor = Color.red; 20 | 21 | [Tooltip("Color range to affect hsv shift [0 ~ 1].")] [SerializeField] [Range(0, 1)] 22 | float m_Range = 0.1f; 23 | 24 | [Header("Adjustment")] [Tooltip("Hue shift [-0.5 ~ 0.5].")] [SerializeField] [Range(-0.5f, 0.5f)] 25 | float m_Hue; 26 | 27 | [Tooltip("Saturation shift [-0.5 ~ 0.5].")] [SerializeField] [Range(-0.5f, 0.5f)] 28 | float m_Saturation; 29 | 30 | [Tooltip("Value shift [-0.5 ~ 0.5].")] [SerializeField] [Range(-0.5f, 0.5f)] 31 | float m_Value; 32 | 33 | /// 34 | /// Target color to affect hsv shift. 35 | /// 36 | public Color targetColor 37 | { 38 | get { return m_TargetColor; } 39 | set 40 | { 41 | if (m_TargetColor == value) return; 42 | m_TargetColor = value; 43 | SetEffectParamsDirty(); 44 | } 45 | } 46 | 47 | /// 48 | /// Color range to affect hsv shift [0 ~ 1]. 49 | /// 50 | public float range 51 | { 52 | get { return m_Range; } 53 | set 54 | { 55 | value = Mathf.Clamp(value, 0, 1); 56 | if (Mathf.Approximately(m_Range, value)) return; 57 | m_Range = value; 58 | SetEffectParamsDirty(); 59 | } 60 | } 61 | 62 | /// 63 | /// Saturation shift [-0.5 ~ 0.5]. 64 | /// 65 | public float saturation 66 | { 67 | get { return m_Saturation; } 68 | set 69 | { 70 | value = Mathf.Clamp(value, -0.5f, 0.5f); 71 | if (Mathf.Approximately(m_Saturation, value)) return; 72 | m_Saturation = value; 73 | SetEffectParamsDirty(); 74 | } 75 | } 76 | 77 | /// 78 | /// Value shift [-0.5 ~ 0.5]. 79 | /// 80 | public float value 81 | { 82 | get { return m_Value; } 83 | set 84 | { 85 | value = Mathf.Clamp(value, -0.5f, 0.5f); 86 | if (Mathf.Approximately(m_Value, value)) return; 87 | m_Value = value; 88 | SetEffectParamsDirty(); 89 | } 90 | } 91 | 92 | /// 93 | /// Hue shift [-0.5 ~ 0.5]. 94 | /// 95 | public float hue 96 | { 97 | get { return m_Hue; } 98 | set 99 | { 100 | value = Mathf.Clamp(value, -0.5f, 0.5f); 101 | if (Mathf.Approximately(m_Hue, value)) return; 102 | m_Hue = value; 103 | SetEffectParamsDirty(); 104 | } 105 | } 106 | 107 | /// 108 | /// Gets the parameter texture. 109 | /// 110 | public override ParameterTexture paramTex 111 | { 112 | get { return s_ParamTex; } 113 | } 114 | 115 | public override Hash128 GetMaterialHash(Material material) 116 | { 117 | if (!isActiveAndEnabled || !material || !material.shader) 118 | return k_InvalidHash; 119 | 120 | return new Hash128( 121 | (uint) material.GetInstanceID(), 122 | k_ShaderId, 123 | 0, 124 | 0 125 | ); 126 | } 127 | 128 | public override void ModifyMaterial(Material newMaterial, Graphic graphic) 129 | { 130 | var connector = GraphicConnector.FindConnector(graphic); 131 | 132 | newMaterial.shader = Shader.Find(string.Format("Hidden/{0} (UIHsvModifier)", newMaterial.shader.name)); 133 | paramTex.RegisterMaterial(newMaterial); 134 | } 135 | 136 | public override void ModifyMesh(VertexHelper vh, Graphic graphic) 137 | { 138 | if (!isActiveAndEnabled) 139 | return; 140 | 141 | var normalizedIndex = paramTex.GetNormalizedIndex(this); 142 | var vertex = default(UIVertex); 143 | var count = vh.currentVertCount; 144 | for (var i = 0; i < count; i++) 145 | { 146 | vh.PopulateUIVertex(ref vertex, i); 147 | 148 | vertex.uv0 = new Vector2( 149 | Packer.ToFloat(vertex.uv0.x, vertex.uv0.y), 150 | normalizedIndex 151 | ); 152 | vh.SetUIVertex(vertex, i); 153 | } 154 | } 155 | 156 | protected override void SetEffectParamsDirty() 157 | { 158 | float h, s, v; 159 | Color.RGBToHSV(m_TargetColor, out h, out s, out v); 160 | 161 | paramTex.SetData(this, 0, h); // param1.x : target hue 162 | paramTex.SetData(this, 1, s); // param1.y : target saturation 163 | paramTex.SetData(this, 2, v); // param1.z : target value 164 | paramTex.SetData(this, 3, m_Range); // param1.w : target range 165 | paramTex.SetData(this, 4, m_Hue + 0.5f); // param2.x : hue shift 166 | paramTex.SetData(this, 5, m_Saturation + 0.5f); // param2.y : saturation shift 167 | paramTex.SetData(this, 6, m_Value + 0.5f); // param2.z : value shift 168 | } 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /Scripts/UIHsvModifier.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efe700dddcd8341ff8607ac2c827b4b5 3 | timeCreated: 1523859834 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/UIShadow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0848bff101191904ead4bb831f7084db 3 | timeCreated: 1485321967 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: -400 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/UIShiny.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Serialization; 5 | using UnityEngine.UI; 6 | using System.Collections; 7 | 8 | namespace Coffee.UIEffects 9 | { 10 | /// 11 | /// UIEffect. 12 | /// 13 | [AddComponentMenu("UI/UIEffects/UIShiny", 2)] 14 | public class UIShiny : BaseMaterialEffect 15 | { 16 | private const uint k_ShaderId = 1 << 3; 17 | private static readonly ParameterTexture s_ParamTex = new ParameterTexture(8, 128, "_ParamTex"); 18 | 19 | float _lastRotation; 20 | EffectArea _lastEffectArea; 21 | 22 | [Tooltip("Location for shiny effect.")] [FormerlySerializedAs("m_Location")] [SerializeField] [Range(0, 1)] 23 | float m_EffectFactor = 0.5f; 24 | 25 | [Tooltip("Width for shiny effect.")] [SerializeField] [Range(0, 1)] 26 | float m_Width = 0.25f; 27 | 28 | [Tooltip("Rotation for shiny effect.")] [SerializeField] [Range(-180, 180)] 29 | float m_Rotation = 135; 30 | 31 | [Tooltip("Softness for shiny effect.")] [SerializeField] [Range(0.01f, 1)] 32 | float m_Softness = 1f; 33 | 34 | [Tooltip("Brightness for shiny effect.")] [FormerlySerializedAs("m_Alpha")] [SerializeField] [Range(0, 1)] 35 | float m_Brightness = 1f; 36 | 37 | [Tooltip("Gloss factor for shiny effect.")] [FormerlySerializedAs("m_Highlight")] [SerializeField] [Range(0, 1)] 38 | float m_Gloss = 1; 39 | 40 | [Header("Advanced Option")] [Tooltip("The area for effect.")] [SerializeField] 41 | protected EffectArea m_EffectArea; 42 | 43 | [SerializeField] EffectPlayer m_Player; 44 | 45 | /// 46 | /// Effect factor between 0(start) and 1(end). 47 | /// 48 | public float effectFactor 49 | { 50 | get { return m_EffectFactor; } 51 | set 52 | { 53 | value = Mathf.Clamp(value, 0, 1); 54 | if (Mathf.Approximately(m_EffectFactor, value)) return; 55 | m_EffectFactor = value; 56 | SetEffectParamsDirty(); 57 | } 58 | } 59 | 60 | /// 61 | /// Width for shiny effect. 62 | /// 63 | public float width 64 | { 65 | get { return m_Width; } 66 | set 67 | { 68 | value = Mathf.Clamp(value, 0, 1); 69 | if (Mathf.Approximately(m_Width, value)) return; 70 | m_Width = value; 71 | SetEffectParamsDirty(); 72 | } 73 | } 74 | 75 | /// 76 | /// Softness for shiny effect. 77 | /// 78 | public float softness 79 | { 80 | get { return m_Softness; } 81 | set 82 | { 83 | value = Mathf.Clamp(value, 0.01f, 1); 84 | if (Mathf.Approximately(m_Softness, value)) return; 85 | m_Softness = value; 86 | SetEffectParamsDirty(); 87 | } 88 | } 89 | 90 | /// 91 | /// Brightness for shiny effect. 92 | /// 93 | public float brightness 94 | { 95 | get { return m_Brightness; } 96 | set 97 | { 98 | value = Mathf.Clamp(value, 0, 1); 99 | if (Mathf.Approximately(m_Brightness, value)) return; 100 | m_Brightness = value; 101 | SetEffectParamsDirty(); 102 | } 103 | } 104 | 105 | /// 106 | /// Gloss factor for shiny effect. 107 | /// 108 | public float gloss 109 | { 110 | get { return m_Gloss; } 111 | set 112 | { 113 | value = Mathf.Clamp(value, 0, 1); 114 | if (Mathf.Approximately(m_Gloss, value)) return; 115 | m_Gloss = value; 116 | SetEffectParamsDirty(); 117 | } 118 | } 119 | 120 | /// 121 | /// Rotation for shiny effect. 122 | /// 123 | public float rotation 124 | { 125 | get { return m_Rotation; } 126 | set 127 | { 128 | if (Mathf.Approximately(m_Rotation, value)) return; 129 | m_Rotation = value; 130 | SetVerticesDirty(); 131 | } 132 | } 133 | 134 | /// 135 | /// The area for effect. 136 | /// 137 | public EffectArea effectArea 138 | { 139 | get { return m_EffectArea; } 140 | set 141 | { 142 | if (m_EffectArea == value) return; 143 | m_EffectArea = value; 144 | SetVerticesDirty(); 145 | } 146 | } 147 | 148 | /// 149 | /// Gets the parameter texture. 150 | /// 151 | public override ParameterTexture paramTex 152 | { 153 | get { return s_ParamTex; } 154 | } 155 | 156 | public EffectPlayer effectPlayer 157 | { 158 | get { return m_Player ?? (m_Player = new EffectPlayer()); } 159 | } 160 | 161 | /// 162 | /// This function is called when the object becomes enabled and active. 163 | /// 164 | protected override void OnEnable() 165 | { 166 | base.OnEnable(); 167 | effectPlayer.OnEnable(f => effectFactor = f); 168 | } 169 | 170 | /// 171 | /// This function is called when the behaviour becomes disabled () or inactive. 172 | /// 173 | protected override void OnDisable() 174 | { 175 | base.OnDisable(); 176 | effectPlayer.OnDisable(); 177 | } 178 | 179 | 180 | public override Hash128 GetMaterialHash(Material material) 181 | { 182 | if (!isActiveAndEnabled || !material || !material.shader) 183 | return k_InvalidHash; 184 | 185 | return new Hash128( 186 | (uint) material.GetInstanceID(), 187 | k_ShaderId, 188 | 0, 189 | 0 190 | ); 191 | } 192 | 193 | public override void ModifyMaterial(Material newMaterial, Graphic graphic) 194 | { 195 | var connector = GraphicConnector.FindConnector(graphic); 196 | 197 | newMaterial.shader = Shader.Find(string.Format("Hidden/{0} (UIShiny)", newMaterial.shader.name)); 198 | paramTex.RegisterMaterial(newMaterial); 199 | } 200 | 201 | /// 202 | /// Modifies the mesh. 203 | /// 204 | public override void ModifyMesh(VertexHelper vh, Graphic graphic) 205 | { 206 | if (!isActiveAndEnabled) 207 | return; 208 | 209 | var normalizedIndex = paramTex.GetNormalizedIndex(this); 210 | var rect = m_EffectArea.GetEffectArea(vh, rectTransform.rect); 211 | 212 | // rotation. 213 | var rad = m_Rotation * Mathf.Deg2Rad; 214 | var dir = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad)); 215 | dir.x *= rect.height / rect.width; 216 | dir = dir.normalized; 217 | 218 | // Calculate vertex position. 219 | var vertex = default(UIVertex); 220 | var localMatrix = new Matrix2x3(rect, dir.x, dir.y); // Get local matrix. 221 | for (int i = 0; i < vh.currentVertCount; i++) 222 | { 223 | vh.PopulateUIVertex(ref vertex, i); 224 | Vector2 normalizedPos; 225 | connector.GetNormalizedFactor(m_EffectArea, i, localMatrix, vertex.position, out normalizedPos); 226 | 227 | vertex.uv0 = new Vector2( 228 | Packer.ToFloat(vertex.uv0.x, vertex.uv0.y), 229 | Packer.ToFloat(normalizedPos.y, normalizedIndex) 230 | ); 231 | 232 | vh.SetUIVertex(vertex, i); 233 | } 234 | } 235 | 236 | /// 237 | /// Play effect. 238 | /// 239 | public void Play(bool reset = true) 240 | { 241 | effectPlayer.Play(reset); 242 | } 243 | 244 | /// 245 | /// Stop effect. 246 | /// 247 | public void Stop(bool reset = true) 248 | { 249 | effectPlayer.Stop(reset); 250 | } 251 | 252 | protected override void SetEffectParamsDirty() 253 | { 254 | paramTex.SetData(this, 0, m_EffectFactor); // param1.x : location 255 | paramTex.SetData(this, 1, m_Width); // param1.y : width 256 | paramTex.SetData(this, 2, m_Softness); // param1.z : softness 257 | paramTex.SetData(this, 3, m_Brightness); // param1.w : blightness 258 | paramTex.SetData(this, 4, m_Gloss); // param2.x : gloss 259 | } 260 | 261 | protected override void SetVerticesDirty() 262 | { 263 | base.SetVerticesDirty(); 264 | 265 | _lastRotation = m_Rotation; 266 | _lastEffectArea = m_EffectArea; 267 | } 268 | 269 | protected override void OnDidApplyAnimationProperties() 270 | { 271 | base.OnDidApplyAnimationProperties(); 272 | 273 | if (!Mathf.Approximately(_lastRotation, m_Rotation) 274 | || _lastEffectArea != m_EffectArea) 275 | SetVerticesDirty(); 276 | } 277 | } 278 | } 279 | -------------------------------------------------------------------------------- /Scripts/UIShiny.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f19b7e2285c104f6ca47d583f3e5444f 3 | timeCreated: 1523859834 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Scripts/UISyncEffect.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | 7 | namespace Coffee.UIEffects 8 | { 9 | /// 10 | /// Dissolve effect for uGUI. 11 | /// 12 | [ExecuteInEditMode] 13 | public class UISyncEffect : BaseMaterialEffect 14 | { 15 | [Tooltip("The target effect to synchronize.")] [SerializeField] 16 | private BaseMeshEffect m_TargetEffect; 17 | 18 | public BaseMeshEffect targetEffect 19 | { 20 | get { return m_TargetEffect != this ? m_TargetEffect : null; } 21 | set 22 | { 23 | if (m_TargetEffect == value) return; 24 | m_TargetEffect = value; 25 | 26 | SetVerticesDirty(); 27 | SetMaterialDirty(); 28 | SetEffectParamsDirty(); 29 | } 30 | } 31 | 32 | protected override void OnEnable() 33 | { 34 | if (targetEffect) 35 | targetEffect.syncEffects.Add(this); 36 | base.OnEnable(); 37 | } 38 | 39 | protected override void OnDisable() 40 | { 41 | if (targetEffect) 42 | targetEffect.syncEffects.Remove(this); 43 | base.OnDisable(); 44 | } 45 | 46 | public override Hash128 GetMaterialHash(Material baseMaterial) 47 | { 48 | if (!isActiveAndEnabled) return k_InvalidHash; 49 | 50 | var matEffect = targetEffect as BaseMaterialEffect; 51 | if (!matEffect || !matEffect.isActiveAndEnabled) return k_InvalidHash; 52 | 53 | return matEffect.GetMaterialHash(baseMaterial); 54 | } 55 | 56 | public override void ModifyMaterial(Material newMaterial, Graphic graphic) 57 | { 58 | if (!isActiveAndEnabled) return; 59 | 60 | var matEffect = targetEffect as BaseMaterialEffect; 61 | if (!matEffect || !matEffect.isActiveAndEnabled) return; 62 | 63 | matEffect.ModifyMaterial(newMaterial, graphic); 64 | } 65 | 66 | public override void ModifyMesh(VertexHelper vh, Graphic graphic) 67 | { 68 | if (!isActiveAndEnabled) return; 69 | if (!targetEffect || !targetEffect.isActiveAndEnabled) return; 70 | 71 | targetEffect.ModifyMesh(vh, graphic); 72 | } 73 | 74 | #if UNITY_EDITOR 75 | protected override void OnValidate() 76 | { 77 | SetVerticesDirty(); 78 | SetMaterialDirty(); 79 | SetEffectParamsDirty(); 80 | } 81 | #endif 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Scripts/UISyncEffect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7be078926b3448089fe9995b32f75f1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Scripts/UITransitionEffect.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 922b805bc01c243e5853d9cbb544118c 3 | timeCreated: 1538827562 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - m_EffectMaterial: {instanceID: 0} 9 | - m_PtexMaterial: {instanceID: 0} 10 | - m_TransitionTexture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, 11 | type: 3} 12 | executionOrder: 0 13 | icon: {instanceID: 0} 14 | userData: 15 | assetBundleName: 16 | assetBundleVariant: 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.coffee.ui-effect", 3 | "displayName": "UI Effect", 4 | "description": "UI Effect provides visual effect components for Unity UI.\nLet's decorate your UI with effects!", 5 | "version": "4.0.0-preview.9", 6 | "unity": "2017.1", 7 | "license": "MIT", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/mob-sakai/UIEffect.git" 11 | }, 12 | "author": { 13 | "name": "mob-sakai", 14 | "email": "sakai861104@gmail.com", 15 | "url": "https://github.com/mob-sakai" 16 | }, 17 | "dependencies": {}, 18 | "keywords": [ 19 | "ui", 20 | "effect" 21 | ], 22 | "samples": [ 23 | { 24 | "displayName": "Demo", 25 | "description": "UI Effect Demo", 26 | "path": "Samples~/Demo" 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 546af75b6221c4768be79d67c9cea1fb 3 | timeCreated: 1547605752 4 | licenseType: Pro 5 | TextScriptImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | --------------------------------------------------------------------------------