mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-20 01:42:37 +08:00
Compare commits
50 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 99375cce90 | |||
| a13f4702da | |||
| 8247a34341 | |||
| 175011211e | |||
| 5ff0de7354 | |||
| 1709f2de26 | |||
| 9266e4c50f | |||
| eaba40fc29 | |||
| 47d9f2978d | |||
| 950b07cfcc | |||
| 0a85f355c1 | |||
| c7782686ae | |||
| c9809ff1f4 | |||
| b9e0da1316 | |||
| 9e79f18613 | |||
| 8c4dc5d996 | |||
| 850ae8e7e4 | |||
| 7724d5a9ed | |||
| 3215160a8f | |||
| 0c1468b257 | |||
| 5de1ff78a4 | |||
| 896ea1ab93 | |||
| cdd8e2b7b0 | |||
| e660c8233d | |||
| b0f7ad390a | |||
| 51f8e13949 | |||
| 8682783932 | |||
| a854d5d561 | |||
| d9361ebf74 | |||
| 5f1fdedb3c | |||
| 33881e7c6a | |||
| b3a3edd30a | |||
| da9f36397d | |||
| ff0ea5d24c | |||
| 67c0bf9f6d | |||
| a2ad00041b | |||
| 97a6f48ac1 | |||
| bfc3468705 | |||
| 66516f0e2d | |||
| 20717fdca6 | |||
| 4f179ea5fc | |||
| a073a70582 | |||
| 91830e2b20 | |||
| cd970b05a9 | |||
| 7be2f6f8d7 | |||
| 9903cce242 | |||
| 21f8af7668 | |||
| ee0c1ceee3 | |||
| 8b31489593 | |||
| 76bfd259cf |
Executable
+23
@@ -0,0 +1,23 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Environment (please complete the following information):**
|
||||
- Platform: [e.g. Editor(Windows/Mac), Standalone(Windows/Mac), iOS, Android, WebGL]
|
||||
- Unity: [e.g. 2018.2.8f1]
|
||||
- UIEffect: [e.g. v3.0.0]
|
||||
|
||||
**Additional context**
|
||||
Add any other context, screenshots or gif animations about the bug here.
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context, screenshots or gif animations about the feature request here.
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
---
|
||||
name: Question
|
||||
about: Feel free to ask us any question.
|
||||
|
||||
---
|
||||
|
||||
**Describe the question**
|
||||
A clear and concise description of what the question is.
|
||||
|
||||
**Environment (please complete the following information):**
|
||||
- Platform: [e.g. Editor(Windows/Mac), Standalone(Windows/Mac), iOS, Android, WebGL]
|
||||
- Unity: [e.g. 2018.2.8f1]
|
||||
- UIEffect: [e.g. v3.0.0]
|
||||
|
||||
**Additional context**
|
||||
Add any other context, screenshots or gif animations about the question here.
|
||||
@@ -7,7 +7,7 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
public class UIEffect_Demo : MonoBehaviour
|
||||
{
|
||||
[SerializeField] RectMask2D mask;
|
||||
[SerializeField] RectMask2D mask = null;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
@@ -40,5 +40,10 @@ namespace Coffee.UIExtensions
|
||||
anim.GetComponentInChildren<UIEffectCapturedImage>().Capture();
|
||||
anim.SetTrigger("Capture");
|
||||
}
|
||||
|
||||
public void SetCanvasOverlay(bool isOverlay)
|
||||
{
|
||||
GetComponent<Canvas> ().renderMode = isOverlay ? RenderMode.ScreenSpaceOverlay : RenderMode.ScreenSpaceCamera;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!200 &20000000
|
||||
ShaderVariantCollection:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UIEffect_Demo
|
||||
m_Shaders:
|
||||
- first: {fileID: 4800000, guid: 7a6f925a07c3c5846a1c782eaaeb7087, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: DETAILBLUR GRAYSCALE
|
||||
passType: 0
|
||||
- keywords: DETAILBLUR SEPIA
|
||||
passType: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73036fa061ee340dcb3c04b9d8872e66
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 20000000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because one or more lines are too long
@@ -34,7 +34,7 @@ TextureImporter:
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
filterMode: 0
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: 1
|
||||
|
||||
@@ -330,7 +330,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -400,7 +400,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
public class UIEffect_Demo_Dialog : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Animator m_Animator;
|
||||
[SerializeField] Animator m_Animator = null;
|
||||
|
||||
public void Open()
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_Location
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f19b7e2285c104f6ca47d583f3e5444f, type: 3}
|
||||
@@ -80,7 +80,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_Location
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: ce76b7a490bd74f34a2f2752641aea24, type: 3}
|
||||
@@ -158,7 +158,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_Blur
|
||||
attribute: m_BlurFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -214,7 +214,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -242,7 +242,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path: Mask
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -354,7 +354,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path: Pixel
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -470,6 +470,34 @@ AnimationClip:
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: efe700dddcd8341ff8607ac2c827b4b5, type: 3}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
- serializedVersion: 2
|
||||
time: 1.2
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
- serializedVersion: 2
|
||||
time: 2.4
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ColorFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
m_PPtrCurves: []
|
||||
m_SampleRate: 10
|
||||
m_WrapMode: 0
|
||||
@@ -574,6 +602,12 @@ AnimationClip:
|
||||
classID: 114
|
||||
customType: 0
|
||||
isPPtrCurve: 0
|
||||
- path: 0
|
||||
attribute: 4097790204
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
classID: 114
|
||||
customType: 0
|
||||
isPPtrCurve: 0
|
||||
pptrCurveMapping: []
|
||||
m_AnimationClipSettings:
|
||||
serializedVersion: 2
|
||||
@@ -626,7 +660,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_Location
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f19b7e2285c104f6ca47d583f3e5444f, type: 3}
|
||||
@@ -660,7 +694,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_Location
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: ce76b7a490bd74f34a2f2752641aea24, type: 3}
|
||||
@@ -738,7 +772,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_Blur
|
||||
attribute: m_BlurFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -794,7 +828,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -822,7 +856,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path: Mask
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -934,7 +968,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path: Pixel
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -1050,6 +1084,34 @@ AnimationClip:
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: efe700dddcd8341ff8607ac2c827b4b5, type: 3}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
- serializedVersion: 2
|
||||
time: 1.2
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
- serializedVersion: 2
|
||||
time: 2.4
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ColorFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 0
|
||||
m_HasMotionFloatCurves: 0
|
||||
|
||||
@@ -46,7 +46,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -124,7 +124,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_Location
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: ce76b7a490bd74f34a2f2752641aea24, type: 3}
|
||||
@@ -280,7 +280,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -358,7 +358,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_Location
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: ce76b7a490bd74f34a2f2752641aea24, type: 3}
|
||||
@@ -759,7 +759,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
@@ -829,7 +829,7 @@ AnimationClip:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_ToneLevel
|
||||
attribute: m_EffectFactor
|
||||
path:
|
||||
classID: 114
|
||||
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
|
||||
|
||||
@@ -27,6 +27,12 @@ Material:
|
||||
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -80,6 +86,12 @@ Material:
|
||||
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -133,6 +145,12 @@ Material:
|
||||
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -186,6 +204,12 @@ Material:
|
||||
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
|
||||
@@ -69,6 +69,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _BumpScale
|
||||
|
||||
@@ -21,6 +21,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
|
||||
@@ -115,6 +115,18 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _TransitionTexture
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -235,6 +247,65 @@ Material:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21131850011850196
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 9
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UI-Effect-Transition-Dissolve
|
||||
m_Shader: {fileID: 4800000, guid: 85ad24dd0759947ddb117625e108d49c, type: 3}
|
||||
m_ShaderKeywords: DISSOLVE
|
||||
m_LightmapFlags: 5
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
m_SavedProperties:
|
||||
serializedVersion: 2
|
||||
m_TexEnvs:
|
||||
- first:
|
||||
name: _MainTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _TransitionTexture
|
||||
second:
|
||||
m_Texture: {fileID: 2800000, guid: a74d3d4a498866d44b094d3d3717604d, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
second: 15
|
||||
- first:
|
||||
name: _Stencil
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilComp
|
||||
second: 8
|
||||
- first:
|
||||
name: _StencilOp
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilReadMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _StencilWriteMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _UseUIAlphaClip
|
||||
second: 0
|
||||
m_Colors:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21165426070421698
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
@@ -329,6 +400,65 @@ Material:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21383746192470066
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 9
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UI-Effect-Transition-Fade
|
||||
m_Shader: {fileID: 4800000, guid: 85ad24dd0759947ddb117625e108d49c, type: 3}
|
||||
m_ShaderKeywords: FADE
|
||||
m_LightmapFlags: 5
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
m_SavedProperties:
|
||||
serializedVersion: 2
|
||||
m_TexEnvs:
|
||||
- first:
|
||||
name: _MainTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _TransitionTexture
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
second: 15
|
||||
- first:
|
||||
name: _Stencil
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilComp
|
||||
second: 8
|
||||
- first:
|
||||
name: _StencilOp
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilReadMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _StencilWriteMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _UseUIAlphaClip
|
||||
second: 0
|
||||
m_Colors:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21397352971802982
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
|
||||
@@ -21,6 +21,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -162,6 +168,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -209,6 +221,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -397,6 +415,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -773,6 +797,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -1149,6 +1179,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -1619,6 +1655,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -1786,6 +1828,59 @@ Material:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21305736874167728
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 9
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UI-Effect-Fill-DetailBlur-Ex
|
||||
m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3}
|
||||
m_ShaderKeywords: DETAILBLUR EX FILL
|
||||
m_LightmapFlags: 5
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
m_SavedProperties:
|
||||
serializedVersion: 2
|
||||
m_TexEnvs:
|
||||
- first:
|
||||
name: _MainTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
second: 15
|
||||
- first:
|
||||
name: _Stencil
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilComp
|
||||
second: 8
|
||||
- first:
|
||||
name: _StencilOp
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilReadMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _StencilWriteMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _UseUIAlphaClip
|
||||
second: 0
|
||||
m_Colors:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21306681885004364
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
@@ -2418,6 +2513,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -2726,6 +2827,59 @@ Material:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21448049851552048
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 9
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UI-Effect-MediumBlur-Ex
|
||||
m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3}
|
||||
m_ShaderKeywords: EX MEDIUMBLUR
|
||||
m_LightmapFlags: 5
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
m_SavedProperties:
|
||||
serializedVersion: 2
|
||||
m_TexEnvs:
|
||||
- first:
|
||||
name: _MainTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
second: 15
|
||||
- first:
|
||||
name: _Stencil
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilComp
|
||||
second: 8
|
||||
- first:
|
||||
name: _StencilOp
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilReadMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _StencilWriteMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _UseUIAlphaClip
|
||||
second: 0
|
||||
m_Colors:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21450770079124654
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
@@ -2841,6 +2995,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -2935,6 +3095,65 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
second: 15
|
||||
- first:
|
||||
name: _Stencil
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilComp
|
||||
second: 8
|
||||
- first:
|
||||
name: _StencilOp
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilReadMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _StencilWriteMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _UseUIAlphaClip
|
||||
second: 0
|
||||
m_Colors:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21510007115466990
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 9
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UI-Effect-Add-DetailBlur-Ex
|
||||
m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3}
|
||||
m_ShaderKeywords: ADD DETAILBLUR EX
|
||||
m_LightmapFlags: 5
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
m_SavedProperties:
|
||||
serializedVersion: 2
|
||||
m_TexEnvs:
|
||||
- first:
|
||||
name: _MainTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -2982,6 +3201,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -3149,6 +3374,59 @@ Material:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21541535114347366
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 9
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UI-Effect-DetailBlur-Ex
|
||||
m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3}
|
||||
m_ShaderKeywords: DETAILBLUR EX
|
||||
m_LightmapFlags: 5
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
m_SavedProperties:
|
||||
serializedVersion: 2
|
||||
m_TexEnvs:
|
||||
- first:
|
||||
name: _MainTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
second: 15
|
||||
- first:
|
||||
name: _Stencil
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilComp
|
||||
second: 8
|
||||
- first:
|
||||
name: _StencilOp
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilReadMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _StencilWriteMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _UseUIAlphaClip
|
||||
second: 0
|
||||
m_Colors:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21542047413524304
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
@@ -3358,6 +3636,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -3854,6 +4138,59 @@ Material:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21635119553697766
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 9
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UI-Effect-FastBlur-Ex
|
||||
m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3}
|
||||
m_ShaderKeywords: EX FASTBLUR
|
||||
m_LightmapFlags: 5
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
m_SavedProperties:
|
||||
serializedVersion: 2
|
||||
m_TexEnvs:
|
||||
- first:
|
||||
name: _MainTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
second: 15
|
||||
- first:
|
||||
name: _Stencil
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilComp
|
||||
second: 8
|
||||
- first:
|
||||
name: _StencilOp
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilReadMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _StencilWriteMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _UseUIAlphaClip
|
||||
second: 0
|
||||
m_Colors:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21639588145429544
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
@@ -4486,6 +4823,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -4580,6 +4923,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -4768,6 +5117,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -4909,6 +5264,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -5003,6 +5364,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -5097,6 +5464,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -5264,6 +5637,59 @@ Material:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21812566947609066
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 9
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: UI-Effect-Grayscale-DetailBlur-Ex
|
||||
m_Shader: {fileID: 4800000, guid: b868e81d0156245e08c8646b4fb68d7a, type: 3}
|
||||
m_ShaderKeywords: DETAILBLUR EX GRAYSCALE
|
||||
m_LightmapFlags: 5
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
m_SavedProperties:
|
||||
serializedVersion: 2
|
||||
m_TexEnvs:
|
||||
- first:
|
||||
name: _MainTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
second: 15
|
||||
- first:
|
||||
name: _Stencil
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilComp
|
||||
second: 8
|
||||
- first:
|
||||
name: _StencilOp
|
||||
second: 0
|
||||
- first:
|
||||
name: _StencilReadMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _StencilWriteMask
|
||||
second: 255
|
||||
- first:
|
||||
name: _UseUIAlphaClip
|
||||
second: 0
|
||||
m_Colors:
|
||||
- first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!21 &21846284721920408
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
@@ -5426,6 +5852,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -5661,6 +6093,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
@@ -5990,6 +6428,12 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- first:
|
||||
name: _ParamTex
|
||||
second:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- first:
|
||||
name: _ColorMask
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Effect player.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class EffectPlayer
|
||||
{
|
||||
//################################
|
||||
// Public Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether is playing.
|
||||
/// </summary>
|
||||
[Tooltip("Playing.")]
|
||||
public bool play = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether can loop.
|
||||
/// </summary>
|
||||
[Tooltip("Loop.")]
|
||||
public bool loop = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the duration.
|
||||
/// </summary>
|
||||
[Tooltip("Duration.")]
|
||||
[Range(0.01f,10f)]
|
||||
public float duration = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the delay before looping.
|
||||
/// </summary>
|
||||
[Tooltip("Delay before looping.")]
|
||||
[Range(0f,10f)]
|
||||
public float loopDelay = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the update mode.
|
||||
/// </summary>
|
||||
[Tooltip("Update mode")]
|
||||
public AnimatorUpdateMode updateMode = AnimatorUpdateMode.Normal;
|
||||
|
||||
static List<Action> s_UpdateActions;
|
||||
|
||||
/// <summary>
|
||||
/// Register player.
|
||||
/// </summary>
|
||||
public void OnEnable(Action<float> callback = null)
|
||||
{
|
||||
|
||||
if (s_UpdateActions == null)
|
||||
{
|
||||
s_UpdateActions = new List<Action>();
|
||||
Canvas.willRenderCanvases += () =>
|
||||
{
|
||||
var count = s_UpdateActions.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
s_UpdateActions[i].Invoke();
|
||||
}
|
||||
};
|
||||
}
|
||||
s_UpdateActions.Add(OnWillRenderCanvases);
|
||||
|
||||
_time = 0;
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregister player.
|
||||
/// </summary>
|
||||
public void OnDisable()
|
||||
{
|
||||
_callback = null;
|
||||
s_UpdateActions.Remove(OnWillRenderCanvases);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start playing.
|
||||
/// </summary>
|
||||
public void Play(Action<float> callback = null)
|
||||
{
|
||||
_time = 0;
|
||||
play = true;
|
||||
if (callback != null)
|
||||
{
|
||||
_callback = callback;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop playing.
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
play = false;
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
float _time = 0;
|
||||
Action<float> _callback;
|
||||
|
||||
void OnWillRenderCanvases()
|
||||
{
|
||||
if (!play || !Application.isPlaying || _callback == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_time += updateMode == AnimatorUpdateMode.UnscaledTime
|
||||
? Time.unscaledDeltaTime
|
||||
: Time.deltaTime;
|
||||
var current = _time / duration;
|
||||
|
||||
if (duration <= _time)
|
||||
{
|
||||
play = loop;
|
||||
_time = loop ? -loopDelay : 0;
|
||||
}
|
||||
_callback(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1656fb67110cd44298010d95c324e87a
|
||||
timeCreated: 1528296875
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,23 +7,59 @@ namespace Coffee.UIExtensions
|
||||
public class MaterialCache
|
||||
{
|
||||
public ulong hash { get; private set; }
|
||||
|
||||
public int referenceCount { get; private set; }
|
||||
|
||||
public Texture texture { get; private set; }
|
||||
|
||||
public Material material { get; private set; }
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.InitializeOnLoadMethod]
|
||||
static void ClearCache()
|
||||
{
|
||||
materialCache.Clear();
|
||||
foreach (var cache in materialCaches)
|
||||
{
|
||||
cache.material = null;
|
||||
}
|
||||
materialCaches.Clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
public static List<MaterialCache> materialCache = new List<MaterialCache>();
|
||||
public static List<MaterialCache> materialCaches = new List<MaterialCache>();
|
||||
|
||||
public static MaterialCache Register(ulong hash, Texture texture, System.Func<Material> onCreateMaterial)
|
||||
{
|
||||
var cache = materialCache.FirstOrDefault(x => x.hash == hash);
|
||||
var cache = materialCaches.FirstOrDefault(x => x.hash == hash);
|
||||
if (cache != null && cache.material)
|
||||
{
|
||||
if (cache.material)
|
||||
{
|
||||
cache.referenceCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
materialCaches.Remove(cache);
|
||||
cache = null;
|
||||
}
|
||||
}
|
||||
if (cache == null)
|
||||
{
|
||||
cache = new MaterialCache()
|
||||
{
|
||||
hash = hash,
|
||||
material = onCreateMaterial(),
|
||||
referenceCount = 1,
|
||||
};
|
||||
materialCaches.Add(cache);
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
public static MaterialCache Register(ulong hash, System.Func<Material> onCreateMaterial)
|
||||
{
|
||||
var cache = materialCaches.FirstOrDefault(x => x.hash == hash);
|
||||
if (cache != null)
|
||||
{
|
||||
cache.referenceCount++;
|
||||
@@ -33,11 +69,10 @@ namespace Coffee.UIExtensions
|
||||
cache = new MaterialCache()
|
||||
{
|
||||
hash = hash,
|
||||
texture = texture,
|
||||
material = onCreateMaterial(),
|
||||
referenceCount = 1,
|
||||
};
|
||||
materialCache.Add(cache);
|
||||
materialCaches.Add(cache);
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
@@ -52,9 +87,8 @@ namespace Coffee.UIExtensions
|
||||
cache.referenceCount--;
|
||||
if (cache.referenceCount <= 0)
|
||||
{
|
||||
MaterialCache.materialCache.Remove(cache);
|
||||
MaterialCache.materialCaches.Remove(cache);
|
||||
cache.material = null;
|
||||
cache.texture = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,25 +10,27 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
public class MaterialResolver
|
||||
{
|
||||
static readonly StringBuilder s_StringBuilder = new StringBuilder ();
|
||||
static readonly StringBuilder s_StringBuilder = new StringBuilder();
|
||||
|
||||
static readonly Dictionary<string, Material> s_MaterialMap = new Dictionary<string, Material> ();
|
||||
static readonly Dictionary<string, Material> s_MaterialMap = new Dictionary<string, Material>();
|
||||
|
||||
public static Material GetOrGenerateMaterialVariant (Shader shader, params object[] append)
|
||||
public static Material GetOrGenerateMaterialVariant(Shader shader, params object[] append)
|
||||
{
|
||||
if (!shader) {
|
||||
if (!shader)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string[] keywords = append.Where (x => 0 < (int)x)
|
||||
.Select (x => x.ToString ().ToUpper ())
|
||||
.ToArray ();
|
||||
Material mat = GetMaterial (shader, append);
|
||||
if (mat) {
|
||||
if(!mat.shaderKeywords.OrderBy(x=>x).SequenceEqual(keywords.OrderBy(x=>x)))
|
||||
string[] keywords = append.Where(x => 0 < (int)x)
|
||||
.Select(x => x.ToString().ToUpper())
|
||||
.ToArray();
|
||||
Material mat = GetMaterial(shader, append);
|
||||
if (mat)
|
||||
{
|
||||
if (!mat.shaderKeywords.OrderBy(x => x).SequenceEqual(keywords.OrderBy(x => x)))
|
||||
{
|
||||
mat.shaderKeywords = keywords;
|
||||
EditorUtility.SetDirty (mat);
|
||||
EditorUtility.SetDirty(mat);
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
EditorApplication.delayCall += AssetDatabase.SaveAssets;
|
||||
@@ -37,28 +39,28 @@ namespace Coffee.UIExtensions
|
||||
return mat;
|
||||
}
|
||||
|
||||
string variantName = GetVariantName (shader, append);
|
||||
if(s_MaterialMap.TryGetValue(variantName, out mat) && mat)
|
||||
string variantName = GetVariantName(shader, append);
|
||||
if (s_MaterialMap.TryGetValue(variantName, out mat) && mat)
|
||||
{
|
||||
return mat;
|
||||
}
|
||||
|
||||
Debug.Log ("Generate material : " + variantName);
|
||||
mat = new Material (shader);
|
||||
Debug.Log("Generate material : " + variantName);
|
||||
mat = new Material(shader);
|
||||
mat.shaderKeywords = keywords;
|
||||
|
||||
mat.name = variantName;
|
||||
mat.hideFlags |= HideFlags.NotEditable;
|
||||
s_MaterialMap [variantName] = mat;
|
||||
s_MaterialMap[variantName] = mat;
|
||||
|
||||
bool isMainAsset = append.Cast<int> ().All (x => x == 0);
|
||||
EditorApplication.delayCall += () => SaveMaterial (mat, shader, isMainAsset);
|
||||
bool isMainAsset = append.Cast<int>().All(x => x == 0);
|
||||
EditorApplication.delayCall += () => SaveMaterial(mat, shader, isMainAsset);
|
||||
return mat;
|
||||
}
|
||||
|
||||
static void SaveMaterial (Material mat, Shader shader, bool isMainAsset)
|
||||
static void SaveMaterial(Material mat, Shader shader, bool isMainAsset)
|
||||
{
|
||||
string materialPath = GetDefaultMaterialPath (shader);
|
||||
string materialPath = GetDefaultMaterialPath(shader);
|
||||
|
||||
#if UIEFFECT_SEPARATE
|
||||
string dir = Path.GetDirectoryName(materialPath);
|
||||
@@ -67,50 +69,51 @@ namespace Coffee.UIExtensions
|
||||
#endif
|
||||
if (isMainAsset)
|
||||
{
|
||||
Directory.CreateDirectory (Path.GetDirectoryName (materialPath));
|
||||
AssetDatabase.CreateAsset (mat, materialPath);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(materialPath));
|
||||
AssetDatabase.CreateAsset(mat, materialPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetOrGenerateMaterialVariant (shader);
|
||||
GetOrGenerateMaterialVariant(shader);
|
||||
mat.hideFlags |= HideFlags.HideInHierarchy;
|
||||
AssetDatabase.AddObjectToAsset (mat, materialPath);
|
||||
AssetDatabase.AddObjectToAsset(mat, materialPath);
|
||||
}
|
||||
AssetDatabase.SaveAssets ();
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
public static Material GetMaterial (Shader shader, params object[] append)
|
||||
public static Material GetMaterial(Shader shader, params object[] append)
|
||||
{
|
||||
string variantName = GetVariantName (shader, append);
|
||||
return AssetDatabase.FindAssets ("t:Material " + Path.GetFileName (shader.name))
|
||||
.Select (x => AssetDatabase.GUIDToAssetPath (x))
|
||||
.SelectMany (x => AssetDatabase.LoadAllAssetsAtPath (x))
|
||||
.OfType<Material> ()
|
||||
.FirstOrDefault (x => x.name == variantName);
|
||||
string variantName = GetVariantName(shader, append);
|
||||
return AssetDatabase.FindAssets("t:Material " + Path.GetFileName(shader.name))
|
||||
.Select(x => AssetDatabase.GUIDToAssetPath(x))
|
||||
.SelectMany(x => AssetDatabase.LoadAllAssetsAtPath(x))
|
||||
.OfType<Material>()
|
||||
.FirstOrDefault(x => x.name == variantName);
|
||||
}
|
||||
|
||||
public static string GetDefaultMaterialPath (Shader shader)
|
||||
public static string GetDefaultMaterialPath(Shader shader)
|
||||
{
|
||||
var name = Path.GetFileName (shader.name);
|
||||
return AssetDatabase.FindAssets ("t:Material " + name)
|
||||
.Select (x => AssetDatabase.GUIDToAssetPath (x))
|
||||
.FirstOrDefault (x => Path.GetFileNameWithoutExtension (x) == name)
|
||||
var name = Path.GetFileName(shader.name);
|
||||
return AssetDatabase.FindAssets("t:Material " + name)
|
||||
.Select(x => AssetDatabase.GUIDToAssetPath(x))
|
||||
.FirstOrDefault(x => Path.GetFileNameWithoutExtension(x) == name)
|
||||
?? ("Assets/" + name + ".mat");
|
||||
}
|
||||
|
||||
public static string GetVariantName (Shader shader, params object[] append)
|
||||
public static string GetVariantName(Shader shader, params object[] append)
|
||||
{
|
||||
s_StringBuilder.Length = 0;
|
||||
|
||||
#if UIEFFECT_SEPARATE
|
||||
s_StringBuilder.Append("[Separated] ");
|
||||
#endif
|
||||
s_StringBuilder.Append (Path.GetFileName (shader.name));
|
||||
foreach (object mode in append.Where(x=>0<(int)x)) {
|
||||
s_StringBuilder.Append ("-");
|
||||
s_StringBuilder.Append (mode.ToString ());
|
||||
s_StringBuilder.Append(Path.GetFileName(shader.name));
|
||||
foreach (object mode in append.Where(x=>0<(int)x))
|
||||
{
|
||||
s_StringBuilder.Append("-");
|
||||
s_StringBuilder.Append(mode.ToString());
|
||||
}
|
||||
return s_StringBuilder.ToString ();
|
||||
return s_StringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ public static class Packer
|
||||
/// </summary>
|
||||
public static float ToFloat(float x, float y, float z, float w)
|
||||
{
|
||||
x = x < 0 ? 0 : 1 < x ? 1 : x;
|
||||
y = y < 0 ? 0 : 1 < y ? 1 : y;
|
||||
z = z < 0 ? 0 : 1 < z ? 1 : z;
|
||||
w = w < 0 ? 0 : 1 < w ? 1 : w;
|
||||
const int PRECISION = (1 << 6) - 1;
|
||||
return (Mathf.FloorToInt(w * PRECISION) << 18)
|
||||
+ (Mathf.FloorToInt(z * PRECISION) << 12)
|
||||
@@ -27,11 +31,14 @@ public static class Packer
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pack 3 low-precision [0-1] floats values to a float.
|
||||
/// Each value [0-1] has 256 steps(8 bits).
|
||||
/// Pack 1 middle-precision & 2 low-precision [0-1] floats values to a float.
|
||||
/// z value [0-1] has 4096 steps(12 bits) and xy value [0-1] has 64 steps(6 bits).
|
||||
/// </summary>
|
||||
public static float ToFloat(float x, float y, float z)
|
||||
{
|
||||
x = x < 0 ? 0 : 1 < x ? 1 : x;
|
||||
y = y < 0 ? 0 : 1 < y ? 1 : y;
|
||||
z = z < 0 ? 0 : 1 < z ? 1 : z;
|
||||
const int PRECISION = (1 << 8) - 1;
|
||||
return (Mathf.FloorToInt(z * PRECISION) << 16)
|
||||
+ (Mathf.FloorToInt(y * PRECISION) << 8)
|
||||
@@ -44,6 +51,8 @@ public static class Packer
|
||||
/// </summary>
|
||||
public static float ToFloat(float x, float y)
|
||||
{
|
||||
x = x < 0 ? 0 : 1 < x ? 1 : x;
|
||||
y = y < 0 ? 0 : 1 < y ? 1 : y;
|
||||
const int PRECISION = (1 << 12) - 1;
|
||||
return (Mathf.FloorToInt(y * PRECISION) << 12)
|
||||
+ Mathf.FloorToInt(x * PRECISION);
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using System;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
public interface IParameterTexture
|
||||
{
|
||||
int parameterIndex { get; set; }
|
||||
|
||||
ParameterTexture ptex { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameter texture.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class ParameterTexture
|
||||
{
|
||||
|
||||
//################################
|
||||
// Public Members.
|
||||
//################################
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Coffee.UIExtensions.ParameterTexture"/> class.
|
||||
/// </summary>
|
||||
/// <param name="channels">Channels.</param>
|
||||
/// <param name="instanceLimit">Instance limit.</param>
|
||||
/// <param name="propertyName">Property name.</param>
|
||||
public ParameterTexture(int channels, int instanceLimit, string propertyName)
|
||||
{
|
||||
_propertyName = propertyName;
|
||||
_channels = ((channels - 1) / 4 + 1) * 4;
|
||||
_instanceLimit = ((instanceLimit - 1) / 2 + 1) * 2;
|
||||
_data = new byte[_channels * _instanceLimit];
|
||||
|
||||
_stack = new Stack<int>(_instanceLimit);
|
||||
for (int i = 1; i < _instanceLimit + 1; i++)
|
||||
{
|
||||
_stack.Push(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Register the specified target.
|
||||
/// </summary>
|
||||
/// <param name="target">Target.</param>
|
||||
public void Register(IParameterTexture target)
|
||||
{
|
||||
Initialize();
|
||||
if (target.parameterIndex <= 0 && 0 < _stack.Count)
|
||||
{
|
||||
target.parameterIndex = _stack.Pop();
|
||||
// Debug.LogFormat("<color=green>@@@ Register {0} : {1}</color>", target, target.parameterIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregister the specified target.
|
||||
/// </summary>
|
||||
/// <param name="target">Target.</param>
|
||||
public void Unregister(IParameterTexture target)
|
||||
{
|
||||
if (0 < target.parameterIndex)
|
||||
{
|
||||
// Debug.LogFormat("<color=red>@@@ Unregister {0} : {1}</color>", target, target.parameterIndex);
|
||||
_stack.Push(target.parameterIndex);
|
||||
target.parameterIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the data.
|
||||
/// </summary>
|
||||
/// <param name="target">Target.</param>
|
||||
/// <param name="channelId">Channel identifier.</param>
|
||||
/// <param name="value">Value.</param>
|
||||
public void SetData(IParameterTexture target, int channelId, byte value)
|
||||
{
|
||||
int index = (target.parameterIndex - 1) * _channels + channelId;
|
||||
if (0 < target.parameterIndex && _data[index] != value)
|
||||
{
|
||||
_data[index] = value;
|
||||
_needUpload = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the data.
|
||||
/// </summary>
|
||||
/// <param name="target">Target.</param>
|
||||
/// <param name="channelId">Channel identifier.</param>
|
||||
/// <param name="value">Value.</param>
|
||||
public void SetData(IParameterTexture target, int channelId, float value)
|
||||
{
|
||||
SetData(target, channelId, (byte)(Mathf.Clamp01(value) * 255));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the material.
|
||||
/// </summary>
|
||||
/// <param name="mat">Mat.</param>
|
||||
public void RegisterMaterial(Material mat)
|
||||
{
|
||||
if (_propertyId == 0)
|
||||
{
|
||||
_propertyId = Shader.PropertyToID(_propertyName);
|
||||
}
|
||||
if (mat)
|
||||
{
|
||||
mat.SetTexture(_propertyId, _texture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the index of the normalized.
|
||||
/// </summary>
|
||||
/// <returns>The normalized index.</returns>
|
||||
/// <param name="target">Target.</param>
|
||||
public float GetNormalizedIndex(IParameterTexture target)
|
||||
{
|
||||
return ((float)target.parameterIndex - 0.5f) / _instanceLimit;
|
||||
}
|
||||
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
|
||||
Texture2D _texture;
|
||||
bool _needUpload;
|
||||
int _propertyId;
|
||||
readonly string _propertyName;
|
||||
readonly int _channels;
|
||||
readonly int _instanceLimit;
|
||||
readonly byte[] _data;
|
||||
readonly Stack<int> _stack;
|
||||
static List<Action> updates;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize this instance.
|
||||
/// </summary>
|
||||
void Initialize()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!UnityEditor.EditorApplication.isPlaying && UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (updates == null)
|
||||
{
|
||||
updates = new List<Action>();
|
||||
Canvas.willRenderCanvases += () =>
|
||||
{
|
||||
var count = updates.Count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
updates[i].Invoke();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (!_texture)
|
||||
{
|
||||
_texture = new Texture2D(_channels / 4, _instanceLimit, TextureFormat.RGBA32, false, false);
|
||||
_texture.filterMode = FilterMode.Point;
|
||||
_texture.wrapMode = TextureWrapMode.Clamp;
|
||||
|
||||
updates.Add(UpdateParameterTexture);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateParameterTexture()
|
||||
{
|
||||
if (_needUpload && _texture)
|
||||
{
|
||||
_needUpload = false;
|
||||
_texture.LoadRawTextureData(_data);
|
||||
_texture.Apply(false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4961e148a8cd4fe0b84dddc2741894a
|
||||
timeCreated: 1487152293
|
||||
guid: 65eafa89b3a3a494a99e185423ba6cad
|
||||
timeCreated: 1533006319
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
@@ -3,15 +3,12 @@
|
||||
/// <summary>
|
||||
/// Effect mode.
|
||||
/// </summary>
|
||||
public enum ToneMode
|
||||
public enum EffectMode
|
||||
{
|
||||
None = 0,
|
||||
Grayscale = 1,
|
||||
Sepia = 2,
|
||||
Nega = 3,
|
||||
Pixel = 4,
|
||||
Mono = 5,
|
||||
Cutoff = 6,
|
||||
Hue = 7,
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,38 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract effect base for UI.
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Graphic))]
|
||||
[DisallowMultipleComponent]
|
||||
public abstract class UIEffectBase : BaseMeshEffect
|
||||
public abstract class UIEffectBase : BaseMeshEffect, IParameterTexture
|
||||
#if UNITY_EDITOR
|
||||
, ISerializationCallbackReceiver
|
||||
#endif
|
||||
{
|
||||
protected static readonly Vector2[] splitedCharacterPosition = { Vector2.up, Vector2.one, Vector2.right, Vector2.zero };
|
||||
protected static readonly List<UIVertex> tempVerts = new List<UIVertex>();
|
||||
|
||||
[HideInInspector]
|
||||
[SerializeField] int m_Version;
|
||||
[SerializeField] protected Material m_EffectMaterial;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the parameter index.
|
||||
/// </summary>
|
||||
public int parameterIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameter texture.
|
||||
/// </summary>
|
||||
public virtual ParameterTexture ptex { get { return null; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets target graphic for effect.
|
||||
/// </summary>
|
||||
@@ -30,13 +46,14 @@ namespace Coffee.UIExtensions
|
||||
#if UNITY_EDITOR
|
||||
protected override void Reset()
|
||||
{
|
||||
m_Version = 300;
|
||||
OnValidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the validate event.
|
||||
/// </summary>
|
||||
protected override void OnValidate ()
|
||||
protected override void OnValidate()
|
||||
{
|
||||
var mat = GetMaterial();
|
||||
if (m_EffectMaterial != mat)
|
||||
@@ -44,10 +61,46 @@ namespace Coffee.UIExtensions
|
||||
m_EffectMaterial = mat;
|
||||
UnityEditor.EditorUtility.SetDirty(this);
|
||||
}
|
||||
|
||||
ModifyMaterial();
|
||||
targetGraphic.SetVerticesDirty();
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
UnityEditor.EditorApplication.delayCall += UpgradeIfNeeded;
|
||||
}
|
||||
|
||||
protected bool IsShouldUpgrade(int expectedVersion)
|
||||
{
|
||||
if (m_Version < expectedVersion)
|
||||
{
|
||||
Debug.LogFormat(gameObject, "<b>{0}({1})</b> has been upgraded: <i>version {2} -> {3}</i>", name, GetType().Name, m_Version, expectedVersion);
|
||||
m_Version = expectedVersion;
|
||||
|
||||
//UnityEditor.EditorApplication.delayCall += () =>
|
||||
{
|
||||
UnityEditor.EditorUtility.SetDirty(this);
|
||||
if (!Application.isPlaying && gameObject && gameObject.scene.IsValid())
|
||||
{
|
||||
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(gameObject.scene);
|
||||
}
|
||||
}
|
||||
;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual void UpgradeIfNeeded()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the material.
|
||||
/// </summary>
|
||||
@@ -71,8 +124,13 @@ namespace Coffee.UIExtensions
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
if (ptex != null)
|
||||
{
|
||||
ptex.Register(this);
|
||||
}
|
||||
ModifyMaterial();
|
||||
base.OnEnable();
|
||||
targetGraphic.SetVerticesDirty();
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -81,18 +139,24 @@ namespace Coffee.UIExtensions
|
||||
protected override void OnDisable()
|
||||
{
|
||||
ModifyMaterial();
|
||||
base.OnDisable();
|
||||
targetGraphic.SetVerticesDirty();
|
||||
if (ptex != null)
|
||||
{
|
||||
ptex.Unregister(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mark the UIEffect as dirty.
|
||||
/// </summary>
|
||||
protected void SetDirty()
|
||||
protected virtual void SetDirty()
|
||||
{
|
||||
if (targetGraphic)
|
||||
{
|
||||
targetGraphic.SetVerticesDirty();
|
||||
}
|
||||
targetGraphic.SetVerticesDirty();
|
||||
}
|
||||
|
||||
protected override void OnDidApplyAnimationProperties()
|
||||
{
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// Remove deprecated files in old .unitypackage, after compiling.
|
||||
/// </summary>
|
||||
public class DeprecatedRemover
|
||||
{
|
||||
/// <summary>
|
||||
/// GUIDs of deprecated files.
|
||||
/// </summary>
|
||||
static readonly List<string> DeprecatedFiles = new List<string>()
|
||||
{
|
||||
"156b57fee6ef941958e66a129ce387e2", // UICustomEffect.cs
|
||||
"a4961e148a8cd4fe0b84dddc2741894a", // UICustomEffectEditor.cs
|
||||
"7b1ed09bdf5e54042b5cd1fbe69361bf", // MaterialBundle.cs
|
||||
};
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.InitializeOnLoadMethod]
|
||||
static void RemoveFiles()
|
||||
{
|
||||
// The deprecated file path that exists.
|
||||
var files = DeprecatedFiles.Select(x => AssetDatabase.GUIDToAssetPath(x))
|
||||
.Where(x => File.Exists(x))
|
||||
.ToArray();
|
||||
|
||||
if (files.Any())
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendFormat("<b><color=orange>[{0}]</color></b> {1} files have been removed.\n", typeof(DeprecatedRemover).Name, files.Length);
|
||||
|
||||
foreach (var path in files)
|
||||
{
|
||||
AssetDatabase.DeleteAsset(path);
|
||||
sb.AppendFormat(" - {0}\n", path);
|
||||
}
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
UnityEngine.Debug.Log(sb);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b1ed09bdf5e54042b5cd1fbe69361bf
|
||||
timeCreated: 1527748594
|
||||
guid: 6955fce24c79542af9ba39b3cf6f610f
|
||||
timeCreated: 1536108312
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
@@ -1,81 +0,0 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UICustomEffect))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UICustomEffectEditor : Editor
|
||||
{
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
SerializedProperty spCustomFactor1X;
|
||||
SerializedProperty spCustomFactor1Y;
|
||||
SerializedProperty spCustomFactor1Z;
|
||||
SerializedProperty spCustomFactor1W;
|
||||
SerializedProperty spCustomFactor2X;
|
||||
SerializedProperty spCustomFactor2Y;
|
||||
SerializedProperty spCustomFactor2Z;
|
||||
SerializedProperty spCustomFactor2W;
|
||||
SerializedProperty _spEffectMaterial;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
var spCustomFactor1 = serializedObject.FindProperty("m_CustomFactor1");
|
||||
spCustomFactor1X = spCustomFactor1.FindPropertyRelative("x");
|
||||
spCustomFactor1Y = spCustomFactor1.FindPropertyRelative("y");
|
||||
spCustomFactor1Z = spCustomFactor1.FindPropertyRelative("z");
|
||||
spCustomFactor1W = spCustomFactor1.FindPropertyRelative("w");
|
||||
|
||||
var spCustomFactor2 = serializedObject.FindProperty("m_CustomFactor2");
|
||||
spCustomFactor2X = spCustomFactor2.FindPropertyRelative("x");
|
||||
spCustomFactor2Y = spCustomFactor2.FindPropertyRelative("y");
|
||||
spCustomFactor2Z = spCustomFactor2.FindPropertyRelative("z");
|
||||
spCustomFactor2W = spCustomFactor2.FindPropertyRelative("w");
|
||||
|
||||
_spEffectMaterial = serializedObject.FindProperty("m_EffectMaterial");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(_spEffectMaterial);
|
||||
|
||||
EditorGUILayout.Slider(spCustomFactor1X, 0, 1, "CustomFactor1.X");
|
||||
EditorGUILayout.Slider(spCustomFactor1Y, 0, 1, "CustomFactor1.Y");
|
||||
EditorGUILayout.Slider(spCustomFactor1Z, 0, 1, "CustomFactor1.Z");
|
||||
EditorGUILayout.Slider(spCustomFactor1W, 0, 1, "CustomFactor1.W");
|
||||
EditorGUILayout.Slider(spCustomFactor2X, 0, 1, "CustomFactor2.X");
|
||||
EditorGUILayout.Slider(spCustomFactor2Y, 0, 1, "CustomFactor2.Y");
|
||||
EditorGUILayout.Slider(spCustomFactor2Z, 0, 1, "CustomFactor2.Z");
|
||||
EditorGUILayout.Slider(spCustomFactor2W, 0, 1, "CustomFactor2.W");
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
var graphic = (target as UIEffectBase).targetGraphic;
|
||||
if(graphic)
|
||||
{
|
||||
var canvas = graphic.canvas;
|
||||
if( canvas && 0 == (canvas.additionalShaderChannels & AdditionalCanvasShaderChannels.TexCoord1))
|
||||
{
|
||||
using (new GUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.HelpBox("[Unity5.6+] Enable TexCoord1 of Canvas.additionalShaderChannels to use UICustomEffect.", MessageType.Warning);
|
||||
if (GUILayout.Button("Fix"))
|
||||
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace Coffee.UIExtensions.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIDissolve))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIDissolveEditor : Editor
|
||||
{
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected void OnEnable()
|
||||
{
|
||||
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
|
||||
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
|
||||
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
|
||||
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
|
||||
_spWidth = serializedObject.FindProperty("m_Width");
|
||||
_spColor = serializedObject.FindProperty("m_Color");
|
||||
_spSoftness = serializedObject.FindProperty("m_Softness");
|
||||
_spColorMode = serializedObject.FindProperty("m_ColorMode");
|
||||
_spNoiseTexture = serializedObject.FindProperty("m_NoiseTexture");
|
||||
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
|
||||
var player = serializedObject.FindProperty("m_Player");
|
||||
_spDuration = player.FindPropertyRelative("duration");
|
||||
_spUpdateMode = player.FindPropertyRelative("updateMode");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
//================
|
||||
// Effect material.
|
||||
//================
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.PropertyField(_spMaterial);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
//================
|
||||
// Effect setting.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spEffectFactor);
|
||||
EditorGUILayout.PropertyField(_spWidth);
|
||||
EditorGUILayout.PropertyField(_spSoftness);
|
||||
EditorGUILayout.PropertyField(_spColor);
|
||||
EditorGUILayout.PropertyField(_spColorMode);
|
||||
EditorGUILayout.PropertyField(_spNoiseTexture);
|
||||
|
||||
//================
|
||||
// Advanced option.
|
||||
//================
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Advanced Option", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.PropertyField(_spEffectArea);
|
||||
EditorGUILayout.PropertyField(_spKeepAspectRatio);
|
||||
|
||||
//================
|
||||
// Effect runner.
|
||||
//================
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Effect Player", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_spDuration);
|
||||
EditorGUILayout.PropertyField(_spUpdateMode);
|
||||
|
||||
// Debug.
|
||||
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
|
||||
{
|
||||
GUILayout.Label("Debug");
|
||||
|
||||
if (GUILayout.Button("Play", "ButtonLeft"))
|
||||
{
|
||||
(target as UIDissolve).Play();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Stop", "ButtonRight"))
|
||||
{
|
||||
(target as UIDissolve).Stop();
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
SerializedProperty _spMaterial;
|
||||
SerializedProperty _spEffectFactor;
|
||||
SerializedProperty _spWidth;
|
||||
SerializedProperty _spColor;
|
||||
SerializedProperty _spSoftness;
|
||||
SerializedProperty _spColorMode;
|
||||
SerializedProperty _spNoiseTexture;
|
||||
SerializedProperty _spEffectArea;
|
||||
SerializedProperty _spKeepAspectRatio;
|
||||
SerializedProperty _spDuration;
|
||||
SerializedProperty _spUpdateMode;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 156b57fee6ef941958e66a129ce387e2
|
||||
timeCreated: 1485321967
|
||||
guid: f7f7349a5d61649b69946853317db047
|
||||
timeCreated: 1538806040
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
@@ -3,7 +3,7 @@ using UnityEditor.UI;
|
||||
using UnityEngine;
|
||||
using DesamplingRate = Coffee.UIExtensions.UIEffectCapturedImage.DesamplingRate;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
namespace Coffee.UIExtensions.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffectCapturedImage editor.
|
||||
@@ -42,12 +42,12 @@ namespace Coffee.UIExtensions
|
||||
_spFilterMode = serializedObject.FindProperty("m_FilterMode");
|
||||
_spIterations = serializedObject.FindProperty("m_BlurIterations");
|
||||
_spKeepSizeToRootCanvas = serializedObject.FindProperty("m_FitToScreen");
|
||||
_spTargetTexture = serializedObject.FindProperty("m_TargetTexture");
|
||||
_spBlurMode = serializedObject.FindProperty("m_BlurMode");
|
||||
_spCaptureOnEnable = serializedObject.FindProperty("m_CaptureOnEnable");
|
||||
_spImmediateCapturing = serializedObject.FindProperty("m_ImmediateCapturing");
|
||||
|
||||
|
||||
_customAdvancedOption = (qualityMode == QualityMode.Custom) || _spTargetTexture.objectReferenceValue;
|
||||
_customAdvancedOption = (qualityMode == QualityMode.Custom);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -70,7 +70,7 @@ namespace Coffee.UIExtensions
|
||||
//================
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Capture Effect", EditorStyles.boldLabel);
|
||||
UIEffectEditor.DrawEffectProperties(UIEffectCapturedImage.shaderName, serializedObject);
|
||||
UIEffectEditor.DrawEffectProperties(serializedObject);
|
||||
|
||||
//================
|
||||
// Advanced option.
|
||||
@@ -80,20 +80,21 @@ namespace Coffee.UIExtensions
|
||||
|
||||
EditorGUILayout.PropertyField(_spCaptureOnEnable);// CaptureOnEnable.
|
||||
EditorGUILayout.PropertyField(_spKeepSizeToRootCanvas);// Keep Graphic Size To RootCanvas.
|
||||
EditorGUILayout.PropertyField(_spImmediateCapturing);// Capture immediately.
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
QualityMode quality = qualityMode;
|
||||
quality = (QualityMode)EditorGUILayout.EnumPopup("Quality Mode", quality);
|
||||
if(EditorGUI.EndChangeCheck())
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
_customAdvancedOption = (quality == QualityMode.Custom) || _spTargetTexture.objectReferenceValue;
|
||||
_customAdvancedOption = (quality == QualityMode.Custom);
|
||||
qualityMode = quality;
|
||||
}
|
||||
|
||||
// When qualityMode is `Custom`, show advanced option.
|
||||
if (_customAdvancedOption)
|
||||
{
|
||||
if(_spBlurMode.intValue != 0)
|
||||
if (_spBlurMode.intValue != 0)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_spIterations);// Iterations.
|
||||
}
|
||||
@@ -102,20 +103,8 @@ namespace Coffee.UIExtensions
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Result Texture Setting", EditorStyles.boldLabel);
|
||||
|
||||
if(!_spTargetTexture.objectReferenceValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_spFilterMode);// Filter Mode.
|
||||
DrawDesamplingRate(_spDesamplingRate);// Desampling rate.
|
||||
}
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.PropertyField(_spTargetTexture);// Target Texture.
|
||||
Texture t = _spTargetTexture.objectReferenceValue as Texture;
|
||||
if (t)
|
||||
{
|
||||
GUILayout.Label(string.Format("{0}x{1}", t.width, t.height), EditorStyles.miniLabel);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.PropertyField(_spFilterMode);// Filter Mode.
|
||||
DrawDesamplingRate(_spDesamplingRate);// Desampling rate.
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
@@ -138,23 +127,6 @@ namespace Coffee.UIExtensions
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Warning message for overlay rendering.
|
||||
if(graphic && graphic.canvas)
|
||||
{
|
||||
var canvas = graphic.canvas.rootCanvas;
|
||||
if( canvas && canvas.renderMode == RenderMode.WorldSpace)
|
||||
{
|
||||
using (new GUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.HelpBox("'WorldSpace - Camera' render modes is not supported. Change render mode of root canvas.", MessageType.Warning);
|
||||
if (GUILayout.Button("Canvas"))
|
||||
{
|
||||
Selection.activeGameObject = canvas.gameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//################################
|
||||
@@ -172,8 +144,8 @@ namespace Coffee.UIExtensions
|
||||
SerializedProperty _spBlurMode;
|
||||
SerializedProperty _spIterations;
|
||||
SerializedProperty _spKeepSizeToRootCanvas;
|
||||
SerializedProperty _spTargetTexture;
|
||||
SerializedProperty _spCaptureOnEnable;
|
||||
SerializedProperty _spImmediateCapturing;
|
||||
|
||||
QualityMode qualityMode
|
||||
{
|
||||
@@ -183,9 +155,9 @@ namespace Coffee.UIExtensions
|
||||
return QualityMode.Custom;
|
||||
|
||||
int qualityValue = (_spDesamplingRate.intValue << 0)
|
||||
+ (_spReductionRate.intValue << 4)
|
||||
+ (_spFilterMode.intValue << 8)
|
||||
+ (_spIterations.intValue << 10);
|
||||
+ (_spReductionRate.intValue << 4)
|
||||
+ (_spFilterMode.intValue << 8)
|
||||
+ (_spIterations.intValue << 10);
|
||||
|
||||
return System.Enum.IsDefined(typeof(QualityMode), qualityValue) ? (QualityMode)qualityValue : QualityMode.Custom;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
namespace Coffee.UIExtensions.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
@@ -11,16 +12,16 @@ namespace Coffee.UIExtensions
|
||||
[CanEditMultipleObjects]
|
||||
public class UIEffectEditor : Editor
|
||||
{
|
||||
static readonly GUIContent contentEffectColor = new GUIContent ("Effect Color");
|
||||
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// Draw effect properties.
|
||||
/// </summary>
|
||||
public static void DrawEffectProperties(string shaderName, SerializedObject serializedObject)
|
||||
public static void DrawEffectProperties(SerializedObject serializedObject)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
//================
|
||||
// Effect material.
|
||||
//================
|
||||
@@ -30,18 +31,16 @@ namespace Coffee.UIExtensions
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
//================
|
||||
// Tone setting.
|
||||
// Effect setting.
|
||||
//================
|
||||
var spToneMode = serializedObject.FindProperty("m_ToneMode");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var spToneMode = serializedObject.FindProperty("m_EffectMode");
|
||||
EditorGUILayout.PropertyField(spToneMode);
|
||||
changed |= EditorGUI.EndChangeCheck();
|
||||
|
||||
// When tone is enable, show parameters.
|
||||
if (spToneMode.intValue != (int)ToneMode.None)
|
||||
if (spToneMode.intValue != (int)EffectMode.None)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ToneLevel"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectFactor"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
@@ -49,15 +48,30 @@ namespace Coffee.UIExtensions
|
||||
// Color setting.
|
||||
//================
|
||||
var spColorMode = serializedObject.FindProperty("m_ColorMode");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(spColorMode);
|
||||
changed |= EditorGUI.EndChangeCheck();
|
||||
|
||||
// When color is enable, show parameters.
|
||||
if (spColorMode.intValue != (int)ColorMode.Multiply)
|
||||
//if (spColorMode.intValue != (int)ColorMode.Multiply)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectColor"));
|
||||
|
||||
SerializedProperty spColor = serializedObject.FindProperty("m_Color");
|
||||
if (spColor == null && serializedObject.targetObject is UIEffect) {
|
||||
spColor = new SerializedObject (serializedObject.targetObjects.Select(x=>(x as UIEffect).targetGraphic).ToArray()).FindProperty("m_Color");
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
EditorGUI.showMixedValue = spColor.hasMultipleDifferentValues;
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false);
|
||||
#else
|
||||
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false, null);
|
||||
#endif
|
||||
if (EditorGUI.EndChangeCheck ()) {
|
||||
spColor.serializedObject.ApplyModifiedProperties ();
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorFactor"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
@@ -65,116 +79,26 @@ namespace Coffee.UIExtensions
|
||||
// Blur setting.
|
||||
//================
|
||||
var spBlurMode = serializedObject.FindProperty("m_BlurMode");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(spBlurMode);
|
||||
changed |= EditorGUI.EndChangeCheck();
|
||||
|
||||
// When blur is enable, show parameters.
|
||||
if (spBlurMode.intValue != (int)BlurMode.None)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Blur"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor"));
|
||||
|
||||
var spAdvancedBlur = serializedObject.FindProperty("m_AdvancedBlur");
|
||||
if (spAdvancedBlur != null)
|
||||
{
|
||||
EditorGUILayout.PropertyField(spAdvancedBlur);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// // Set effect material.
|
||||
// if (!serializedObject.isEditingMultipleObjects && spToneMode.intValue == 0 && spColorMode.intValue == 0 && spBlurMode.intValue == 0)
|
||||
// {
|
||||
// spMaterial.objectReferenceValue = null;
|
||||
// }
|
||||
// else if (changed || !serializedObject.isEditingMultipleObjects)
|
||||
// {
|
||||
// spMaterial.objectReferenceValue = UIEffect.GetOrGenerateMaterialVariant(Shader.Find(shaderName),
|
||||
// (UIEffect.ToneMode)spToneMode.intValue,
|
||||
// (UIEffect.ColorMode)spColorMode.intValue,
|
||||
// (UIEffect.BlurMode)spBlurMode.intValue
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
ReorderableList _roAdditionalShadows;
|
||||
SerializedProperty _spAdditionalShadows;
|
||||
SerializedProperty _spBlurMode;
|
||||
SerializedProperty _spCustomEffect;
|
||||
SerializedProperty _spEffectMaterial;
|
||||
SerializedProperty _spEffectColor;
|
||||
SerializedProperty _spCustomFactorX;
|
||||
SerializedProperty _spCustomFactorY;
|
||||
SerializedProperty _spCustomFactorZ;
|
||||
SerializedProperty _spCustomFactorW;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_spAdditionalShadows = serializedObject.FindProperty("m_AdditionalShadows");
|
||||
_spBlurMode = serializedObject.FindProperty("m_BlurMode");
|
||||
_spEffectColor = serializedObject.FindProperty("m_EffectColor");
|
||||
|
||||
_spCustomEffect = serializedObject.FindProperty("m_CustomEffect");
|
||||
_spEffectMaterial = serializedObject.FindProperty("m_EffectMaterial");
|
||||
var spFactor = serializedObject.FindProperty("m_CustomFactor");
|
||||
_spCustomFactorX = spFactor.FindPropertyRelative("x");
|
||||
_spCustomFactorY = spFactor.FindPropertyRelative("y");
|
||||
_spCustomFactorZ = spFactor.FindPropertyRelative("z");
|
||||
_spCustomFactorW = spFactor.FindPropertyRelative("w");
|
||||
|
||||
_roAdditionalShadows = new ReorderableList(serializedObject, _spAdditionalShadows, true, true, true, true);
|
||||
_roAdditionalShadows.drawElementCallback = DrawElementCallback;
|
||||
_roAdditionalShadows.drawHeaderCallback = (rect) => EditorGUI.LabelField(rect, "Additional Shadows");
|
||||
_roAdditionalShadows.onAddCallback = OnAddCallback;
|
||||
_roAdditionalShadows.elementHeightCallback = ElementHeightCallback;
|
||||
|
||||
}
|
||||
|
||||
void OnAddCallback(ReorderableList ro)
|
||||
{
|
||||
_spAdditionalShadows.InsertArrayElementAtIndex(ro.count);
|
||||
var element = _spAdditionalShadows.GetArrayElementAtIndex(ro.count - 1);
|
||||
element.FindPropertyRelative("shadowMode").intValue = (int)ShadowStyle.Shadow;
|
||||
element.FindPropertyRelative("shadowColor").colorValue = Color.black;
|
||||
element.FindPropertyRelative("effectDistance").vector2Value = new Vector2(1f, -1f);
|
||||
element.FindPropertyRelative("useGraphicAlpha").boolValue = true;
|
||||
element.FindPropertyRelative("shadowBlur").floatValue = 0.25f;
|
||||
}
|
||||
|
||||
float ElementHeightCallback(int index)
|
||||
{
|
||||
var element = _spAdditionalShadows.GetArrayElementAtIndex(index);
|
||||
if (element.FindPropertyRelative("shadowMode").intValue == (int)ShadowStyle.None)
|
||||
return 16;
|
||||
|
||||
return (_spBlurMode.intValue == (int)BlurMode.None ? 66 : 84) + (EditorGUIUtility.wideMode ? 0 : 18);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
var sp = _roAdditionalShadows.serializedProperty.GetArrayElementAtIndex(index);
|
||||
|
||||
Rect r = new Rect(rect);
|
||||
r.height = EditorGUIUtility.singleLineHeight;
|
||||
var spMode = sp.FindPropertyRelative("shadowMode");
|
||||
EditorGUI.PropertyField(r, spMode);
|
||||
if (spMode.intValue == (int)ShadowStyle.None)
|
||||
return;
|
||||
|
||||
r.y += r.height;
|
||||
EditorGUI.PropertyField(r, sp.FindPropertyRelative("shadowColor"));
|
||||
r.y += r.height;
|
||||
EditorGUI.PropertyField(r, sp.FindPropertyRelative("effectDistance"));
|
||||
r.y += EditorGUIUtility.wideMode ? r.height : r.height * 2;
|
||||
EditorGUI.PropertyField(r, sp.FindPropertyRelative("useGraphicAlpha"));
|
||||
|
||||
if (_spBlurMode.intValue != (int)BlurMode.None)
|
||||
{
|
||||
r.y += r.height;
|
||||
EditorGUI.PropertyField(r, sp.FindPropertyRelative("shadowBlur"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
@@ -183,50 +107,7 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
// Custom effect.
|
||||
EditorGUILayout.PropertyField(_spCustomEffect);
|
||||
if(_spCustomEffect.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_spEffectMaterial);
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.Slider(_spCustomFactorX, 0, 1, new GUIContent("Effect Factor X"));
|
||||
EditorGUILayout.Slider(_spCustomFactorY, 0, 1, new GUIContent("Effect Factor Y"));
|
||||
EditorGUILayout.Slider(_spCustomFactorZ, 0, 1, new GUIContent("Effect Factor Z"));
|
||||
EditorGUILayout.Slider(_spCustomFactorW, 0, 1, new GUIContent("Effect Factor W"));
|
||||
EditorGUILayout.PropertyField(_spEffectColor);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawEffectProperties(UIEffect.shaderName, serializedObject);
|
||||
}
|
||||
|
||||
//================
|
||||
// Shadow setting.
|
||||
//================
|
||||
var spShadowMode = serializedObject.FindProperty("m_ShadowStyle");
|
||||
EditorGUILayout.PropertyField(spShadowMode);
|
||||
|
||||
// When shadow is enable, show parameters.
|
||||
if (spShadowMode.intValue != (int)ShadowStyle.None)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectDistance"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ShadowColor"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_UseGraphicAlpha"));
|
||||
|
||||
if (_spBlurMode.intValue != (int)BlurMode.None)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ShadowBlur"));
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//================
|
||||
// Additional shadow setting.
|
||||
//================
|
||||
_roAdditionalShadows.DoLayoutList();
|
||||
DrawEffectProperties(serializedObject);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
namespace Coffee.UIExtensions.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
@@ -87,7 +87,7 @@ namespace Coffee.UIExtensions
|
||||
EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
{
|
||||
if ((target as UIGradient).graphic is Text)
|
||||
if ((target as UIGradient).targetGraphic is Text)
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_GradientStyle"));
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorSpace"));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
namespace Coffee.UIExtensions.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIShadow editor.
|
||||
@@ -11,77 +11,20 @@ namespace Coffee.UIExtensions
|
||||
[CanEditMultipleObjects]
|
||||
public class UIShadowEditor : Editor
|
||||
{
|
||||
ReorderableList roAdditionalShadows;
|
||||
SerializedProperty spAdditionalShadows;
|
||||
UIEffect uiEffect;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
uiEffect = (target as UIShadow).GetComponent<UIEffect>();
|
||||
spAdditionalShadows = serializedObject.FindProperty("m_AdditionalShadows");
|
||||
|
||||
roAdditionalShadows = new ReorderableList(serializedObject, spAdditionalShadows, true, true, true, true);
|
||||
roAdditionalShadows.drawElementCallback = DrawElementCallback;
|
||||
roAdditionalShadows.drawHeaderCallback = (rect) => EditorGUI.LabelField(rect, "Additional Shadows");
|
||||
roAdditionalShadows.onAddCallback = OnAddCallback;
|
||||
roAdditionalShadows.elementHeightCallback = ElementHeightCallback;
|
||||
|
||||
}
|
||||
|
||||
void OnAddCallback(ReorderableList ro)
|
||||
{
|
||||
spAdditionalShadows.InsertArrayElementAtIndex(ro.count);
|
||||
var element = spAdditionalShadows.GetArrayElementAtIndex(ro.count - 1);
|
||||
element.FindPropertyRelative("style").intValue = (int)ShadowStyle.Shadow;
|
||||
element.FindPropertyRelative("effectColor").colorValue = Color.black;
|
||||
element.FindPropertyRelative("effectDistance").vector2Value = new Vector2(1f, -1f);
|
||||
element.FindPropertyRelative("useGraphicAlpha").boolValue = true;
|
||||
element.FindPropertyRelative("blur").floatValue = 0.25f;
|
||||
}
|
||||
|
||||
float ElementHeightCallback(int index)
|
||||
{
|
||||
var element = spAdditionalShadows.GetArrayElementAtIndex(index);
|
||||
if (element.FindPropertyRelative("style").intValue == (int)ShadowStyle.None)
|
||||
return 16;
|
||||
|
||||
return (uiEffect && uiEffect.blurMode != BlurMode.None ? 84 : 64) + (EditorGUIUtility.wideMode ? 0 : 18);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
var sp = roAdditionalShadows.serializedProperty.GetArrayElementAtIndex(index);
|
||||
|
||||
Rect r = new Rect(rect);
|
||||
r.height = EditorGUIUtility.singleLineHeight;
|
||||
var spMode = sp.FindPropertyRelative("style");
|
||||
EditorGUI.PropertyField(r, spMode);
|
||||
if (spMode.intValue == (int)ShadowStyle.None)
|
||||
return;
|
||||
|
||||
r.y += r.height;
|
||||
EditorGUI.PropertyField(r, sp.FindPropertyRelative("effectColor"));
|
||||
r.y += r.height;
|
||||
EditorGUI.PropertyField(r, sp.FindPropertyRelative("effectDistance"));
|
||||
r.y += EditorGUIUtility.wideMode ? r.height : r.height * 2;
|
||||
EditorGUI.PropertyField(r, sp.FindPropertyRelative("useGraphicAlpha"));
|
||||
|
||||
if (uiEffect && uiEffect.blurMode != BlurMode.None)
|
||||
{
|
||||
r.y += r.height;
|
||||
EditorGUI.PropertyField(r, sp.FindPropertyRelative("blur"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
//================
|
||||
@@ -100,16 +43,11 @@ namespace Coffee.UIExtensions
|
||||
|
||||
if (uiEffect && uiEffect.blurMode != BlurMode.None)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Blur"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor"));
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//================
|
||||
// Additional shadow setting.
|
||||
//================
|
||||
roAdditionalShadows.DoLayoutList();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace Coffee.UIExtensions.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIShiny))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIShinyEditor : Editor
|
||||
{
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected void OnEnable()
|
||||
{
|
||||
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
|
||||
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
|
||||
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
|
||||
_spWidth = serializedObject.FindProperty("m_Width");
|
||||
_spRotation = serializedObject.FindProperty("m_Rotation");
|
||||
_spSoftness = serializedObject.FindProperty("m_Softness");
|
||||
_spBrightness = serializedObject.FindProperty("m_Brightness");
|
||||
_spGloss = serializedObject.FindProperty("m_Gloss");
|
||||
var player = serializedObject.FindProperty("m_Player");
|
||||
_spPlay = player.FindPropertyRelative("play");
|
||||
_spDuration = player.FindPropertyRelative("duration");
|
||||
_spLoop = player.FindPropertyRelative("loop");
|
||||
_spLoopDelay = player.FindPropertyRelative("loopDelay");
|
||||
_spUpdateMode = player.FindPropertyRelative("updateMode");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
//================
|
||||
// Effect material.
|
||||
//================
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.PropertyField(_spMaterial);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
//================
|
||||
// Effect setting.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spEffectFactor);
|
||||
EditorGUILayout.PropertyField(_spWidth);
|
||||
EditorGUILayout.PropertyField(_spRotation);
|
||||
EditorGUILayout.PropertyField(_spSoftness);
|
||||
EditorGUILayout.PropertyField(_spBrightness);
|
||||
EditorGUILayout.PropertyField(_spGloss);
|
||||
|
||||
//================
|
||||
// Advanced option.
|
||||
//================
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Advanced Option", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.PropertyField(_spEffectArea);
|
||||
|
||||
//================
|
||||
// Effect runner.
|
||||
//================
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Effect Player", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_spPlay);
|
||||
EditorGUILayout.PropertyField(_spDuration);
|
||||
EditorGUILayout.PropertyField(_spLoop);
|
||||
EditorGUILayout.PropertyField(_spLoopDelay);
|
||||
EditorGUILayout.PropertyField(_spUpdateMode);
|
||||
|
||||
// Debug.
|
||||
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
|
||||
{
|
||||
GUILayout.Label("Debug");
|
||||
|
||||
if (GUILayout.Button("Play", "ButtonLeft"))
|
||||
{
|
||||
(target as UIShiny).Play();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Stop", "ButtonRight"))
|
||||
{
|
||||
(target as UIShiny).Stop();
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
SerializedProperty _spMaterial;
|
||||
SerializedProperty _spEffectFactor;
|
||||
SerializedProperty _spWidth;
|
||||
SerializedProperty _spRotation;
|
||||
SerializedProperty _spSoftness;
|
||||
SerializedProperty _spBrightness;
|
||||
SerializedProperty _spGloss;
|
||||
SerializedProperty _spEffectArea;
|
||||
SerializedProperty _spPlay;
|
||||
SerializedProperty _spLoop;
|
||||
SerializedProperty _spLoopDelay;
|
||||
SerializedProperty _spDuration;
|
||||
SerializedProperty _spUpdateMode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0080e984bad7545cd957d9121e99f988
|
||||
timeCreated: 1538806052
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,121 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace Coffee.UIExtensions.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UITransitionEffect))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UITransitionEffectEditor : Editor
|
||||
{
|
||||
SerializedProperty _spMaterial;
|
||||
SerializedProperty _spEffectMode;
|
||||
SerializedProperty _spEffectFactor;
|
||||
SerializedProperty _spEffectArea;
|
||||
SerializedProperty _spKeepAspectRatio;
|
||||
SerializedProperty _spDissolveWidth;
|
||||
SerializedProperty _spDissolveSoftness;
|
||||
SerializedProperty _spDissolveColor;
|
||||
SerializedProperty _spTransitionTexture;
|
||||
SerializedProperty _spDuration;
|
||||
SerializedProperty _spUpdateMode;
|
||||
SerializedProperty _spPassRayOnHidden;
|
||||
|
||||
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected void OnEnable()
|
||||
{
|
||||
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
|
||||
_spEffectMode = serializedObject.FindProperty("m_EffectMode");
|
||||
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
|
||||
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
|
||||
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
|
||||
_spDissolveWidth = serializedObject.FindProperty("m_DissolveWidth");
|
||||
_spDissolveSoftness = serializedObject.FindProperty("m_DissolveSoftness");
|
||||
_spDissolveColor = serializedObject.FindProperty("m_DissolveColor");
|
||||
_spTransitionTexture = serializedObject.FindProperty("m_TransitionTexture");
|
||||
var player = serializedObject.FindProperty("m_Player");
|
||||
_spDuration = player.FindPropertyRelative("duration");
|
||||
_spUpdateMode = player.FindPropertyRelative("updateMode");
|
||||
_spPassRayOnHidden = serializedObject.FindProperty("m_PassRayOnHidden");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
//================
|
||||
// Effect material.
|
||||
//================
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.PropertyField(_spMaterial);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
//================
|
||||
// Effect setting.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spEffectMode);
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_spEffectFactor);
|
||||
if (_spEffectMode.intValue == (int)UITransitionEffect.EffectMode.Dissolve)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_spDissolveWidth);
|
||||
EditorGUILayout.PropertyField(_spDissolveSoftness);
|
||||
EditorGUILayout.PropertyField(_spDissolveColor);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
//================
|
||||
// Advanced option.
|
||||
//================
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Advanced Option", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.PropertyField(_spEffectArea);
|
||||
EditorGUILayout.PropertyField(_spTransitionTexture);
|
||||
EditorGUILayout.PropertyField(_spKeepAspectRatio);
|
||||
EditorGUILayout.PropertyField(_spPassRayOnHidden);
|
||||
|
||||
//================
|
||||
// Effect runner.
|
||||
//================
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Effect Player", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_spDuration);
|
||||
EditorGUILayout.PropertyField(_spUpdateMode);
|
||||
|
||||
// Debug.
|
||||
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
|
||||
{
|
||||
GUILayout.Label("Debug");
|
||||
|
||||
if (GUILayout.Button("Show", "ButtonLeft"))
|
||||
{
|
||||
(target as UITransitionEffect).Show();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Hide", "ButtonRight"))
|
||||
{
|
||||
(target as UITransitionEffect).Hide();
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 631f363a54c834f1f846f823b31bd321
|
||||
timeCreated: 1538806067
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,80 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect.
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Graphic))]
|
||||
[DisallowMultipleComponent]
|
||||
public class UICustomEffect : UIEffectBase
|
||||
{
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
[SerializeField] Vector4 m_CustomFactor1 = new Vector4();
|
||||
[SerializeField] Vector4 m_CustomFactor2 = new Vector4();
|
||||
|
||||
//################################
|
||||
// Public Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// Custom effect factor 1.
|
||||
/// </summary>
|
||||
public Vector4 customFactor1 { get { return m_CustomFactor1; } set { m_CustomFactor1 = value; SetDirty(); } }
|
||||
|
||||
/// <summary>
|
||||
/// Custom effect factor 2.
|
||||
/// </summary>
|
||||
public Vector4 customFactor2 { get { return m_CustomFactor2; } set { m_CustomFactor2 = value; SetDirty(); } }
|
||||
|
||||
/// <summary>
|
||||
/// Modifies the mesh.
|
||||
/// </summary>
|
||||
public override void ModifyMesh(VertexHelper vh)
|
||||
{
|
||||
if (!isActiveAndEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UIVertex vt;
|
||||
vh.GetUIVertexStream(tempVerts);
|
||||
|
||||
//================================
|
||||
// Effect modify original vertices.
|
||||
//================================
|
||||
{
|
||||
// Pack some effect factors to 1 float.
|
||||
Vector2 factor = new Vector2(
|
||||
Packer.ToFloat(m_CustomFactor1),
|
||||
Packer.ToFloat(m_CustomFactor2)
|
||||
);
|
||||
|
||||
for (int i = 0; i < tempVerts.Count; i++)
|
||||
{
|
||||
vt = tempVerts[i];
|
||||
|
||||
// Set prameters to vertex.
|
||||
vt.uv1 = factor;
|
||||
tempVerts[i] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
vh.Clear();
|
||||
vh.AddUIVertexTriangleStream(tempVerts);
|
||||
|
||||
tempVerts.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,57 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Dissolve effect for uGUI.
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
[AddComponentMenu("UI/UIEffect/UIDissolve", 3)]
|
||||
public class UIDissolve : UIEffectBase
|
||||
{
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
public const string shaderName = "UI/Hidden/UI-Effect-Dissolve";
|
||||
static readonly ParameterTexture _ptex = new ParameterTexture(8, 128, "_ParamTex");
|
||||
|
||||
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
[SerializeField] [Range(0, 1)] float m_Location = 0.5f;
|
||||
[Tooltip("Current location[0-1] for dissolve effect. 0 is not dissolved, 1 is completely dissolved.")]
|
||||
[FormerlySerializedAs("m_Location")]
|
||||
[SerializeField] [Range(0, 1)] float m_EffectFactor = 0.5f;
|
||||
|
||||
[Tooltip("Edge width.")]
|
||||
[SerializeField] [Range(0, 1)] float m_Width = 0.5f;
|
||||
|
||||
[Tooltip("Edge softness.")]
|
||||
[SerializeField] [Range(0, 1)] float m_Softness = 0.5f;
|
||||
|
||||
[Tooltip("Edge color.")]
|
||||
[SerializeField] [ColorUsage(false)] Color m_Color = new Color(0.0f, 0.25f, 1.0f);
|
||||
|
||||
[Tooltip("Edge color effect mode.")]
|
||||
[SerializeField] ColorMode m_ColorMode = ColorMode.Add;
|
||||
|
||||
[Tooltip("Noise texture for dissolving (single channel texture).")]
|
||||
[SerializeField] Texture m_NoiseTexture;
|
||||
|
||||
[Tooltip("The area for effect.")]
|
||||
[SerializeField] protected EffectArea m_EffectArea;
|
||||
|
||||
[Tooltip("Keep effect aspect ratio.")]
|
||||
[SerializeField] bool m_KeepAspectRatio;
|
||||
[Header("Play Effect")]
|
||||
[SerializeField] bool m_Play = false;
|
||||
|
||||
[Header("Effect Player")]
|
||||
[SerializeField] EffectPlayer m_Player;
|
||||
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField][Range(0.1f, 10)] float m_Duration = 1;
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField] AnimatorUpdateMode m_UpdateMode = AnimatorUpdateMode.Normal;
|
||||
|
||||
|
||||
@@ -38,17 +60,35 @@ namespace Coffee.UIExtensions
|
||||
//################################
|
||||
|
||||
/// <summary>
|
||||
/// Current location[0-1] for dissolve effect. 0 is not dissolved, 1 is completely dissolved.
|
||||
/// Effect factor between 0(start) and 1(end).
|
||||
/// </summary>
|
||||
[System.Obsolete("Use effectFactor instead (UnityUpgradable) -> effectFactor")]
|
||||
public float location
|
||||
{
|
||||
get { return m_Location; }
|
||||
get { return m_EffectFactor; }
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 1);
|
||||
if (!Mathf.Approximately(m_Location, value))
|
||||
if (!Mathf.Approximately(m_EffectFactor, value))
|
||||
{
|
||||
m_Location = value;
|
||||
m_EffectFactor = value;
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effect factor between 0(start) and 1(end).
|
||||
/// </summary>
|
||||
public float effectFactor
|
||||
{
|
||||
get { return m_EffectFactor; }
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 1);
|
||||
if (!Mathf.Approximately(m_EffectFactor, value))
|
||||
{
|
||||
m_EffectFactor = value;
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
@@ -161,26 +201,44 @@ namespace Coffee.UIExtensions
|
||||
public ColorMode colorMode { get { return m_ColorMode; } }
|
||||
|
||||
/// <summary>
|
||||
/// Play dissolve on enable.
|
||||
/// Play effect on enable.
|
||||
/// </summary>
|
||||
public bool play { get { return m_Play; } set { m_Play = value; } }
|
||||
[System.Obsolete("Use Show/Hide method instead")]
|
||||
public bool play { get { return _player.play; } set { _player.play = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Dissolve duration.
|
||||
/// Play effect loop.
|
||||
/// </summary>
|
||||
public float duration { get { return m_Duration; } set { m_Duration = Mathf.Max(value, 0.1f); } }
|
||||
[System.Obsolete]
|
||||
public bool loop { get { return _player.loop; } set { _player.loop = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Dissolve update mode.
|
||||
/// The duration for playing effect.
|
||||
/// </summary>
|
||||
public AnimatorUpdateMode updateMode { get { return m_UpdateMode; } set { m_UpdateMode = value; } }
|
||||
public float duration { get { return _player.duration; } set { _player.duration = Mathf.Max(value, 0.1f); } }
|
||||
|
||||
/// <summary>
|
||||
/// Delay on loop effect.
|
||||
/// </summary>
|
||||
[System.Obsolete]
|
||||
public float loopDelay { get { return _player.loopDelay; } set { _player.loopDelay = Mathf.Max(value, 0); } }
|
||||
|
||||
/// <summary>
|
||||
/// Update mode for playing effect.
|
||||
/// </summary>
|
||||
public AnimatorUpdateMode updateMode { get { return _player.updateMode; } set { _player.updateMode = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameter texture.
|
||||
/// </summary>
|
||||
public override ParameterTexture ptex { get { return _ptex; } }
|
||||
|
||||
/// <summary>
|
||||
/// Modifies the material.
|
||||
/// </summary>
|
||||
public override void ModifyMaterial()
|
||||
{
|
||||
ulong hash = (m_NoiseTexture ? (uint)m_NoiseTexture.GetInstanceID() : 0) + ((ulong)m_ColorMode << 32);
|
||||
ulong hash = (m_NoiseTexture ? (uint)m_NoiseTexture.GetInstanceID() : 0) + ((ulong)1 << 32) + ((ulong)m_ColorMode << 36);
|
||||
if (_materialCache != null && (_materialCache.hash != hash || !isActiveAndEnabled || !m_EffectMaterial))
|
||||
{
|
||||
MaterialCache.Unregister(_materialCache);
|
||||
@@ -204,6 +262,7 @@ namespace Coffee.UIExtensions
|
||||
_materialCache = MaterialCache.Register(hash, m_NoiseTexture, () =>
|
||||
{
|
||||
var mat = new Material(m_EffectMaterial);
|
||||
mat.name += "_" + m_NoiseTexture.name;
|
||||
mat.SetTexture("_NoiseTex", m_NoiseTexture);
|
||||
return mat;
|
||||
});
|
||||
@@ -219,6 +278,8 @@ namespace Coffee.UIExtensions
|
||||
if (!isActiveAndEnabled)
|
||||
return;
|
||||
|
||||
float normalizedIndex = ptex.GetNormalizedIndex(this);
|
||||
|
||||
// rect.
|
||||
var tex = noiseTexture;
|
||||
var aspectRatio = m_KeepAspectRatio && tex ? ((float)tex.width) / tex.height : -1;
|
||||
@@ -228,38 +289,57 @@ namespace Coffee.UIExtensions
|
||||
UIVertex vertex = default(UIVertex);
|
||||
bool effectEachCharacter = graphic is Text && m_EffectArea == EffectArea.Character;
|
||||
float x, y;
|
||||
for (int i = 0; i < vh.currentVertCount; i++)
|
||||
int count = vh.currentVertCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
vh.PopulateUIVertex(ref vertex, i);
|
||||
|
||||
if (effectEachCharacter)
|
||||
{
|
||||
x = splitedCharacterPosition[i%4].x;
|
||||
y = splitedCharacterPosition[i%4].y;
|
||||
x = splitedCharacterPosition[i % 4].x;
|
||||
y = splitedCharacterPosition[i % 4].y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = Mathf.Clamp01(vertex.position.x / rect.width + 0.5f);
|
||||
y = Mathf.Clamp01(vertex.position.y / rect.height + 0.5f);
|
||||
}
|
||||
vertex.uv1 = new Vector2(
|
||||
Packer.ToFloat(x, y, location, m_Width),
|
||||
Packer.ToFloat(m_Color.r, m_Color.g, m_Color.b, m_Softness)
|
||||
|
||||
vertex.uv0 = new Vector2(
|
||||
Packer.ToFloat(vertex.uv0.x, vertex.uv0.y),
|
||||
Packer.ToFloat(x, y, normalizedIndex)
|
||||
);
|
||||
|
||||
vh.SetUIVertex(vertex, i);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetDirty()
|
||||
{
|
||||
ptex.RegisterMaterial(targetGraphic.material);
|
||||
ptex.SetData(this, 0, m_EffectFactor); // param1.x : location
|
||||
ptex.SetData(this, 1, m_Width); // param1.y : width
|
||||
ptex.SetData(this, 2, m_Softness); // param1.z : softness
|
||||
ptex.SetData(this, 4, m_Color.r); // param2.x : red
|
||||
ptex.SetData(this, 5, m_Color.g); // param2.y : green
|
||||
ptex.SetData(this, 6, m_Color.b); // param2.z : blue
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Play effect.
|
||||
/// </summary>
|
||||
public void Play()
|
||||
{
|
||||
_time = 0;
|
||||
m_Play = true;
|
||||
_player.Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop effect.
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
_player.Stop();
|
||||
}
|
||||
|
||||
//################################
|
||||
// Protected Members.
|
||||
@@ -269,14 +349,15 @@ namespace Coffee.UIExtensions
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
_time = 0;
|
||||
base.OnEnable();
|
||||
_player.OnEnable(f => effectFactor = f);
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
MaterialCache.Unregister(_materialCache);
|
||||
_materialCache = null;
|
||||
_player.OnDisable();
|
||||
base.OnDisable();
|
||||
}
|
||||
|
||||
@@ -289,31 +370,28 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
return MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName), m_ColorMode);
|
||||
}
|
||||
|
||||
#pragma warning disable 0612
|
||||
protected override void UpgradeIfNeeded()
|
||||
{
|
||||
// Upgrade for v3.0.0
|
||||
if (IsShouldUpgrade(300))
|
||||
{
|
||||
_player.play = false;
|
||||
_player.duration = m_Duration;
|
||||
_player.loop = false;
|
||||
_player.loopDelay = 1;
|
||||
_player.updateMode = m_UpdateMode;
|
||||
}
|
||||
}
|
||||
#pragma warning restore 0612
|
||||
#endif
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
MaterialCache _materialCache = null;
|
||||
float _time = 0;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!m_Play || !Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_time += m_UpdateMode == AnimatorUpdateMode.UnscaledTime
|
||||
? Time.unscaledDeltaTime
|
||||
: Time.deltaTime;
|
||||
location = _time / m_Duration;
|
||||
|
||||
if (m_Duration <= _time)
|
||||
{
|
||||
m_Play = false;
|
||||
_time = 0;
|
||||
}
|
||||
}
|
||||
EffectPlayer _player{ get { return m_Player ?? (m_Player = new EffectPlayer()); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce76b7a490bd74f34a2f2752641aea24
|
||||
timeCreated: 1523859834
|
||||
timeCreated: 1538866738
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
defaultReferences:
|
||||
- m_EffectMaterial: {instanceID: 0}
|
||||
- m_PtexMaterial: {instanceID: 0}
|
||||
- m_NoiseTexture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using System.IO;
|
||||
@@ -17,188 +18,174 @@ namespace Coffee.UIExtensions
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Graphic))]
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("UI/UIEffect/UIEffect", 1)]
|
||||
public class UIEffect : UIEffectBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Additional shadow.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AdditionalShadow
|
||||
{
|
||||
/// <summary>
|
||||
/// How far is the blurring shadow from the graphic.
|
||||
/// </summary>
|
||||
[Range(0, 1)] public float shadowBlur = 0.25f;
|
||||
|
||||
/// <summary>
|
||||
/// Shadow effect mode.
|
||||
/// </summary>
|
||||
public ShadowStyle shadowMode = ShadowStyle.Shadow;
|
||||
|
||||
/// <summary>
|
||||
/// Color for the shadow effect.
|
||||
/// </summary>
|
||||
public Color shadowColor = Color.black;
|
||||
|
||||
/// <summary>
|
||||
/// How far is the shadow from the graphic.
|
||||
/// </summary>
|
||||
public Vector2 effectDistance = new Vector2(1f, -1f);
|
||||
|
||||
/// <summary>
|
||||
/// Should the shadow inherit the alpha from the graphic?
|
||||
/// </summary>
|
||||
public bool useGraphicAlpha = true;
|
||||
}
|
||||
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
public const string shaderName = "UI/Hidden/UI-Effect";
|
||||
static readonly ParameterTexture _ptex = new ParameterTexture(4, 1024, "_ParamTex");
|
||||
|
||||
// /// <summary>
|
||||
// /// Tone effect mode.
|
||||
// /// </summary>
|
||||
// public enum ToneMode
|
||||
// {
|
||||
// None = 0,
|
||||
// Grayscale,
|
||||
// Sepia,
|
||||
// Nega,
|
||||
// Pixel,
|
||||
// Mono,
|
||||
// Cutoff,
|
||||
// Hue,
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Color effect mode.
|
||||
// /// </summary>
|
||||
// public enum ColorMode
|
||||
// {
|
||||
// None = 0,
|
||||
// Set,
|
||||
// Add,
|
||||
// Sub,
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Shadow effect style.
|
||||
// /// </summary>
|
||||
// public enum ShadowStyle
|
||||
// {
|
||||
// None = 0,
|
||||
// Shadow,
|
||||
// Outline,
|
||||
// Outline8,
|
||||
// Shadow3,
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Blur effect mode.
|
||||
// /// </summary>
|
||||
// public enum BlurMode
|
||||
// {
|
||||
// None = 0,
|
||||
// Fast,
|
||||
// Medium,
|
||||
// Detail,
|
||||
// }
|
||||
//
|
||||
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
[SerializeField][Range(0, 1)] float m_ToneLevel = 1;
|
||||
[SerializeField][Range(0, 1)] float m_Blur = 0.25f;
|
||||
[SerializeField][Range(0, 1)] float m_ShadowBlur = 0.25f;
|
||||
[FormerlySerializedAs("m_ToneLevel")]
|
||||
[Tooltip("Effect factor between 0(no effect) and 1(complete effect).")]
|
||||
[SerializeField][Range(0, 1)] float m_EffectFactor = 1;
|
||||
|
||||
[Tooltip("Color effect factor between 0(no effect) and 1(complete effect).")]
|
||||
[SerializeField][Range(0, 1)] float m_ColorFactor = 1;
|
||||
|
||||
[FormerlySerializedAs("m_Blur")]
|
||||
[Tooltip("How far is the blurring from the graphic.")]
|
||||
[SerializeField][Range(0, 1)] float m_BlurFactor = 1;
|
||||
|
||||
[FormerlySerializedAs("m_ToneMode")]
|
||||
[Tooltip("Effect mode")]
|
||||
[SerializeField] EffectMode m_EffectMode = EffectMode.None;
|
||||
|
||||
[Tooltip("Color effect mode")]
|
||||
[SerializeField] ColorMode m_ColorMode = ColorMode.Multiply;
|
||||
|
||||
[Tooltip("Blur effect mode")]
|
||||
[SerializeField] BlurMode m_BlurMode = BlurMode.None;
|
||||
|
||||
[Tooltip("Advanced blurring remove common artifacts in the blur effect for uGUI.")]
|
||||
[SerializeField] bool m_AdvancedBlur = false;
|
||||
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField][Range(0, 1)] float m_ShadowBlur = 1;
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField] ShadowStyle m_ShadowStyle;
|
||||
[SerializeField] ToneMode m_ToneMode;
|
||||
[SerializeField] ColorMode m_ColorMode;
|
||||
[SerializeField] BlurMode m_BlurMode;
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField] Color m_ShadowColor = Color.black;
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField] Vector2 m_EffectDistance = new Vector2(1f, -1f);
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField] bool m_UseGraphicAlpha = true;
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField] Color m_EffectColor = Color.white;
|
||||
[SerializeField] List<AdditionalShadow> m_AdditionalShadows = new List<AdditionalShadow>();
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField] List<UIShadow.AdditionalShadow> m_AdditionalShadows = new List<UIShadow.AdditionalShadow>();
|
||||
|
||||
|
||||
[SerializeField] bool m_CustomEffect = false;
|
||||
[SerializeField] Vector4 m_CustomFactor = new Vector4();
|
||||
public enum BlurEx
|
||||
{
|
||||
None = 0,
|
||||
Ex = 1,
|
||||
}
|
||||
|
||||
//################################
|
||||
// Public Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// Graphic affected by the UIEffect.
|
||||
/// </summary>
|
||||
[System.Obsolete ("Use targetGraphic instead (UnityUpgradable) -> targetGraphic")]
|
||||
new public Graphic graphic { get { return base.graphic; } }
|
||||
|
||||
/// <summary>
|
||||
/// Tone effect level between 0(no effect) and 1(complete effect).
|
||||
/// Effect factor between 0(no effect) and 1(complete effect).
|
||||
/// </summary>
|
||||
public float toneLevel{ get { return m_ToneLevel; } set { m_ToneLevel = Mathf.Clamp(value, 0, 1); SetDirty(); } }
|
||||
[System.Obsolete("Use effectFactor instead (UnityUpgradable) -> effectFactor")]
|
||||
public float toneLevel
|
||||
{
|
||||
get { return m_EffectFactor; }
|
||||
set
|
||||
{
|
||||
m_EffectFactor = Mathf.Clamp(value, 0, 1);
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effect factor between 0(no effect) and 1(complete effect).
|
||||
/// </summary>
|
||||
public float effectFactor
|
||||
{
|
||||
get { return m_EffectFactor; }
|
||||
set
|
||||
{
|
||||
m_EffectFactor = Mathf.Clamp(value, 0, 1);
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color effect factor between 0(no effect) and 1(complete effect).
|
||||
/// </summary>
|
||||
public float colorFactor
|
||||
{
|
||||
get { return m_ColorFactor; }
|
||||
set
|
||||
{
|
||||
m_ColorFactor = Mathf.Clamp(value, 0, 1);
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// How far is the blurring from the graphic.
|
||||
/// </summary>
|
||||
public float blur { get { return m_Blur; } set { m_Blur = Mathf.Clamp(value, 0, 1); SetDirty(); } }
|
||||
[System.Obsolete("Use blurFactor instead (UnityUpgradable) -> blurFactor")]
|
||||
public float blur
|
||||
{
|
||||
get { return m_BlurFactor; }
|
||||
set
|
||||
{
|
||||
m_BlurFactor = Mathf.Clamp(value, 0, 1);
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// How far is the blurring shadow from the graphic.
|
||||
/// How far is the blurring from the graphic.
|
||||
/// </summary>
|
||||
public float shadowBlur { get { return m_ShadowBlur; } set { m_ShadowBlur = Mathf.Clamp(value, 0, 1); SetDirty(); } }
|
||||
[System.Obsolete("Use effectFactor instead (UnityUpgradable) -> effectFactor")]
|
||||
public float blurFactor
|
||||
{
|
||||
get { return m_BlurFactor; }
|
||||
set
|
||||
{
|
||||
m_BlurFactor = Mathf.Clamp(value, 0, 1);
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shadow effect mode.
|
||||
/// Effect mode(readonly).
|
||||
/// </summary>
|
||||
public ShadowStyle shadowStyle { get { return m_ShadowStyle; } set { m_ShadowStyle = value; SetDirty(); } }
|
||||
[System.Obsolete("Use effectMode instead (UnityUpgradable) -> effectMode")]
|
||||
public EffectMode toneMode { get { return m_EffectMode; } }
|
||||
|
||||
/// <summary>
|
||||
/// Tone effect mode.
|
||||
/// Effect mode(readonly).
|
||||
/// </summary>
|
||||
public ToneMode toneMode { get { return m_ToneMode; } }
|
||||
public EffectMode effectMode { get { return m_EffectMode; } }
|
||||
|
||||
/// <summary>
|
||||
/// Color effect mode.
|
||||
/// Color effect mode(readonly).
|
||||
/// </summary>
|
||||
public ColorMode colorMode { get { return m_ColorMode; } }
|
||||
|
||||
/// <summary>
|
||||
/// Blur effect mode.
|
||||
/// Blur effect mode(readonly).
|
||||
/// </summary>
|
||||
public BlurMode blurMode { get { return m_BlurMode; } }
|
||||
|
||||
/// <summary>
|
||||
/// Color for the shadow effect.
|
||||
/// </summary>
|
||||
public Color shadowColor { get { return m_ShadowColor; } set { m_ShadowColor = value; SetDirty(); } }
|
||||
|
||||
/// <summary>
|
||||
/// How far is the shadow from the graphic.
|
||||
/// </summary>
|
||||
public Vector2 effectDistance { get { return m_EffectDistance; } set { m_EffectDistance = value; SetDirty(); } }
|
||||
|
||||
/// <summary>
|
||||
/// Should the shadow inherit the alpha from the graphic?
|
||||
/// </summary>
|
||||
public bool useGraphicAlpha { get { return m_UseGraphicAlpha; } set { m_UseGraphicAlpha = value; SetDirty(); } }
|
||||
|
||||
/// <summary>
|
||||
/// Color for the color effect.
|
||||
/// </summary>
|
||||
public Color effectColor { get { return m_EffectColor; } set { m_EffectColor = value; SetDirty(); } }
|
||||
public Color effectColor
|
||||
{
|
||||
get { return graphic.color; }
|
||||
set
|
||||
{
|
||||
graphic.color = value;
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Additional Shadows.
|
||||
/// Gets the parameter texture.
|
||||
/// </summary>
|
||||
public List<AdditionalShadow> additionalShadows { get { return m_AdditionalShadows; } }
|
||||
|
||||
/// <summary>
|
||||
/// Custom effect factor.
|
||||
/// </summary>
|
||||
public Vector4 customFactor { get { return m_CustomFactor; } set { m_CustomFactor = value; SetDirty(); } }
|
||||
public override ParameterTexture ptex { get { return _ptex; } }
|
||||
|
||||
/// <summary>
|
||||
/// Modifies the mesh.
|
||||
@@ -210,268 +197,253 @@ namespace Coffee.UIExtensions
|
||||
return;
|
||||
}
|
||||
|
||||
UIVertex vt;
|
||||
vh.GetUIVertexStream(tempVerts);
|
||||
float normalizedIndex = ptex.GetNormalizedIndex(this);
|
||||
|
||||
//================================
|
||||
// Effect modify original vertices.
|
||||
//================================
|
||||
if (m_BlurMode != BlurMode.None && m_AdvancedBlur)
|
||||
{
|
||||
// Pack some effect factors to 1 float.
|
||||
Vector2 factor = new Vector2(
|
||||
m_CustomEffect ? Packer.ToFloat(m_CustomFactor) : Packer.ToFloat(toneLevel, 0, blur, 0),
|
||||
Packer.ToFloat(effectColor.r, effectColor.g, effectColor.b, effectColor.a)
|
||||
);
|
||||
vh.GetUIVertexStream(tempVerts);
|
||||
vh.Clear();
|
||||
var count = tempVerts.Count;
|
||||
|
||||
for (int i = 0; i < tempVerts.Count; i++)
|
||||
// Bundle
|
||||
int bundleSize = targetGraphic is Text ? 6 : count;
|
||||
Rect posBounds = default(Rect);
|
||||
Rect uvBounds = default(Rect);
|
||||
Vector3 size = default(Vector3);
|
||||
Vector3 tPos = default(Vector3);
|
||||
Vector3 tUV = default(Vector3);
|
||||
float expand = (float)blurMode * 6 * 2;
|
||||
|
||||
for (int i = 0; i < count; i += bundleSize)
|
||||
{
|
||||
vt = tempVerts[i];
|
||||
// min/max for bundled-quad
|
||||
GetBounds(tempVerts, i, bundleSize, ref posBounds, ref uvBounds, true);
|
||||
|
||||
// Set UIEffect prameters to vertex.
|
||||
vt.uv1 = factor;
|
||||
tempVerts[i] = vt;
|
||||
}
|
||||
}
|
||||
// Pack uv mask.
|
||||
Vector2 uvMask = new Vector2(Packer.ToFloat(uvBounds.xMin, uvBounds.yMin), Packer.ToFloat(uvBounds.xMax, uvBounds.yMax));
|
||||
|
||||
//================================
|
||||
// Append shadow vertices.
|
||||
//================================
|
||||
{
|
||||
var inputVertCount = tempVerts.Count;
|
||||
var start = 0;
|
||||
var end = inputVertCount;
|
||||
// Quad
|
||||
for (int j = 0; j < bundleSize; j += 6)
|
||||
{
|
||||
Vector3 cornerPos1 = tempVerts[i + j + 1].position;
|
||||
Vector3 cornerPos2 = tempVerts[i + j + 4].position;
|
||||
|
||||
// Additional Shadows.
|
||||
for (int i = additionalShadows.Count - 1; 0 <= i; i--)
|
||||
{
|
||||
AdditionalShadow shadow = additionalShadows[i];
|
||||
_ApplyShadow(tempVerts, ref start, ref end, shadow.shadowMode, toneLevel, shadow.shadowBlur, shadow.effectDistance, shadow.shadowColor, shadow.useGraphicAlpha);
|
||||
// Is outer quad?
|
||||
bool hasOuterEdge = (bundleSize == 6)
|
||||
|| !posBounds.Contains(cornerPos1)
|
||||
|| !posBounds.Contains(cornerPos2);
|
||||
if (hasOuterEdge)
|
||||
{
|
||||
Vector3 cornerUv1 = tempVerts[i + j + 1].uv0;
|
||||
Vector3 cornerUv2 = tempVerts[i + j + 4].uv0;
|
||||
|
||||
Vector3 centerPos = (cornerPos1 + cornerPos2) / 2;
|
||||
Vector3 centerUV = (cornerUv1 + cornerUv2) / 2;
|
||||
size = (cornerPos1 - cornerPos2);
|
||||
|
||||
size.x = 1 + expand / Mathf.Abs(size.x);
|
||||
size.y = 1 + expand / Mathf.Abs(size.y);
|
||||
size.z = 1 + expand / Mathf.Abs(size.z);
|
||||
|
||||
tPos = centerPos - Vector3.Scale(size, centerPos);
|
||||
tUV = centerUV - Vector3.Scale(size, centerUV);
|
||||
}
|
||||
|
||||
// Vertex
|
||||
for (int k = 0; k < 6; k++)
|
||||
{
|
||||
UIVertex vt = tempVerts[i + j + k];
|
||||
|
||||
Vector3 pos = vt.position;
|
||||
Vector2 uv0 = vt.uv0;
|
||||
|
||||
if (hasOuterEdge && (pos.x < posBounds.xMin || posBounds.xMax < pos.x))
|
||||
{
|
||||
pos.x = pos.x * size.x + tPos.x;
|
||||
uv0.x = uv0.x * size.x + tUV.x;
|
||||
}
|
||||
if (hasOuterEdge && (pos.y < posBounds.yMin || posBounds.yMax < pos.y))
|
||||
{
|
||||
pos.y = pos.y * size.y + tPos.y;
|
||||
uv0.y = uv0.y * size.y + tUV.y;
|
||||
}
|
||||
|
||||
vt.uv0 = new Vector2(Packer.ToFloat((uv0.x + 0.5f) / 2f, (uv0.y + 0.5f) / 2f), normalizedIndex);
|
||||
vt.position = pos;
|
||||
vt.uv1 = uvMask;
|
||||
|
||||
tempVerts[i + j + k] = vt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shadow.
|
||||
_ApplyShadow(tempVerts, ref start, ref end, shadowStyle, toneLevel, shadowBlur, effectDistance, shadowColor, useGraphicAlpha);
|
||||
vh.AddUIVertexTriangleStream(tempVerts);
|
||||
tempVerts.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = vh.currentVertCount;
|
||||
UIVertex vt = default(UIVertex);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
vh.PopulateUIVertex(ref vt, i);
|
||||
Vector2 uv0 = vt.uv0;
|
||||
vt.uv0 = new Vector2(
|
||||
Packer.ToFloat((uv0.x + 0.5f) / 2f, (uv0.y + 0.5f) / 2f),
|
||||
normalizedIndex
|
||||
);
|
||||
vh.SetUIVertex(vt, i);
|
||||
}
|
||||
}
|
||||
|
||||
vh.Clear();
|
||||
vh.AddUIVertexTriangleStream(tempVerts);
|
||||
|
||||
tempVerts.Clear();
|
||||
}
|
||||
|
||||
//#if UNITY_EDITOR
|
||||
//
|
||||
// protected override void OnValidate ()
|
||||
// {
|
||||
// base.OnValidate ();
|
||||
// EditorApplication.delayCall += () => UpdateMaterial(false);
|
||||
// }
|
||||
//
|
||||
// public override void OnAfterDeserialize()
|
||||
// {
|
||||
// if (!m_CustomEffect)
|
||||
// {
|
||||
// EditorApplication.delayCall += () => UpdateMaterial (true);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void UpdateMaterial(bool onlyEditMode)
|
||||
// {
|
||||
// if(!this || onlyEditMode && Application.isPlaying)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// var mat = (0 == toneMode) && (0 == colorMode) && (0 == blurMode)
|
||||
// ? null
|
||||
// : GetOrGenerateMaterialVariant(Shader.Find(shaderName), toneMode, colorMode, blurMode);
|
||||
//
|
||||
// if (m_EffectMaterial != mat || targetGraphic.material != mat)
|
||||
// {
|
||||
// targetGraphic.material = m_EffectMaterial = mat;
|
||||
// EditorUtility.SetDirty(this);
|
||||
// EditorUtility.SetDirty(targetGraphic);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// public static Material GetOrGenerateMaterialVariant(Shader shader, ToneMode tone, ColorMode color, BlurMode blur)
|
||||
// {
|
||||
// if (!shader)
|
||||
// return null;
|
||||
//
|
||||
// Material mat = GetMaterial(shader, tone, color, blur);
|
||||
//
|
||||
// if (!mat)
|
||||
// {
|
||||
// Debug.Log("Generate material : " + GetVariantName(shader, tone, color, blur));
|
||||
// mat = new Material(shader);
|
||||
//
|
||||
// if (0 < tone)
|
||||
// mat.EnableKeyword("" + tone.ToString().ToUpper());
|
||||
// if (0 < color)
|
||||
// mat.EnableKeyword("UI_COLOR_" + color.ToString().ToUpper());
|
||||
// if (0 < blur)
|
||||
// mat.EnableKeyword("UI_BLUR_" + blur.ToString().ToUpper());
|
||||
//
|
||||
// mat.name = GetVariantName(shader, tone, color, blur);
|
||||
// mat.hideFlags |= HideFlags.NotEditable;
|
||||
//
|
||||
//#if UIEFFECT_SEPARATE
|
||||
// bool isMainAsset = true;
|
||||
// string dir = Path.GetDirectoryName(GetDefaultMaterialPath (shader));
|
||||
// string materialPath = Path.Combine(Path.Combine(dir, "Separated"), mat.name + ".mat");
|
||||
//#else
|
||||
// bool isMainAsset = (0 == tone) && (0 == color) && (0 == blur);
|
||||
// string materialPath = GetDefaultMaterialPath (shader);
|
||||
//#endif
|
||||
// if (isMainAsset)
|
||||
// {
|
||||
// Directory.CreateDirectory(Path.GetDirectoryName(materialPath));
|
||||
// AssetDatabase.CreateAsset(mat, materialPath);
|
||||
// AssetDatabase.SaveAssets();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// mat.hideFlags |= HideFlags.HideInHierarchy;
|
||||
// AssetDatabase.AddObjectToAsset(mat, materialPath);
|
||||
// }
|
||||
// }
|
||||
// return mat;
|
||||
// }
|
||||
//
|
||||
// public static Material GetMaterial(Shader shader, ToneMode tone, ColorMode color, BlurMode blur)
|
||||
// {
|
||||
// string variantName = GetVariantName(shader, tone, color, blur);
|
||||
// return AssetDatabase.FindAssets("t:Material " + Path.GetFileName(shader.name))
|
||||
// .Select(x => AssetDatabase.GUIDToAssetPath(x))
|
||||
// .SelectMany(x => AssetDatabase.LoadAllAssetsAtPath(x))
|
||||
// .OfType<Material>()
|
||||
// .FirstOrDefault(x => x.name == variantName);
|
||||
// }
|
||||
//
|
||||
// public static string GetDefaultMaterialPath(Shader shader)
|
||||
// {
|
||||
// var name = Path.GetFileName (shader.name);
|
||||
// return AssetDatabase.FindAssets("t:Material " + name)
|
||||
// .Select(x => AssetDatabase.GUIDToAssetPath(x))
|
||||
// .FirstOrDefault(x => Path.GetFileNameWithoutExtension(x) == name)
|
||||
// ?? ("Assets/Coffee/UIExtensions/UIEffect/Materials/" + name + ".mat");
|
||||
// }
|
||||
//
|
||||
// public static string GetVariantName(Shader shader, ToneMode tone, ColorMode color, BlurMode blur)
|
||||
// {
|
||||
// return
|
||||
//#if UIEFFECT_SEPARATE
|
||||
// "[Separated] " + Path.GetFileName(shader.name)
|
||||
//#else
|
||||
// Path.GetFileName(shader.name)
|
||||
//#endif
|
||||
// + (0 < tone ? "-" + tone : "")
|
||||
// + (0 < color ? "-" + color : "")
|
||||
// + (0 < blur ? "-" + blur : "");
|
||||
// }
|
||||
//#endif
|
||||
protected override void SetDirty()
|
||||
{
|
||||
ptex.RegisterMaterial(m_EffectMaterial);
|
||||
ptex.SetData(this, 0, m_EffectFactor); // param.x : effect factor
|
||||
ptex.SetData(this, 1, m_ColorFactor); // param.y : color factor
|
||||
ptex.SetData(this, 2, m_BlurFactor); // param.z : blur factor
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// Gets the material.
|
||||
/// </summary>
|
||||
/// <returns>The material.</returns>
|
||||
protected override Material GetMaterial ()
|
||||
protected override Material GetMaterial()
|
||||
{
|
||||
return MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName), m_ToneMode, m_ColorMode, m_BlurMode);
|
||||
return MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName), m_EffectMode, m_ColorMode, m_BlurMode, m_AdvancedBlur ? BlurEx.Ex : BlurEx.None);
|
||||
}
|
||||
|
||||
#pragma warning disable 0612
|
||||
protected override void UpgradeIfNeeded()
|
||||
{
|
||||
// Upgrade for v3.0.0
|
||||
if (IsShouldUpgrade(300))
|
||||
{
|
||||
if (m_ColorMode != ColorMode.Multiply)
|
||||
{
|
||||
Color col = targetGraphic.color;
|
||||
col.r = m_EffectColor.r;
|
||||
col.g = m_EffectColor.g;
|
||||
col.b = m_EffectColor.b;
|
||||
targetGraphic.color = col;
|
||||
m_ColorFactor = m_EffectColor.a;
|
||||
}
|
||||
|
||||
if (m_ShadowStyle != ShadowStyle.None || m_AdditionalShadows.Any(x => x.style != ShadowStyle.None))
|
||||
{
|
||||
if (m_ShadowStyle != ShadowStyle.None)
|
||||
{
|
||||
var shadow = gameObject.GetComponent<UIShadow>() ?? gameObject.AddComponent<UIShadow>();
|
||||
shadow.style = m_ShadowStyle;
|
||||
shadow.effectDistance = m_EffectDistance;
|
||||
shadow.effectColor = m_ShadowColor;
|
||||
shadow.useGraphicAlpha = m_UseGraphicAlpha;
|
||||
shadow.blurFactor = m_ShadowBlur;
|
||||
}
|
||||
|
||||
foreach (var s in m_AdditionalShadows)
|
||||
{
|
||||
if (s.style == ShadowStyle.None)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var shadow = gameObject.AddComponent<UIShadow>();
|
||||
shadow.style = s.style;
|
||||
shadow.effectDistance = s.effectDistance;
|
||||
shadow.effectColor = s.effectColor;
|
||||
shadow.useGraphicAlpha = s.useGraphicAlpha;
|
||||
shadow.blurFactor = s.blur;
|
||||
}
|
||||
|
||||
m_ShadowStyle = ShadowStyle.None;
|
||||
m_AdditionalShadows = null;
|
||||
|
||||
if (m_EffectMode == EffectMode.None && m_ColorMode == ColorMode.Multiply && m_BlurMode == BlurMode.None)
|
||||
{
|
||||
DestroyImmediate(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
int tone = (int)m_EffectMode;
|
||||
const int Mono = 5;
|
||||
const int Cutoff = 6;
|
||||
const int Hue = 7;
|
||||
if (tone == Hue)
|
||||
{
|
||||
var go = gameObject;
|
||||
var hue = m_EffectFactor;
|
||||
DestroyImmediate(this, true);
|
||||
var hsv = go.GetComponent<UIHsvModifier>() ?? go.AddComponent<UIHsvModifier>();
|
||||
hsv.hue = hue;
|
||||
hsv.range = 1;
|
||||
}
|
||||
|
||||
// Cutoff/Mono
|
||||
if (tone == Cutoff || tone == Mono)
|
||||
{
|
||||
var go = gameObject;
|
||||
var factor = m_EffectFactor;
|
||||
var transitionMode = tone == Cutoff
|
||||
? UITransitionEffect.EffectMode.Cutoff
|
||||
: UITransitionEffect.EffectMode.Fade;
|
||||
DestroyImmediate(this, true);
|
||||
var trans = go.GetComponent<UITransitionEffect>() ?? go.AddComponent<UITransitionEffect>();
|
||||
trans.effectFactor = factor;
|
||||
|
||||
var sp = new SerializedObject(trans).FindProperty("m_EffectMode");
|
||||
sp.intValue = (int)transitionMode;
|
||||
sp.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 0612
|
||||
#endif
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// Append shadow vertices.
|
||||
/// * It is similar to Shadow component implementation.
|
||||
/// </summary>
|
||||
void _ApplyShadow(List<UIVertex> verts, ref int start, ref int end, ShadowStyle mode, float toneLevel, float blur, Vector2 effectDistance, Color color, bool useGraphicAlpha)
|
||||
static void GetBounds(List<UIVertex> verts, int start, int count, ref Rect posBounds, ref Rect uvBounds, bool global)
|
||||
{
|
||||
if (ShadowStyle.None == mode)
|
||||
return;
|
||||
|
||||
var factor = new Vector2(
|
||||
Packer.ToFloat(toneLevel, 0, blur, 0),
|
||||
Packer.ToFloat(color.r, color.g, color.b, 1)
|
||||
);
|
||||
|
||||
// Append Shadow.
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, effectDistance.x, effectDistance.y, factor, color, useGraphicAlpha);
|
||||
|
||||
// Append Shadow3.
|
||||
if (ShadowStyle.Shadow3 == mode)
|
||||
Vector2 minPos = new Vector2(float.MaxValue, float.MaxValue);
|
||||
Vector2 maxPos = new Vector2(float.MinValue, float.MinValue);
|
||||
Vector2 minUV = new Vector2(float.MaxValue, float.MaxValue);
|
||||
Vector2 maxUV = new Vector2(float.MinValue, float.MinValue);
|
||||
for (int i = start; i < start + count; i++)
|
||||
{
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, effectDistance.x, 0, factor, color, useGraphicAlpha);
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, 0, effectDistance.y, factor, color, useGraphicAlpha);
|
||||
}
|
||||
UIVertex vt = verts[i];
|
||||
|
||||
// Append Outline.
|
||||
else if (ShadowStyle.Outline == mode)
|
||||
{
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, effectDistance.x, -effectDistance.y, factor, color, useGraphicAlpha);
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, -effectDistance.x, effectDistance.y, factor, color, useGraphicAlpha);
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, -effectDistance.x, -effectDistance.y, factor, color, useGraphicAlpha);
|
||||
}
|
||||
Vector2 uv = vt.uv0;
|
||||
Vector3 pos = vt.position;
|
||||
|
||||
// Append Outline8.
|
||||
else if (ShadowStyle.Outline8 == mode)
|
||||
{
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, effectDistance.x, -effectDistance.y, factor, color, useGraphicAlpha);
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, -effectDistance.x, effectDistance.y, factor, color, useGraphicAlpha);
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, -effectDistance.x, -effectDistance.y, factor, color, useGraphicAlpha);
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, -effectDistance.x, 0, factor, color, useGraphicAlpha);
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, 0, -effectDistance.y, factor, color, useGraphicAlpha);
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, effectDistance.x, 0, factor, color, useGraphicAlpha);
|
||||
_ApplyShadowZeroAlloc(tempVerts, ref start, ref end, 0, effectDistance.y, factor, color, useGraphicAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append shadow vertices.
|
||||
/// * It is similar to Shadow component implementation.
|
||||
/// </summary>
|
||||
void _ApplyShadowZeroAlloc(List<UIVertex> verts, ref int start, ref int end, float x, float y, Vector2 factor, Color color, bool useGraphicAlpha)
|
||||
{
|
||||
// Check list capacity.
|
||||
var neededCapacity = verts.Count + end - start;
|
||||
if (verts.Capacity < neededCapacity)
|
||||
verts.Capacity = neededCapacity;
|
||||
|
||||
// Append shadow vertices to the front of list.
|
||||
// * The original vertex is pushed backward.
|
||||
UIVertex vt;
|
||||
for (int i = start; i < end; ++i)
|
||||
{
|
||||
vt = verts[i];
|
||||
verts.Add(vt);
|
||||
|
||||
Vector3 v = vt.position;
|
||||
vt.position.Set(v.x + x, v.y + y, v.z);
|
||||
|
||||
Color vertColor = color;
|
||||
|
||||
if(colorMode != ColorMode.Multiply)
|
||||
// Left-Bottom
|
||||
if (minPos.x >= pos.x && minPos.y >= pos.y)
|
||||
{
|
||||
vertColor.r = vertColor.g = vertColor.b = 1;
|
||||
minPos = pos;
|
||||
}
|
||||
// Right-Top
|
||||
else if (maxPos.x <= pos.x && maxPos.y <= pos.y)
|
||||
{
|
||||
maxPos = pos;
|
||||
}
|
||||
|
||||
vertColor.a = useGraphicAlpha ? color.a * vt.color.a / 255 : color.a;
|
||||
vt.color = vertColor;
|
||||
|
||||
// Set UIEffect prameters to vertex.
|
||||
vt.uv1 = factor;
|
||||
verts[i] = vt;
|
||||
// Left-Bottom
|
||||
if (minUV.x >= uv.x && minUV.y >= uv.y)
|
||||
{
|
||||
minUV = uv;
|
||||
}
|
||||
// Right-Top
|
||||
else if (maxUV.x <= uv.x && maxUV.y <= uv.y)
|
||||
{
|
||||
maxUV = uv;
|
||||
}
|
||||
}
|
||||
|
||||
// Update next shadow offset.
|
||||
start = end;
|
||||
end = verts.Count;
|
||||
// Shrink coordinate for detect edge
|
||||
posBounds.Set(minPos.x + 0.001f, minPos.y + 0.001f, maxPos.x - minPos.x - 0.002f, maxPos.y - minPos.y - 0.002f);
|
||||
uvBounds.Set(minUV.x, minUV.y, maxUV.x - minUV.x, maxUV.y - minUV.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Coffee.UIExtensions
|
||||
/// <summary>
|
||||
/// UIEffectCapturedImage
|
||||
/// </summary>
|
||||
[AddComponentMenu("UI/UIEffect/UIEffectCapturedImage", 200)]
|
||||
public class UIEffectCapturedImage : RawImage
|
||||
#if UNITY_EDITOR
|
||||
, ISerializationCallbackReceiver
|
||||
@@ -37,51 +38,107 @@ namespace Coffee.UIExtensions
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
[SerializeField][Range(0, 1)] float m_ToneLevel = 1;
|
||||
[SerializeField][Range(0, 1)] float m_Blur = 0;
|
||||
[SerializeField] ToneMode m_ToneMode;
|
||||
[SerializeField] ColorMode m_ColorMode;
|
||||
[SerializeField] BlurMode m_BlurMode;
|
||||
[Tooltip("Effect factor between 0(no effect) and 1(complete effect).")]
|
||||
[FormerlySerializedAs("m_ToneLevel")]
|
||||
[SerializeField][Range(0, 1)] float m_EffectFactor = 1;
|
||||
|
||||
[Tooltip("Color effect factor between 0(no effect) and 1(complete effect).")]
|
||||
[SerializeField][Range(0, 1)] float m_ColorFactor = 1;
|
||||
|
||||
[Tooltip("How far is the blurring from the graphic.")]
|
||||
[FormerlySerializedAs("m_Blur")]
|
||||
[SerializeField][Range(0, 1)] float m_BlurFactor = 1;
|
||||
|
||||
[Tooltip("Effect mode.")]
|
||||
[FormerlySerializedAs("m_ToneMode")]
|
||||
[SerializeField] EffectMode m_EffectMode = EffectMode.None;
|
||||
|
||||
[Tooltip("Color effect mode.")]
|
||||
[SerializeField] ColorMode m_ColorMode = ColorMode.Multiply;
|
||||
|
||||
[Tooltip("Blur effect mode.")]
|
||||
[SerializeField] BlurMode m_BlurMode = BlurMode.DetailBlur;
|
||||
|
||||
[Tooltip("Color for the color effect.")]
|
||||
[SerializeField] Color m_EffectColor = Color.white;
|
||||
[SerializeField] DesamplingRate m_DesamplingRate;
|
||||
[SerializeField] DesamplingRate m_ReductionRate;
|
||||
|
||||
[Tooltip("Desampling rate of the generated RenderTexture.")]
|
||||
[SerializeField] DesamplingRate m_DesamplingRate = DesamplingRate.x1;
|
||||
|
||||
[Tooltip("Desampling rate of reduction buffer to apply effect.")]
|
||||
[SerializeField] DesamplingRate m_ReductionRate = DesamplingRate.x1;
|
||||
|
||||
[Tooltip("FilterMode for capturing.")]
|
||||
[SerializeField] FilterMode m_FilterMode = FilterMode.Bilinear;
|
||||
|
||||
[Tooltip("Effect material.")]
|
||||
[SerializeField] Material m_EffectMaterial;
|
||||
|
||||
[Tooltip("Blur iterations.")]
|
||||
[FormerlySerializedAs("m_Iterations")]
|
||||
[SerializeField][Range(1, 8)] int m_BlurIterations = 1;
|
||||
[SerializeField][Range(1, 8)] int m_BlurIterations = 3;
|
||||
|
||||
[Tooltip("Fits graphic size to screen on captured.")]
|
||||
[FormerlySerializedAs("m_KeepCanvasSize")]
|
||||
[SerializeField] bool m_FitToScreen = true;
|
||||
[SerializeField] RenderTexture m_TargetTexture;
|
||||
|
||||
[Tooltip("Capture automatically on enable.")]
|
||||
[SerializeField] bool m_CaptureOnEnable = false;
|
||||
|
||||
[Tooltip("Capture immediately.")]
|
||||
[SerializeField] bool m_ImmediateCapturing = true;
|
||||
|
||||
|
||||
//################################
|
||||
// Public Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// Tone effect level between 0(no effect) and 1(complete effect).
|
||||
/// Effect factor between 0(no effect) and 1(complete effect).
|
||||
/// </summary>
|
||||
public float toneLevel { get { return m_ToneLevel; } set { m_ToneLevel = Mathf.Clamp(value, 0, 1); } }
|
||||
[System.Obsolete("Use effectFactor instead (UnityUpgradable) -> effectFactor")]
|
||||
public float toneLevel { get { return m_EffectFactor; } set { m_EffectFactor = Mathf.Clamp(value, 0, 1); } }
|
||||
|
||||
/// <summary>
|
||||
/// Effect factor between 0(no effect) and 1(complete effect).
|
||||
/// </summary>
|
||||
public float effectFactor { get { return m_EffectFactor; } set { m_EffectFactor = Mathf.Clamp(value, 0, 1); } }
|
||||
|
||||
/// <summary>
|
||||
/// Color effect factor between 0(no effect) and 1(complete effect).
|
||||
/// </summary>
|
||||
public float colorFactor { get { return m_ColorFactor; } set { m_ColorFactor = Mathf.Clamp(value, 0, 1); } }
|
||||
|
||||
/// <summary>
|
||||
/// How far is the blurring from the graphic.
|
||||
/// </summary>
|
||||
public float blur { get { return m_Blur; } set { m_Blur = Mathf.Clamp(value, 0, 4); } }
|
||||
[System.Obsolete("Use blurFactor instead (UnityUpgradable) -> blurFactor")]
|
||||
public float blur { get { return m_BlurFactor; } set { m_BlurFactor = Mathf.Clamp(value, 0, 4); } }
|
||||
|
||||
/// <summary>
|
||||
/// How far is the blurring from the graphic.
|
||||
/// </summary>
|
||||
public float blurFactor { get { return m_BlurFactor; } set { m_BlurFactor = Mathf.Clamp(value, 0, 4); } }
|
||||
|
||||
/// <summary>
|
||||
/// Tone effect mode.
|
||||
/// </summary>
|
||||
public ToneMode toneMode { get { return m_ToneMode; } set { m_ToneMode = value; } }
|
||||
[System.Obsolete("Use effectMode instead (UnityUpgradable) -> effectMode")]
|
||||
public EffectMode toneMode { get { return m_EffectMode; } }
|
||||
|
||||
/// <summary>
|
||||
/// Effect mode.
|
||||
/// </summary>
|
||||
public EffectMode effectMode { get { return m_EffectMode; } }
|
||||
|
||||
/// <summary>
|
||||
/// Color effect mode.
|
||||
/// </summary>
|
||||
public ColorMode colorMode { get { return m_ColorMode; } set { m_ColorMode = value; } }
|
||||
public ColorMode colorMode { get { return m_ColorMode; } }
|
||||
|
||||
/// <summary>
|
||||
/// Blur effect mode.
|
||||
/// </summary>
|
||||
public BlurMode blurMode { get { return m_BlurMode; } set { m_BlurMode = value; } }
|
||||
public BlurMode blurMode { get { return m_BlurMode; } }
|
||||
|
||||
/// <summary>
|
||||
/// Color for the color effect.
|
||||
@@ -104,14 +161,14 @@ namespace Coffee.UIExtensions
|
||||
public DesamplingRate reductionRate { get { return m_ReductionRate; } set { m_ReductionRate = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// FilterMode for capture.
|
||||
/// FilterMode for capturing.
|
||||
/// </summary>
|
||||
public FilterMode filterMode { get { return m_FilterMode; } set { m_FilterMode = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Captured texture.
|
||||
/// </summary>
|
||||
public RenderTexture capturedTexture { get { return m_TargetTexture ? m_TargetTexture : _rt; } }
|
||||
public RenderTexture capturedTexture { get { return _rt; } }
|
||||
|
||||
/// <summary>
|
||||
/// Blur iterations.
|
||||
@@ -131,14 +188,25 @@ namespace Coffee.UIExtensions
|
||||
public bool keepCanvasSize { get { return m_FitToScreen; } set { m_FitToScreen = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Fits graphic size to screen.
|
||||
/// Fits graphic size to screen on captured.
|
||||
/// </summary>
|
||||
public bool fitToScreen { get { return m_FitToScreen; } set { m_FitToScreen = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Target RenderTexture to capture.
|
||||
/// </summary>
|
||||
public RenderTexture targetTexture { get { return m_TargetTexture; } set { m_TargetTexture = value; } }
|
||||
[System.Obsolete]
|
||||
public RenderTexture targetTexture { get { return null; } set { } }
|
||||
|
||||
/// <summary>
|
||||
/// Capture automatically on enable.
|
||||
/// </summary>
|
||||
public bool captureOnEnable { get { return m_CaptureOnEnable; } set { m_CaptureOnEnable = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Capture immediately.
|
||||
/// </summary>
|
||||
public bool immediateCapturing { get { return m_ImmediateCapturing; } set { m_ImmediateCapturing = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
@@ -177,10 +245,23 @@ namespace Coffee.UIExtensions
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
// When not displaying, clear vertex.
|
||||
if (texture == null || effectColor.a < 1 / 255f || canvasRenderer.GetAlpha() < 1 / 255f)
|
||||
if (texture == null || color.a < 1 / 255f || canvasRenderer.GetAlpha() < 1 / 255f)
|
||||
{
|
||||
vh.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnPopulateMesh(vh);
|
||||
int count = vh.currentVertCount;
|
||||
UIVertex vt = default(UIVertex);
|
||||
Color c = new Color(1, 1, 1, color.a);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
vh.PopulateUIVertex(ref vt, i);
|
||||
vt.color = c;
|
||||
vh.SetUIVertex(vt, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -223,7 +304,7 @@ namespace Coffee.UIExtensions
|
||||
/// </summary>
|
||||
public void Capture()
|
||||
{
|
||||
// Fit to screen.
|
||||
// Fit to screen.
|
||||
var rootCanvas = canvas.rootCanvas;
|
||||
if (m_FitToScreen)
|
||||
{
|
||||
@@ -243,33 +324,26 @@ namespace Coffee.UIExtensions
|
||||
|
||||
s_EffectFactorId = Shader.PropertyToID("_EffectFactor");
|
||||
s_ColorFactorId = Shader.PropertyToID("_ColorFactor");
|
||||
s_CommandBuffer = new CommandBuffer();
|
||||
s_CommandBuffer = new CommandBuffer();
|
||||
}
|
||||
|
||||
// If target texture exists, release result RT.
|
||||
if (m_TargetTexture)
|
||||
{
|
||||
_Release(ref _rt);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If size of result RT has changed, release it.
|
||||
int w, h;
|
||||
GetDesamplingSize (m_DesamplingRate, out w, out h);
|
||||
if (_rt && (_rt.width != w || _rt.height != h))
|
||||
{
|
||||
_Release (ref _rt);
|
||||
}
|
||||
|
||||
// Generate RT for result.
|
||||
if (_rt == null)
|
||||
{
|
||||
_rt = new RenderTexture(w, h, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
|
||||
_rt.filterMode = m_FilterMode;
|
||||
_rt.useMipMap = false;
|
||||
_rt.wrapMode = TextureWrapMode.Clamp;
|
||||
_rt.hideFlags = HideFlags.HideAndDontSave;
|
||||
}
|
||||
// If size of result RT has changed, release it.
|
||||
int w, h;
|
||||
GetDesamplingSize(m_DesamplingRate, out w, out h);
|
||||
if (_rt && (_rt.width != w || _rt.height != h))
|
||||
{
|
||||
_Release(ref _rt);
|
||||
}
|
||||
|
||||
// Generate RT for result.
|
||||
if (_rt == null)
|
||||
{
|
||||
_rt = new RenderTexture(w, h, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
|
||||
_rt.filterMode = m_FilterMode;
|
||||
_rt.useMipMap = false;
|
||||
_rt.wrapMode = TextureWrapMode.Clamp;
|
||||
_rt.hideFlags = HideFlags.HideAndDontSave;
|
||||
}
|
||||
SetupCommandBuffer();
|
||||
}
|
||||
@@ -277,16 +351,11 @@ namespace Coffee.UIExtensions
|
||||
void SetupCommandBuffer()
|
||||
{
|
||||
// Material for effect.
|
||||
Material mat = effectMaterial;
|
||||
Material mat = m_EffectMaterial;
|
||||
|
||||
if(s_CommandBuffer == null)
|
||||
if (s_CommandBuffer == null)
|
||||
{
|
||||
s_CommandBuffer = new CommandBuffer ();
|
||||
}
|
||||
s_CommandBuffer.name = mat ? mat.name : "noeffect";
|
||||
if (_rt)
|
||||
{
|
||||
_rt.name = s_CommandBuffer.name;
|
||||
s_CommandBuffer = new CommandBuffer();
|
||||
}
|
||||
|
||||
// [1] Capture from back buffer (back buffer -> copied screen).
|
||||
@@ -300,12 +369,12 @@ namespace Coffee.UIExtensions
|
||||
#endif
|
||||
|
||||
// Set properties for effect.
|
||||
s_CommandBuffer.SetGlobalVector(s_EffectFactorId, new Vector4(toneLevel, 0));
|
||||
s_CommandBuffer.SetGlobalVector(s_ColorFactorId, new Vector4(effectColor.r, effectColor.g, effectColor.b, effectColor.a));
|
||||
s_CommandBuffer.SetGlobalVector(s_EffectFactorId, new Vector4(m_EffectFactor, 0));
|
||||
s_CommandBuffer.SetGlobalVector(s_ColorFactorId, new Vector4(m_EffectColor.r, m_EffectColor.g, m_EffectColor.b, m_EffectColor.a));
|
||||
|
||||
// [2] Apply base effect with reduction buffer (copied screen -> effect1).
|
||||
GetDesamplingSize (m_ReductionRate, out w, out h);
|
||||
s_CommandBuffer.GetTemporaryRT (s_EffectId1, w, h, 0, m_FilterMode);
|
||||
GetDesamplingSize(m_ReductionRate, out w, out h);
|
||||
s_CommandBuffer.GetTemporaryRT(s_EffectId1, w, h, 0, m_FilterMode);
|
||||
s_CommandBuffer.Blit(s_CopyId, s_EffectId1, mat, 0);
|
||||
s_CommandBuffer.ReleaseTemporaryRT(s_CopyId);
|
||||
|
||||
@@ -316,28 +385,24 @@ namespace Coffee.UIExtensions
|
||||
for (int i = 0; i < m_BlurIterations; i++)
|
||||
{
|
||||
// [3] Apply blurring with reduction buffer (effect1 -> effect2, or effect2 -> effect1).
|
||||
s_CommandBuffer.SetGlobalVector(s_EffectFactorId, new Vector4(blur, 0));
|
||||
s_CommandBuffer.SetGlobalVector(s_EffectFactorId, new Vector4(m_BlurFactor, 0));
|
||||
s_CommandBuffer.Blit(s_EffectId1, s_EffectId2, mat, 1);
|
||||
s_CommandBuffer.SetGlobalVector(s_EffectFactorId, new Vector4(0, blur));
|
||||
s_CommandBuffer.SetGlobalVector(s_EffectFactorId, new Vector4(0, m_BlurFactor));
|
||||
s_CommandBuffer.Blit(s_EffectId2, s_EffectId1, mat, 1);
|
||||
}
|
||||
s_CommandBuffer.ReleaseTemporaryRT(s_EffectId2);
|
||||
}
|
||||
|
||||
// [4] Copy to result RT.
|
||||
s_CommandBuffer.Blit(s_EffectId1, new RenderTargetIdentifier (capturedTexture));
|
||||
// [4] Copy to result RT.
|
||||
s_CommandBuffer.Blit(s_EffectId1, new RenderTargetIdentifier(capturedTexture));
|
||||
s_CommandBuffer.ReleaseTemporaryRT(s_EffectId1);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if(!Application.isPlaying)
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
texture = null;
|
||||
_SetDirty ();
|
||||
Graphics.ExecuteCommandBuffer (s_CommandBuffer);
|
||||
Graphics.ExecuteCommandBuffer(s_CommandBuffer);
|
||||
|
||||
_Release(false);
|
||||
texture = capturedTexture;
|
||||
_SetDirty ();
|
||||
UpdateTexture();
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -345,8 +410,15 @@ namespace Coffee.UIExtensions
|
||||
Graphics.ExecuteCommandBuffer(s_CommandBuffer);
|
||||
}
|
||||
#endif
|
||||
// Execute command buffer.
|
||||
canvas.rootCanvas.GetComponent<CanvasScaler> ().StartCoroutine(_CoUpdateTextureOnNextFrame ());
|
||||
if (m_ImmediateCapturing)
|
||||
{
|
||||
UpdateTexture();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Execute command buffer.
|
||||
canvas.rootCanvas.GetComponent<CanvasScaler>().StartCoroutine(_CoUpdateTextureOnNextFrame());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -362,10 +434,10 @@ namespace Coffee.UIExtensions
|
||||
#if UNITY_EDITOR
|
||||
protected override void Reset()
|
||||
{
|
||||
// Set parameters as 'Detail'.
|
||||
m_BlurIterations = 5;
|
||||
// Set parameters as 'Medium'.
|
||||
m_BlurIterations = 3;
|
||||
m_FilterMode = FilterMode.Bilinear;
|
||||
m_DesamplingRate = DesamplingRate.None;
|
||||
m_DesamplingRate = DesamplingRate.x1;
|
||||
m_ReductionRate = DesamplingRate.x1;
|
||||
base.Reset();
|
||||
}
|
||||
@@ -388,9 +460,9 @@ namespace Coffee.UIExtensions
|
||||
/// <summary>
|
||||
/// Raises the validate event.
|
||||
/// </summary>
|
||||
protected override void OnValidate ()
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate ();
|
||||
base.OnValidate();
|
||||
UnityEditor.EditorApplication.delayCall += () => UpdateMaterial(false);
|
||||
}
|
||||
|
||||
@@ -400,12 +472,12 @@ namespace Coffee.UIExtensions
|
||||
/// <param name="ignoreInPlayMode">If set to <c>true</c> ignore in play mode.</param>
|
||||
protected void UpdateMaterial(bool ignoreInPlayMode)
|
||||
{
|
||||
if(!this || ignoreInPlayMode && Application.isPlaying)
|
||||
if (!this || ignoreInPlayMode && Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var mat = MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName), m_ToneMode, m_ColorMode, m_BlurMode);
|
||||
var mat = MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName), m_EffectMode, m_ColorMode, m_BlurMode);
|
||||
if (m_EffectMaterial != mat)
|
||||
{
|
||||
material = null;
|
||||
@@ -427,7 +499,7 @@ namespace Coffee.UIExtensions
|
||||
static int s_EffectId2;
|
||||
static int s_EffectFactorId;
|
||||
static int s_ColorFactorId;
|
||||
static CommandBuffer s_CommandBuffer;
|
||||
static CommandBuffer s_CommandBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// Release genarated objects.
|
||||
@@ -435,7 +507,7 @@ namespace Coffee.UIExtensions
|
||||
/// <param name="releaseRT">If set to <c>true</c> release cached RenderTexture.</param>
|
||||
void _Release(bool releaseRT)
|
||||
{
|
||||
if (releaseRT || m_TargetTexture)
|
||||
if (releaseRT)
|
||||
{
|
||||
texture = null;
|
||||
_Release(ref _rt);
|
||||
@@ -443,11 +515,11 @@ namespace Coffee.UIExtensions
|
||||
|
||||
if (s_CommandBuffer != null)
|
||||
{
|
||||
s_CommandBuffer.Clear();
|
||||
s_CommandBuffer.Clear();
|
||||
|
||||
if(releaseRT)
|
||||
if (releaseRT)
|
||||
{
|
||||
s_CommandBuffer.Release ();
|
||||
s_CommandBuffer.Release();
|
||||
s_CommandBuffer = null;
|
||||
}
|
||||
}
|
||||
@@ -457,7 +529,7 @@ namespace Coffee.UIExtensions
|
||||
void _SetDirty()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if(!Application.isPlaying)
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
UnityEditor.EditorUtility.SetDirty(this);
|
||||
}
|
||||
@@ -470,7 +542,7 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
obj.Release();
|
||||
#if UNITY_EDITOR
|
||||
if(!Application.isPlaying)
|
||||
if (!Application.isPlaying)
|
||||
DestroyImmediate(obj);
|
||||
else
|
||||
#endif
|
||||
@@ -482,10 +554,14 @@ namespace Coffee.UIExtensions
|
||||
/// <summary>
|
||||
/// Set texture on next frame.
|
||||
/// </summary>
|
||||
IEnumerator _CoUpdateTextureOnNextFrame ()
|
||||
IEnumerator _CoUpdateTextureOnNextFrame()
|
||||
{
|
||||
yield return new WaitForEndOfFrame ();
|
||||
yield return new WaitForEndOfFrame();
|
||||
UpdateTexture();
|
||||
}
|
||||
|
||||
void UpdateTexture()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
// Execute command buffer.
|
||||
Graphics.ExecuteCommandBuffer (s_CommandBuffer);
|
||||
|
||||
@@ -8,12 +8,17 @@ namespace Coffee.UIExtensions
|
||||
|
||||
[RequireComponent(typeof(Graphic))]
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("UI/UIEffect/UIFlip",102)]
|
||||
public class UIFlip : BaseMeshEffect
|
||||
{
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
|
||||
[Tooltip("Flip horizontally.")]
|
||||
[SerializeField] private bool m_Horizontal = false;
|
||||
|
||||
[Tooltip("Flip vertically.")]
|
||||
[SerializeField] private bool m_Veritical = false;
|
||||
|
||||
//################################
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Coffee.UIExtensions
|
||||
/// UIGradient.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("UI/UIEffect/UIGradient",101)]
|
||||
public class UIGradient : BaseMeshEffect
|
||||
{
|
||||
//################################
|
||||
@@ -38,48 +39,125 @@ namespace Coffee.UIExtensions
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
|
||||
[Tooltip("Gradient Direction.")]
|
||||
[SerializeField] Direction m_Direction;
|
||||
|
||||
[Tooltip("Color1: Top or Left.")]
|
||||
[SerializeField] Color m_Color1 = Color.white;
|
||||
|
||||
[Tooltip("Color2: Bottom or Right.")]
|
||||
[SerializeField] Color m_Color2 = Color.white;
|
||||
|
||||
[Tooltip("Color3: For diagonal.")]
|
||||
[SerializeField] Color m_Color3 = Color.white;
|
||||
|
||||
[Tooltip("Color4: For diagonal.")]
|
||||
[SerializeField] Color m_Color4 = Color.white;
|
||||
|
||||
[Tooltip("Gradient rotation.")]
|
||||
[SerializeField][Range(-180, 180)] float m_Rotation;
|
||||
|
||||
[Tooltip("Gradient offset for Horizontal, Vertical or Angle.")]
|
||||
[SerializeField][Range(-1, 1)] float m_Offset1;
|
||||
|
||||
[Tooltip("Gradient offset for Diagonal.")]
|
||||
[SerializeField][Range(-1, 1)] float m_Offset2;
|
||||
|
||||
[Tooltip("Gradient style for Text.")]
|
||||
[SerializeField] GradientStyle m_GradientStyle;
|
||||
|
||||
[Tooltip("Color space to correct color.")]
|
||||
[SerializeField] ColorSpace m_ColorSpace = ColorSpace.Uninitialized;
|
||||
|
||||
[Tooltip("Ignore aspect ratio.")]
|
||||
[SerializeField] bool m_IgnoreAspectRatio = true;
|
||||
|
||||
|
||||
//################################
|
||||
// Public Members.
|
||||
//################################
|
||||
new public Graphic graphic { get { return base.graphic; } }
|
||||
public Graphic targetGraphic { get { return base.graphic; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gradient Direction.
|
||||
/// </summary>
|
||||
public Direction direction { get { return m_Direction; } set { if (m_Direction != value) { m_Direction = value; graphic.SetVerticesDirty(); } } }
|
||||
public Direction direction
|
||||
{
|
||||
get { return m_Direction; }
|
||||
set
|
||||
{
|
||||
if (m_Direction != value)
|
||||
{
|
||||
m_Direction = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color1: Top or Left.
|
||||
/// </summary>
|
||||
public Color color1 { get { return m_Color1; } set { if (m_Color1 != value) { m_Color1 = value; graphic.SetVerticesDirty(); } } }
|
||||
public Color color1
|
||||
{
|
||||
get { return m_Color1; }
|
||||
set
|
||||
{
|
||||
if (m_Color1 != value)
|
||||
{
|
||||
m_Color1 = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color2: Bottom or Right.
|
||||
/// </summary>
|
||||
public Color color2 { get { return m_Color2; } set { if (m_Color2 != value) { m_Color2 = value; graphic.SetVerticesDirty(); } } }
|
||||
public Color color2
|
||||
{
|
||||
get { return m_Color2; }
|
||||
set
|
||||
{
|
||||
if (m_Color2 != value)
|
||||
{
|
||||
m_Color2 = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color3: For diagonal.
|
||||
/// </summary>
|
||||
public Color color3 { get { return m_Color3; } set { if (m_Color3 != value) { m_Color3 = value; graphic.SetVerticesDirty(); } } }
|
||||
public Color color3
|
||||
{
|
||||
get { return m_Color3; }
|
||||
set
|
||||
{
|
||||
if (m_Color3 != value)
|
||||
{
|
||||
m_Color3 = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color4: For diagonal.
|
||||
/// </summary>
|
||||
public Color color4 { get { return m_Color4; } set { if (m_Color4 != value) { m_Color4 = value; graphic.SetVerticesDirty(); } } }
|
||||
public Color color4
|
||||
{
|
||||
get { return m_Color4; }
|
||||
set
|
||||
{
|
||||
if (m_Color4 != value)
|
||||
{
|
||||
m_Color4 = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gradient rotation.
|
||||
@@ -92,33 +170,96 @@ namespace Coffee.UIExtensions
|
||||
: m_Direction == Direction.Vertical ? 0
|
||||
: m_Rotation;
|
||||
}
|
||||
set { if (!Mathf.Approximately(m_Rotation, value)) { m_Rotation = value; graphic.SetVerticesDirty(); } }
|
||||
set
|
||||
{
|
||||
if (!Mathf.Approximately(m_Rotation, value))
|
||||
{
|
||||
m_Rotation = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gradient offset for Horizontal, Vertical or Angle.
|
||||
/// </summary>
|
||||
public float offset { get { return m_Offset1; } set { if (m_Offset1 != value) { m_Offset1 = value; graphic.SetVerticesDirty(); } } }
|
||||
public float offset
|
||||
{
|
||||
get { return m_Offset1; }
|
||||
set
|
||||
{
|
||||
if (m_Offset1 != value)
|
||||
{
|
||||
m_Offset1 = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gradient offset for Diagonal.
|
||||
/// </summary>
|
||||
public Vector2 offset2 { get { return new Vector2(m_Offset2, m_Offset1); } set { if (m_Offset1 != value.y || m_Offset2 != value.x) { m_Offset1 = value.y; m_Offset2 = value.x; graphic.SetVerticesDirty(); } } }
|
||||
public Vector2 offset2
|
||||
{
|
||||
get { return new Vector2(m_Offset2, m_Offset1); }
|
||||
set
|
||||
{
|
||||
if (m_Offset1 != value.y || m_Offset2 != value.x)
|
||||
{
|
||||
m_Offset1 = value.y;
|
||||
m_Offset2 = value.x;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gradient style for Text.
|
||||
/// </summary>
|
||||
public GradientStyle gradientStyle { get { return m_GradientStyle; } set { if (m_GradientStyle != value) { m_GradientStyle = value; graphic.SetVerticesDirty(); } } }
|
||||
public GradientStyle gradientStyle
|
||||
{
|
||||
get { return m_GradientStyle; }
|
||||
set
|
||||
{
|
||||
if (m_GradientStyle != value)
|
||||
{
|
||||
m_GradientStyle = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color space to correct color.
|
||||
/// </summary>
|
||||
public ColorSpace colorSpace { get { return m_ColorSpace; } set { if (m_ColorSpace != value) { m_ColorSpace = value; graphic.SetVerticesDirty(); } } }
|
||||
public ColorSpace colorSpace
|
||||
{
|
||||
get { return m_ColorSpace; }
|
||||
set
|
||||
{
|
||||
if (m_ColorSpace != value)
|
||||
{
|
||||
m_ColorSpace = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ignore aspect ratio.
|
||||
/// </summary>
|
||||
public bool ignoreAspectRatio { get { return m_IgnoreAspectRatio; } set { if (m_IgnoreAspectRatio != value) { m_IgnoreAspectRatio = value; graphic.SetVerticesDirty(); } } }
|
||||
public bool ignoreAspectRatio
|
||||
{
|
||||
get { return m_IgnoreAspectRatio; }
|
||||
set
|
||||
{
|
||||
if (m_IgnoreAspectRatio != value)
|
||||
{
|
||||
m_IgnoreAspectRatio = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,25 +8,36 @@ namespace Coffee.UIExtensions
|
||||
/// <summary>
|
||||
/// HSV Modifier.
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("UI/UIEffect/UIHsvModifier", 4)]
|
||||
public class UIHsvModifier : UIEffectBase
|
||||
{
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
public const string shaderName = "UI/Hidden/UI-Effect-HSV";
|
||||
static readonly ParameterTexture _ptex = new ParameterTexture(7, 128, "_ParamTex");
|
||||
|
||||
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
[Header("Target")]
|
||||
|
||||
[Tooltip("Target color to affect hsv shift.")]
|
||||
[SerializeField] [ColorUsage(false)] Color m_TargetColor = Color.red;
|
||||
|
||||
[Tooltip("Color range to affect hsv shift [0 ~ 1].")]
|
||||
[SerializeField] [Range(0, 1)] float m_Range = 0.1f;
|
||||
|
||||
[Header("Adjustment")]
|
||||
|
||||
[Tooltip("Hue shift [-0.5 ~ 0.5].")]
|
||||
[SerializeField] [Range(-0.5f, 0.5f)] float m_Hue;
|
||||
|
||||
[Tooltip("Saturation shift [-0.5 ~ 0.5].")]
|
||||
[SerializeField] [Range(-0.5f, 0.5f)] float m_Saturation;
|
||||
|
||||
[Tooltip("Value shift [-0.5 ~ 0.5].")]
|
||||
[SerializeField] [Range(-0.5f, 0.5f)] float m_Value;
|
||||
|
||||
|
||||
@@ -117,6 +128,11 @@ namespace Coffee.UIExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameter texture.
|
||||
/// </summary>
|
||||
public override ParameterTexture ptex { get { return _ptex; } }
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override Material GetMaterial()
|
||||
{
|
||||
@@ -132,26 +148,34 @@ namespace Coffee.UIExtensions
|
||||
if (!isActiveAndEnabled)
|
||||
return;
|
||||
|
||||
vh.GetUIVertexStream(tempVerts);
|
||||
vh.Clear();
|
||||
float normalizedIndex = ptex.GetNormalizedIndex(this);
|
||||
UIVertex vertex = default(UIVertex);
|
||||
int count = vh.currentVertCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
vh.PopulateUIVertex(ref vertex, i);
|
||||
|
||||
float h,s,v;
|
||||
vertex.uv0 = new Vector2(
|
||||
Packer.ToFloat(vertex.uv0.x, vertex.uv0.y),
|
||||
normalizedIndex
|
||||
);
|
||||
vh.SetUIVertex(vertex, i);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetDirty()
|
||||
{
|
||||
float h, s, v;
|
||||
Color.RGBToHSV(m_TargetColor, out h, out s, out v);
|
||||
|
||||
// Pack some effect factors to 1 float.
|
||||
Vector2 factor = new Vector2(
|
||||
Packer.ToFloat(h, s, v, m_Range),
|
||||
Packer.ToFloat(m_Hue + 0.5f, m_Saturation + 0.5f, m_Value + 0.5f)
|
||||
);
|
||||
|
||||
for (int i = 0; i < tempVerts.Count; i++)
|
||||
{
|
||||
UIVertex vt = tempVerts[i];
|
||||
vt.uv1 = factor;
|
||||
tempVerts[i] = vt;
|
||||
}
|
||||
|
||||
vh.AddUIVertexTriangleStream(tempVerts);
|
||||
ptex.RegisterMaterial(targetGraphic.material);
|
||||
ptex.SetData(this, 0, h); // param1.x : target hue
|
||||
ptex.SetData(this, 1, s); // param1.y : target saturation
|
||||
ptex.SetData(this, 2, v); // param1.z : target value
|
||||
ptex.SetData(this, 3, m_Range); // param1.w : target range
|
||||
ptex.SetData(this, 4, m_Hue + 0.5f); // param2.x : hue shift
|
||||
ptex.SetData(this, 5, m_Saturation + 0.5f); // param2.y : saturation shift
|
||||
ptex.SetData(this, 6, m_Value + 0.5f); // param2.z : value shift
|
||||
}
|
||||
|
||||
//################################
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
@@ -14,30 +15,37 @@ namespace Coffee.UIExtensions
|
||||
/// <summary>
|
||||
/// UIEffect.
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Graphic))]
|
||||
[DisallowMultipleComponent]
|
||||
public class UIShadow : Shadow
|
||||
[AddComponentMenu("UI/UIEffect/UIShadow", 100)]
|
||||
public class UIShadow : Shadow, IParameterTexture
|
||||
#if UNITY_EDITOR
|
||||
, ISerializationCallbackReceiver
|
||||
#endif
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Additional shadow.
|
||||
/// </summary>
|
||||
[System.Obsolete]
|
||||
[System.Serializable]
|
||||
public class AdditionalShadow
|
||||
{
|
||||
/// <summary>
|
||||
/// How far is the blurring shadow from the graphic.
|
||||
/// </summary>
|
||||
[FormerlySerializedAs("shadowBlur")]
|
||||
[Range(0, 1)] public float blur = 0.25f;
|
||||
|
||||
/// <summary>
|
||||
/// Shadow effect mode.
|
||||
/// </summary>
|
||||
[FormerlySerializedAs("shadowMode")]
|
||||
public ShadowStyle style = ShadowStyle.Shadow;
|
||||
|
||||
/// <summary>
|
||||
/// Color for the shadow effect.
|
||||
/// </summary>
|
||||
[FormerlySerializedAs("shadowColor")]
|
||||
public Color effectColor = Color.black;
|
||||
|
||||
/// <summary>
|
||||
@@ -54,8 +62,14 @@ namespace Coffee.UIExtensions
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
[SerializeField][Range(0, 1)] float m_Blur = 0.25f;
|
||||
[Tooltip("How far is the blurring shadow from the graphic.")]
|
||||
[FormerlySerializedAs("m_Blur")]
|
||||
[SerializeField][Range(0, 1)] float m_BlurFactor = 1;
|
||||
|
||||
[Tooltip("Shadow effect style.")]
|
||||
[SerializeField] ShadowStyle m_Style = ShadowStyle.Shadow;
|
||||
|
||||
[HideInInspector][System.Obsolete]
|
||||
[SerializeField] List<AdditionalShadow> m_AdditionalShadows = new List<AdditionalShadow>();
|
||||
|
||||
|
||||
@@ -63,57 +77,128 @@ namespace Coffee.UIExtensions
|
||||
// Public Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// Graphic affected by the UIEffect.
|
||||
/// How far is the blurring shadow from the graphic.
|
||||
/// </summary>
|
||||
new public Graphic graphic { get { return base.graphic; } }
|
||||
|
||||
[System.Obsolete("Use blurFactor instead (UnityUpgradable) -> blurFactor")]
|
||||
public float blur
|
||||
{
|
||||
get { return m_BlurFactor; }
|
||||
set
|
||||
{
|
||||
m_BlurFactor = Mathf.Clamp(value, 0, 2);
|
||||
_SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// How far is the blurring shadow from the graphic.
|
||||
/// </summary>
|
||||
public float blur { get { return m_Blur; } set { m_Blur = Mathf.Clamp(value, 0, 2); _SetDirty(); } }
|
||||
public float blurFactor
|
||||
{
|
||||
get { return m_BlurFactor; }
|
||||
set
|
||||
{
|
||||
m_BlurFactor = Mathf.Clamp(value, 0, 2);
|
||||
_SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shadow effect mode.
|
||||
/// Shadow effect style.
|
||||
/// </summary>
|
||||
public ShadowStyle style { get { return m_Style; } set { m_Style = value; _SetDirty(); } }
|
||||
|
||||
public ShadowStyle style
|
||||
{
|
||||
get { return m_Style; }
|
||||
set
|
||||
{
|
||||
m_Style = value;
|
||||
_SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Additional Shadows.
|
||||
/// Gets or sets the parameter index.
|
||||
/// </summary>
|
||||
public List<AdditionalShadow> additionalShadows { get { return m_AdditionalShadows; } }
|
||||
public int parameterIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameter texture.
|
||||
/// </summary>
|
||||
public ParameterTexture ptex{ get; private set; }
|
||||
|
||||
int _graphicVertexCount;
|
||||
static readonly List<UIShadow> tmpShadows = new List<UIShadow>();
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
_uiEffect = GetComponent<UIEffect>();
|
||||
if (_uiEffect)
|
||||
{
|
||||
ptex = _uiEffect.ptex;
|
||||
ptex.Register(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
_uiEffect = null;
|
||||
if (ptex != null)
|
||||
{
|
||||
ptex.Unregister(this);
|
||||
ptex = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Modifies the mesh.
|
||||
/// </summary>
|
||||
public override void ModifyMesh(VertexHelper vh)
|
||||
{
|
||||
if (!isActiveAndEnabled || vh.currentVertCount <= 0)
|
||||
if (!isActiveAndEnabled || vh.currentVertCount <= 0 || m_Style == ShadowStyle.None)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vh.GetUIVertexStream(s_Verts);
|
||||
|
||||
GetComponents<UIShadow>(tmpShadows);
|
||||
|
||||
foreach (var s in tmpShadows)
|
||||
{
|
||||
if (s.isActiveAndEnabled)
|
||||
{
|
||||
if (s == this)
|
||||
{
|
||||
foreach (var s2 in tmpShadows)
|
||||
{
|
||||
s2._graphicVertexCount = s_Verts.Count;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
tmpShadows.Clear();
|
||||
|
||||
//================================
|
||||
// Append shadow vertices.
|
||||
//================================
|
||||
{
|
||||
_uiEffect = GetComponent<UIEffect>();
|
||||
var inputVertCount = s_Verts.Count;
|
||||
var start = 0;
|
||||
var end = inputVertCount;
|
||||
var toneLevel = _uiEffect && _uiEffect.isActiveAndEnabled ? _uiEffect.toneLevel : 0;
|
||||
_uiEffect = _uiEffect ?? GetComponent<UIEffect>();
|
||||
var start = s_Verts.Count - _graphicVertexCount;
|
||||
var end = s_Verts.Count;
|
||||
|
||||
// Additional Shadows.
|
||||
for (int i = additionalShadows.Count - 1; 0 <= i; i--)
|
||||
if (ptex != null && _uiEffect && _uiEffect.isActiveAndEnabled)
|
||||
{
|
||||
AdditionalShadow shadow = additionalShadows[i];
|
||||
UpdateFactor(toneLevel, shadow.blur, shadow.effectColor);
|
||||
_ApplyShadow(s_Verts, shadow.effectColor, ref start, ref end, shadow.effectDistance, shadow.style, shadow.useGraphicAlpha);
|
||||
ptex.SetData(this, 0, _uiEffect.effectFactor); // param.x : effect factor
|
||||
ptex.SetData(this, 1, 255); // param.y : color factor
|
||||
ptex.SetData(this, 2, m_BlurFactor); // param.z : blur factor
|
||||
}
|
||||
|
||||
// Shadow.
|
||||
UpdateFactor(toneLevel, blur, effectColor);
|
||||
_ApplyShadow(s_Verts, effectColor, ref start, ref end, effectDistance, style, useGraphicAlpha);
|
||||
}
|
||||
|
||||
@@ -124,21 +209,12 @@ namespace Coffee.UIExtensions
|
||||
}
|
||||
|
||||
UIEffect _uiEffect;
|
||||
Vector2 _factor;
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
static readonly List<UIVertex> s_Verts = new List<UIVertex>();
|
||||
|
||||
void UpdateFactor(float tone, float blur, Color color)
|
||||
{
|
||||
if (_uiEffect && _uiEffect.isActiveAndEnabled)
|
||||
{
|
||||
_factor = new Vector2(Packer.ToFloat(tone, 0, blur, 0), Packer.ToFloat(color.r, color.g, color.b, 1));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append shadow vertices.
|
||||
/// * It is similar to Shadow component implementation.
|
||||
@@ -186,28 +262,51 @@ namespace Coffee.UIExtensions
|
||||
void _ApplyShadowZeroAlloc(List<UIVertex> verts, Color color, ref int start, ref int end, float x, float y, bool useGraphicAlpha)
|
||||
{
|
||||
// Check list capacity.
|
||||
var neededCapacity = verts.Count + end - start;
|
||||
int count = end - start;
|
||||
var neededCapacity = verts.Count + count;
|
||||
if (verts.Capacity < neededCapacity)
|
||||
verts.Capacity = neededCapacity;
|
||||
|
||||
float normalizedIndex = ptex != null && _uiEffect && _uiEffect.isActiveAndEnabled
|
||||
? ptex.GetNormalizedIndex(this)
|
||||
: -1;
|
||||
|
||||
// Add
|
||||
UIVertex vt = default(UIVertex);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
verts.Add(vt);
|
||||
}
|
||||
|
||||
// Move
|
||||
for (int i = verts.Count - 1; count <= i; i--)
|
||||
{
|
||||
verts[i] = verts[i - count];
|
||||
}
|
||||
|
||||
// Append shadow vertices to the front of list.
|
||||
// * The original vertex is pushed backward.
|
||||
UIVertex vt;
|
||||
for (int i = start; i < end; ++i)
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
vt = verts[i];
|
||||
verts.Add(vt);
|
||||
vt = verts[i + start + count];
|
||||
|
||||
Vector3 v = vt.position;
|
||||
vt.position.Set(v.x + x, v.y + y, v.z);
|
||||
|
||||
Color vertColor = color;
|
||||
Color vertColor = effectColor;
|
||||
vertColor.a = useGraphicAlpha ? color.a * vt.color.a / 255 : color.a;
|
||||
vt.color = vertColor;
|
||||
|
||||
// Set UIEffect prameters to vertex.
|
||||
if(_uiEffect)
|
||||
vt.uv1 = _factor;
|
||||
|
||||
// Set UIEffect prameters
|
||||
if (0 <= normalizedIndex)
|
||||
{
|
||||
vt.uv0 = new Vector2(
|
||||
vt.uv0.x,
|
||||
normalizedIndex
|
||||
);
|
||||
}
|
||||
|
||||
verts[i] = vt;
|
||||
}
|
||||
|
||||
@@ -221,8 +320,44 @@ namespace Coffee.UIExtensions
|
||||
/// </summary>
|
||||
void _SetDirty()
|
||||
{
|
||||
if(graphic)
|
||||
if (graphic)
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
EditorApplication.delayCall += UpgradeIfNeeded;
|
||||
}
|
||||
|
||||
|
||||
#pragma warning disable 0612
|
||||
void UpgradeIfNeeded()
|
||||
{
|
||||
if (0 < m_AdditionalShadows.Count)
|
||||
{
|
||||
foreach (var s in m_AdditionalShadows)
|
||||
{
|
||||
if (s.style == ShadowStyle.None)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var shadow = gameObject.AddComponent<UIShadow>();
|
||||
shadow.style = s.style;
|
||||
shadow.effectDistance = s.effectDistance;
|
||||
shadow.effectColor = s.effectColor;
|
||||
shadow.useGraphicAlpha = s.useGraphicAlpha;
|
||||
shadow.blurFactor = s.blur;
|
||||
}
|
||||
m_AdditionalShadows = null;
|
||||
}
|
||||
}
|
||||
#pragma warning restore 0612
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,55 +16,91 @@ namespace Coffee.UIExtensions
|
||||
/// <summary>
|
||||
/// UIEffect.
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("UI/UIEffect/UIShiny", 2)]
|
||||
public class UIShiny : UIEffectBase
|
||||
{
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
public const string shaderName = "UI/Hidden/UI-Effect-Shiny";
|
||||
static readonly ParameterTexture _ptex = new ParameterTexture(8, 128, "_ParamTex");
|
||||
|
||||
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
[SerializeField] [Range(0, 1)] float m_Location = 0;
|
||||
[Tooltip("Location for shiny effect.")]
|
||||
[FormerlySerializedAs("m_Location")]
|
||||
[SerializeField] [Range(0, 1)] float m_EffectFactor = 0;
|
||||
|
||||
[Tooltip("Width for shiny effect.")]
|
||||
[SerializeField] [Range(0, 1)] float m_Width = 0.25f;
|
||||
|
||||
[Tooltip("Rotation for shiny effect.")]
|
||||
[SerializeField] [Range(-180, 180)] float m_Rotation;
|
||||
|
||||
[Tooltip("Softness for shiny effect.")]
|
||||
[SerializeField][Range(0.01f, 1)] float m_Softness = 1f;
|
||||
|
||||
[Tooltip("Brightness for shiny effect.")]
|
||||
[FormerlySerializedAs("m_Alpha")]
|
||||
[SerializeField][Range(0, 1)] float m_Brightness = 1f;
|
||||
[SerializeField][Range(0, 1)] float m_Highlight = 1;
|
||||
|
||||
[Tooltip("Gloss factor for shiny effect.")]
|
||||
[FormerlySerializedAs("m_Highlight")]
|
||||
[SerializeField][Range(0, 1)] float m_Gloss = 1;
|
||||
|
||||
[Tooltip("The area for effect.")]
|
||||
[SerializeField] protected EffectArea m_EffectArea;
|
||||
[Header("Play Effect")]
|
||||
|
||||
[SerializeField] EffectPlayer m_Player;
|
||||
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField] bool m_Play = false;
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField] bool m_Loop = false;
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField][Range(0.1f, 10)] float m_Duration = 1;
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField][Range(0, 10)] float m_LoopDelay = 1;
|
||||
[Obsolete][HideInInspector]
|
||||
[SerializeField] AnimatorUpdateMode m_UpdateMode = AnimatorUpdateMode.Normal;
|
||||
|
||||
|
||||
//################################
|
||||
// Public Members.
|
||||
//################################
|
||||
// /// <summary>
|
||||
// /// Graphic affected by the UIEffect.
|
||||
// /// </summary>
|
||||
// new public Graphic graphic { get { return base.graphic; } }
|
||||
|
||||
/// <summary>
|
||||
/// Location for shiny effect.
|
||||
/// Effect factor between 0(start) and 1(end).
|
||||
/// </summary>
|
||||
[System.Obsolete("Use effectFactor instead (UnityUpgradable) -> effectFactor")]
|
||||
public float location
|
||||
{
|
||||
get { return m_Location; }
|
||||
get { return m_EffectFactor; }
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 1);
|
||||
if (!Mathf.Approximately(m_Location, value))
|
||||
if (!Mathf.Approximately(m_EffectFactor, value))
|
||||
{
|
||||
m_Location = value;
|
||||
m_EffectFactor = value;
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effect factor between 0(start) and 1(end).
|
||||
/// </summary>
|
||||
public float effectFactor
|
||||
{
|
||||
get { return m_EffectFactor; }
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 1);
|
||||
if (!Mathf.Approximately(m_EffectFactor, value))
|
||||
{
|
||||
m_EffectFactor = value;
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
@@ -105,7 +141,7 @@ namespace Coffee.UIExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Alpha for shiny effect.
|
||||
/// Brightness for shiny effect.
|
||||
/// </summary>
|
||||
[System.Obsolete("Use brightness instead (UnityUpgradable) -> brightness")]
|
||||
public float alpha
|
||||
@@ -140,17 +176,35 @@ namespace Coffee.UIExtensions
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Highlight factor for shiny effect.
|
||||
/// Gloss factor for shiny effect.
|
||||
/// </summary>
|
||||
[System.Obsolete("Use gloss instead (UnityUpgradable) -> gloss")]
|
||||
public float highlight
|
||||
{
|
||||
get { return m_Highlight; }
|
||||
get { return m_Gloss; }
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 1);
|
||||
if (!Mathf.Approximately(m_Highlight, value))
|
||||
if (!Mathf.Approximately(m_Gloss, value))
|
||||
{
|
||||
m_Highlight = value;
|
||||
m_Gloss = value;
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gloss factor for shiny effect.
|
||||
/// </summary>
|
||||
public float gloss
|
||||
{
|
||||
get { return m_Gloss; }
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 1);
|
||||
if (!Mathf.Approximately(m_Gloss, value))
|
||||
{
|
||||
m_Gloss = value;
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
@@ -191,47 +245,51 @@ namespace Coffee.UIExtensions
|
||||
/// <summary>
|
||||
/// Play shinning on enable.
|
||||
/// </summary>
|
||||
public bool play { get { return m_Play; } set { m_Play = value; } }
|
||||
public bool play { get { return _player.play; } set { _player.play = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Play shinning loop.
|
||||
/// </summary>
|
||||
public bool loop { get { return m_Loop; } set { m_Loop = value; } }
|
||||
public bool loop { get { return _player.loop; } set { _player.loop = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Shinning duration.
|
||||
/// </summary>
|
||||
public float duration { get { return m_Duration; } set { m_Duration = Mathf.Max(value, 0.1f); } }
|
||||
public float duration { get { return _player.duration; } set { _player.duration = Mathf.Max(value, 0.1f); } }
|
||||
|
||||
/// <summary>
|
||||
/// Delay on loop.
|
||||
/// </summary>
|
||||
public float loopDelay { get { return m_LoopDelay; } set { m_LoopDelay = Mathf.Max(value, 0); } }
|
||||
public float loopDelay { get { return _player.loopDelay; } set { _player.loopDelay = Mathf.Max(value, 0); } }
|
||||
|
||||
/// <summary>
|
||||
/// Shinning update mode.
|
||||
/// </summary>
|
||||
public AnimatorUpdateMode updateMode { get { return m_UpdateMode; } set { m_UpdateMode = value; } }
|
||||
public AnimatorUpdateMode updateMode { get { return _player.updateMode; } set { _player.updateMode = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameter texture.
|
||||
/// </summary>
|
||||
public override ParameterTexture ptex { get { return _ptex; } }
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
_time = 0;
|
||||
// graphic.material = effectMaterial;
|
||||
base.OnEnable();
|
||||
_player.OnEnable(f => effectFactor = f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the behaviour becomes disabled () or inactive.
|
||||
/// </summary>
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
_player.OnDisable();
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// This function is called when the behaviour becomes disabled () or inactive.
|
||||
// /// </summary>
|
||||
// protected override void OnDisable()
|
||||
// {
|
||||
// graphic.material = null;
|
||||
// base.OnDisable();
|
||||
// }
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override Material GetMaterial()
|
||||
@@ -239,38 +297,21 @@ namespace Coffee.UIExtensions
|
||||
return MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName));
|
||||
}
|
||||
|
||||
// public void OnBeforeSerialize()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public void OnAfterDeserialize()
|
||||
// {
|
||||
// var obj = this;
|
||||
// EditorApplication.delayCall += () =>
|
||||
// {
|
||||
// if (Application.isPlaying || !obj)
|
||||
// return;
|
||||
//
|
||||
// var mat = GetMaterial(shaderName);
|
||||
// if (m_EffectMaterial == mat && graphic.material == mat)
|
||||
// return;
|
||||
//
|
||||
// graphic.material = m_EffectMaterial = mat;
|
||||
// EditorUtility.SetDirty(this);
|
||||
// EditorUtility.SetDirty(graphic);
|
||||
// EditorApplication.delayCall += AssetDatabase.SaveAssets;
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public static Material GetMaterial(string shaderName)
|
||||
// {
|
||||
// string name = Path.GetFileName(shaderName);
|
||||
// return AssetDatabase.FindAssets("t:Material " + name)
|
||||
// .Select(x => AssetDatabase.GUIDToAssetPath(x))
|
||||
// .SelectMany(x => AssetDatabase.LoadAllAssetsAtPath(x))
|
||||
// .OfType<Material>()
|
||||
// .FirstOrDefault(x => x.name == name);
|
||||
// }
|
||||
#pragma warning disable 0612
|
||||
protected override void UpgradeIfNeeded()
|
||||
{
|
||||
// Upgrade for v3.0.0
|
||||
if (IsShouldUpgrade(300))
|
||||
{
|
||||
_player.play = m_Play;
|
||||
_player.duration = m_Duration;
|
||||
_player.loop = m_Loop;
|
||||
_player.loopDelay = m_LoopDelay;
|
||||
_player.updateMode = m_UpdateMode;
|
||||
}
|
||||
}
|
||||
#pragma warning restore 0612
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
@@ -281,11 +322,13 @@ namespace Coffee.UIExtensions
|
||||
if (!isActiveAndEnabled)
|
||||
return;
|
||||
|
||||
float normalizedIndex = ptex.GetNormalizedIndex(this);
|
||||
|
||||
// rect.
|
||||
Rect rect = m_EffectArea.GetEffectArea(vh, graphic);
|
||||
|
||||
// rotation.
|
||||
float rad = rotation * Mathf.Deg2Rad;
|
||||
float rad = m_Rotation * Mathf.Deg2Rad;
|
||||
Vector2 dir = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad));
|
||||
dir.x *= rect.height / rect.width;
|
||||
dir = dir.normalized;
|
||||
@@ -300,13 +343,10 @@ namespace Coffee.UIExtensions
|
||||
{
|
||||
vh.PopulateUIVertex(ref vertex, i);
|
||||
|
||||
// Normalize vertex position by local matrix.
|
||||
nomalizedPos = localMatrix * vertex.position;
|
||||
|
||||
// Normalize vertex position by local matrix.
|
||||
if (effectEachCharacter)
|
||||
{
|
||||
// Each characters.
|
||||
nomalizedPos = localMatrix * splitedCharacterPosition[i % 4];
|
||||
}
|
||||
else
|
||||
@@ -314,9 +354,9 @@ namespace Coffee.UIExtensions
|
||||
nomalizedPos = localMatrix * vertex.position;
|
||||
}
|
||||
|
||||
vertex.uv1 = new Vector2(
|
||||
Packer.ToFloat(Mathf.Clamp01(nomalizedPos.y), softness, width, brightness),
|
||||
Packer.ToFloat(location, highlight)
|
||||
vertex.uv0 = new Vector2(
|
||||
Packer.ToFloat(vertex.uv0.x, vertex.uv0.y),
|
||||
Packer.ToFloat(nomalizedPos.y, normalizedIndex)
|
||||
);
|
||||
|
||||
vh.SetUIVertex(vertex, i);
|
||||
@@ -328,42 +368,38 @@ namespace Coffee.UIExtensions
|
||||
/// </summary>
|
||||
public void Play()
|
||||
{
|
||||
_time = 0;
|
||||
m_Play = true;
|
||||
_player.Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop effect.
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
_player.Stop();
|
||||
}
|
||||
|
||||
protected override void SetDirty()
|
||||
{
|
||||
ptex.RegisterMaterial(targetGraphic.material);
|
||||
ptex.SetData(this, 0, m_EffectFactor); // param1.x : location
|
||||
ptex.SetData(this, 1, m_Width); // param1.y : width
|
||||
ptex.SetData(this, 2, m_Softness); // param1.z : softness
|
||||
ptex.SetData(this, 3, m_Brightness);// param1.w : blightness
|
||||
ptex.SetData(this, 4, m_Gloss); // param2.x : gloss
|
||||
|
||||
if (!Mathf.Approximately(_lastRotation, m_Rotation) && targetGraphic)
|
||||
{
|
||||
_lastRotation = m_Rotation;
|
||||
targetGraphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
float _time = 0;
|
||||
float _lastRotation;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!m_Play || !Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_time += m_UpdateMode == AnimatorUpdateMode.UnscaledTime
|
||||
? Time.unscaledDeltaTime
|
||||
: Time.deltaTime;
|
||||
location = _time / m_Duration;
|
||||
|
||||
if (m_Duration <= _time)
|
||||
{
|
||||
m_Play = m_Loop;
|
||||
_time = m_Loop ? -m_LoopDelay : 0;
|
||||
}
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Mark the UIEffect as dirty.
|
||||
// /// </summary>
|
||||
// void _SetDirty()
|
||||
// {
|
||||
// if (graphic)
|
||||
// graphic.SetVerticesDirty();
|
||||
// }
|
||||
EffectPlayer _player{ get { return m_Player ?? (m_Player = new EffectPlayer()); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,33 +6,58 @@ namespace Coffee.UIExtensions
|
||||
/// <summary>
|
||||
/// Transition effect.
|
||||
/// </summary>
|
||||
[AddComponentMenu("UI/UIEffect/UITransitionEffect", 5)]
|
||||
public class UITransitionEffect : UIEffectBase
|
||||
{
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
public const string shaderName = "UI/Hidden/UI-Effect-Transition";
|
||||
static readonly ParameterTexture _ptex = new ParameterTexture(8, 128, "_ParamTex");
|
||||
|
||||
/// <summary>
|
||||
/// Effect mode.
|
||||
/// </summary>
|
||||
public enum EffectMode
|
||||
{
|
||||
None = 0,
|
||||
Fade = 1,
|
||||
Cutoff = 2,
|
||||
Dissolve = 3,
|
||||
}
|
||||
|
||||
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
[SerializeField] EffectMode m_EffectMode;
|
||||
[Tooltip("Effect mode.")]
|
||||
[SerializeField] EffectMode m_EffectMode = EffectMode.Cutoff;
|
||||
|
||||
[Tooltip("Effect factor between 0(hidden) and 1(shown).")]
|
||||
[SerializeField][Range(0, 1)] float m_EffectFactor = 1;
|
||||
|
||||
[Tooltip("Transition texture (single channel texture).")]
|
||||
[SerializeField] Texture m_TransitionTexture;
|
||||
[SerializeField] EffectArea m_EffectArea;
|
||||
|
||||
[Tooltip("The area for effect.")]
|
||||
[SerializeField] EffectArea m_EffectArea = EffectArea.RectTransform;
|
||||
|
||||
[Tooltip("Keep effect aspect ratio.")]
|
||||
[SerializeField] bool m_KeepAspectRatio;
|
||||
|
||||
[Tooltip("Dissolve edge width.")]
|
||||
[SerializeField] [Range(0, 1)] float m_DissolveWidth = 0.5f;
|
||||
|
||||
[Tooltip("Dissolve edge softness.")]
|
||||
[SerializeField] [Range(0, 1)] float m_DissolveSoftness = 0.5f;
|
||||
|
||||
[Tooltip("Dissolve edge color.")]
|
||||
[SerializeField] [ColorUsage(false)] Color m_DissolveColor = new Color(0.0f, 0.25f, 1.0f);
|
||||
|
||||
[Tooltip("Disable graphic's raycast target on hidden.")]
|
||||
[SerializeField] bool m_PassRayOnHidden;
|
||||
|
||||
[Header("Effect Player")]
|
||||
[SerializeField] EffectPlayer m_Player;
|
||||
|
||||
//################################
|
||||
// Public Members.
|
||||
@@ -89,17 +114,105 @@ namespace Coffee.UIExtensions
|
||||
if (m_KeepAspectRatio != value)
|
||||
{
|
||||
m_KeepAspectRatio = value;
|
||||
targetGraphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parameter texture.
|
||||
/// </summary>
|
||||
public override ParameterTexture ptex { get { return _ptex; } }
|
||||
|
||||
/// <summary>
|
||||
/// Dissolve edge width.
|
||||
/// </summary>
|
||||
public float dissolveWidth
|
||||
{
|
||||
get { return m_DissolveWidth; }
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 1);
|
||||
if (!Mathf.Approximately(m_DissolveWidth, value))
|
||||
{
|
||||
m_DissolveWidth = value;
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dissolve edge softness.
|
||||
/// </summary>
|
||||
public float dissolveSoftness
|
||||
{
|
||||
get { return m_DissolveSoftness; }
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 1);
|
||||
if (!Mathf.Approximately(m_DissolveSoftness, value))
|
||||
{
|
||||
m_DissolveSoftness = value;
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dissolve edge color.
|
||||
/// </summary>
|
||||
public Color dissolveColor
|
||||
{
|
||||
get { return m_DissolveColor; }
|
||||
set
|
||||
{
|
||||
if (m_DissolveColor != value)
|
||||
{
|
||||
m_DissolveColor = value;
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Duration for showing/hiding.
|
||||
/// </summary>
|
||||
public float duration { get { return _player.duration; } set { _player.duration = Mathf.Max(value, 0.1f); } }
|
||||
|
||||
/// <summary>
|
||||
/// Disable graphic's raycast target on hidden.
|
||||
/// </summary>
|
||||
public bool passRayOnHidden { get { return m_PassRayOnHidden; } set { m_PassRayOnHidden = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Update mode for showing/hiding.
|
||||
/// </summary>
|
||||
public AnimatorUpdateMode updateMode { get { return _player.updateMode; } set { _player.updateMode = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Show transition.
|
||||
/// </summary>
|
||||
public void Show()
|
||||
{
|
||||
_player.loop = false;
|
||||
_player.Play(f => effectFactor = f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hide transition.
|
||||
/// </summary>
|
||||
public void Hide()
|
||||
{
|
||||
_player.loop = false;
|
||||
_player.Play(f => effectFactor = 1 - f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modifies the material.
|
||||
/// </summary>
|
||||
public override void ModifyMaterial()
|
||||
{
|
||||
ulong hash = (m_TransitionTexture ? (uint)m_TransitionTexture.GetInstanceID() : 0) + (uint)m_EffectMode;
|
||||
ulong hash = (m_TransitionTexture ? (uint)m_TransitionTexture.GetInstanceID() : 0) + ((ulong)2 << 32) + ((ulong)m_EffectMode << 36);
|
||||
if (_materialCache != null && (_materialCache.hash != hash || !isActiveAndEnabled || !m_EffectMaterial))
|
||||
{
|
||||
MaterialCache.Unregister(_materialCache);
|
||||
@@ -123,6 +236,7 @@ namespace Coffee.UIExtensions
|
||||
_materialCache = MaterialCache.Register(hash, m_TransitionTexture, () =>
|
||||
{
|
||||
var mat = new Material(m_EffectMaterial);
|
||||
mat.name += "_" + m_TransitionTexture.name;
|
||||
mat.SetTexture("_TransitionTexture", m_TransitionTexture);
|
||||
return mat;
|
||||
});
|
||||
@@ -135,7 +249,7 @@ namespace Coffee.UIExtensions
|
||||
/// </summary>
|
||||
public override void ModifyMesh(VertexHelper vh)
|
||||
{
|
||||
if (!isActiveAndEnabled || m_EffectMode == EffectMode.None)
|
||||
if (!isActiveAndEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -146,41 +260,77 @@ namespace Coffee.UIExtensions
|
||||
Rect rect = m_EffectArea.GetEffectArea(vh, graphic, aspectRatio);
|
||||
|
||||
// Set prameters to vertex.
|
||||
float normalizedIndex = ptex.GetNormalizedIndex(this);
|
||||
UIVertex vertex = default(UIVertex);
|
||||
bool effectEachCharacter = graphic is Text && m_EffectArea == EffectArea.Character;
|
||||
float x, y;
|
||||
for (int i = 0; i < vh.currentVertCount; i++)
|
||||
int count = vh.currentVertCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
vh.PopulateUIVertex(ref vertex, i);
|
||||
|
||||
if (effectEachCharacter)
|
||||
{
|
||||
x = splitedCharacterPosition[i%4].x;
|
||||
y = splitedCharacterPosition[i%4].y;
|
||||
x = splitedCharacterPosition[i % 4].x;
|
||||
y = splitedCharacterPosition[i % 4].y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = Mathf.Clamp01(vertex.position.x / rect.width + 0.5f);
|
||||
y = Mathf.Clamp01(vertex.position.y / rect.height + 0.5f);
|
||||
}
|
||||
vertex.uv1 = new Vector2(
|
||||
effectFactor,
|
||||
Packer.ToFloat (x, y)
|
||||
);
|
||||
|
||||
vertex.uv0 = new Vector2(
|
||||
Packer.ToFloat(vertex.uv0.x, vertex.uv0.y),
|
||||
Packer.ToFloat(x, y, normalizedIndex)
|
||||
);
|
||||
vh.SetUIVertex(vertex, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//################################
|
||||
// Protected Members.
|
||||
//################################
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
_player.OnEnable(null);
|
||||
_player.loop = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the behaviour becomes disabled () or inactive.
|
||||
/// </summary>
|
||||
protected override void OnDisable()
|
||||
{
|
||||
MaterialCache.Unregister(_materialCache);
|
||||
_materialCache = null;
|
||||
base.OnDisable();
|
||||
_player.OnDisable();
|
||||
}
|
||||
|
||||
protected override void SetDirty()
|
||||
{
|
||||
ptex.RegisterMaterial(targetGraphic.material);
|
||||
ptex.SetData(this, 0, m_EffectFactor); // param1.x : effect factor
|
||||
if (m_EffectMode == EffectMode.Dissolve)
|
||||
{
|
||||
ptex.SetData(this, 1, m_DissolveWidth); // param1.y : width
|
||||
ptex.SetData(this, 2, m_DissolveSoftness); // param1.z : softness
|
||||
ptex.SetData(this, 4, m_DissolveColor.r); // param2.x : red
|
||||
ptex.SetData(this, 5, m_DissolveColor.g); // param2.y : green
|
||||
ptex.SetData(this, 6, m_DissolveColor.b); // param2.z : blue
|
||||
}
|
||||
|
||||
// Disable graphic's raycastTarget on hidden.
|
||||
if (m_PassRayOnHidden)
|
||||
{
|
||||
graphic.raycastTarget = 0 < m_EffectFactor;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
@@ -190,9 +340,7 @@ namespace Coffee.UIExtensions
|
||||
/// <returns>The material.</returns>
|
||||
protected override Material GetMaterial()
|
||||
{
|
||||
return m_EffectMode != EffectMode.None
|
||||
? MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName), m_EffectMode)
|
||||
: null;
|
||||
return MaterialResolver.GetOrGenerateMaterialVariant(Shader.Find(shaderName), m_EffectMode);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -200,5 +348,7 @@ namespace Coffee.UIExtensions
|
||||
// Private Members.
|
||||
//################################
|
||||
MaterialCache _materialCache = null;
|
||||
|
||||
EffectPlayer _player{ get { return m_Player ?? (m_Player = new EffectPlayer()); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 922b805bc01c243e5853d9cbb544118c
|
||||
timeCreated: 1485321967
|
||||
timeCreated: 1538827562
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
defaultReferences:
|
||||
- m_EffectMaterial: {instanceID: 0}
|
||||
- m_PtexMaterial: {instanceID: 0}
|
||||
- m_TransitionTexture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de,
|
||||
type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
|
||||
@@ -15,6 +15,8 @@ Shader "UI/Hidden/UI-Effect-Dissolve"
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
|
||||
_ParamTex ("Parameter Texture", 2D) = "white" {}
|
||||
|
||||
[Header(Dissolve)]
|
||||
_NoiseTex("Noise Texture (A)", 2D) = "white" {}
|
||||
}
|
||||
@@ -68,8 +70,6 @@ Shader "UI/Hidden/UI-Effect-Dissolve"
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
|
||||
float2 uv1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
@@ -79,9 +79,8 @@ Shader "UI/Hidden/UI-Effect-Dissolve"
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
|
||||
fixed4 effectFactor : TEXCOORD2;
|
||||
fixed4 effectFactor2 : TEXCOORD3;
|
||||
|
||||
half3 param : TEXCOORD2;
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
@@ -89,7 +88,8 @@ Shader "UI/Hidden/UI-Effect-Dissolve"
|
||||
float4 _ClipRect;
|
||||
sampler2D _MainTex;
|
||||
sampler2D _NoiseTex;
|
||||
|
||||
sampler2D _ParamTex;
|
||||
|
||||
v2f vert(appdata_t IN)
|
||||
{
|
||||
v2f OUT;
|
||||
@@ -103,32 +103,33 @@ Shader "UI/Hidden/UI-Effect-Dissolve"
|
||||
|
||||
OUT.color = IN.color * _Color;
|
||||
|
||||
//xy: Noize uv, z: Dissolve factor, w: width
|
||||
OUT.effectFactor = UnpackToVec4(IN.uv1.x);
|
||||
|
||||
//xyz: color, w: softness
|
||||
OUT.effectFactor2 = UnpackToVec4(IN.uv1.y);
|
||||
OUT.texcoord = UnpackToVec2(IN.texcoord.x);
|
||||
OUT.param = UnpackToVec3(IN.texcoord.y);
|
||||
return OUT;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
fixed4 param1 = tex2D(_ParamTex, float2(0.25, IN.param.z));
|
||||
fixed location = param1.x;
|
||||
fixed width = param1.y/4;
|
||||
fixed softness = param1.z;
|
||||
fixed3 dissolveColor = tex2D(_ParamTex, float2(0.75, IN.param.z)).rgb;
|
||||
float cutout = tex2D(_NoiseTex, IN.param.xy).a;
|
||||
|
||||
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
|
||||
|
||||
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
|
||||
float cutout = tex2D(_NoiseTex, IN.effectFactor.xy).a;
|
||||
float location = IN.effectFactor.z;
|
||||
float width = IN.effectFactor.w/4;
|
||||
float factor = cutout - location * ( 1 + width ) + width;
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip (min(color.a - 0.01, factor));
|
||||
#endif
|
||||
|
||||
fixed edgeLerp = step(factor, color.a) * saturate((width - factor)*16/ IN.effectFactor2.w);
|
||||
color = ApplyColorEffect(color, fixed4(IN.effectFactor2.rgb, edgeLerp));
|
||||
color.a *= saturate((factor)*32/ IN.effectFactor2.w);
|
||||
fixed edgeLerp = step(factor, color.a) * saturate((width - factor)*16/ softness);
|
||||
color = ApplyColorEffect(color, fixed4(dissolveColor, edgeLerp));
|
||||
color.a *= saturate((factor)*32/ softness);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
|
||||
_ParamTex ("Parameter Texture", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
@@ -56,15 +58,14 @@
|
||||
sampler2D _MainTex;
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
|
||||
sampler2D _ParamTex;
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
|
||||
float2 uv1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
@@ -74,9 +75,8 @@
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 wpos : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
|
||||
half4 range : TEXCOORD2;
|
||||
half3 hsv : TEXCOORD3;
|
||||
|
||||
half param : TEXCOORD2;
|
||||
};
|
||||
|
||||
|
||||
@@ -91,9 +91,8 @@
|
||||
OUT.texcoord = IN.texcoord;
|
||||
OUT.color = IN.color;
|
||||
|
||||
OUT.range = UnpackToVec4(IN.uv1.x);
|
||||
OUT.hsv = UnpackToVec3(IN.uv1.y) - 0.5f;
|
||||
OUT.hsv.yz *= 2;
|
||||
OUT.texcoord = UnpackToVec2(IN.texcoord.x);
|
||||
OUT.param = IN.texcoord.y;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
@@ -117,6 +116,12 @@
|
||||
|
||||
fixed4 frag(v2f IN) : COLOR
|
||||
{
|
||||
fixed4 param1 = tex2D(_ParamTex, float2(0.25, IN.param));
|
||||
fixed4 param2 = tex2D(_ParamTex, float2(0.75, IN.param));
|
||||
fixed3 targetHsv = param1.rgb;
|
||||
fixed3 targetRange = param1.w;
|
||||
fixed3 hsvShift = param2.xyz - 0.5;
|
||||
|
||||
half4 color = tex2D(_MainTex, IN.texcoord);// + _TextureSampleAdd) * IN.color;
|
||||
|
||||
color.a *= UnityGet2DClipping(IN.wpos.xy, _ClipRect);
|
||||
@@ -126,11 +131,11 @@
|
||||
#endif
|
||||
|
||||
half3 hsv = rgb2hsv(color.rgb);
|
||||
half3 range = abs(hsv - IN.range.xyz);
|
||||
half3 range = abs(hsv - targetHsv);
|
||||
half diff = max(max(min(1-range.x, range.x), min(1-range.y, range.y)/10), min(1-range.z, range.z)/10);
|
||||
|
||||
fixed masked = step(diff, IN.range.w);
|
||||
color.rgb = hsv2rgb(hsv + IN.hsv.xyz * masked);
|
||||
fixed masked = step(diff, targetRange);
|
||||
color.rgb = hsv2rgb(hsv + hsvShift * masked);
|
||||
|
||||
return (color + _TextureSampleAdd) * IN.color;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ Shader "UI/Hidden/UI-Effect-Shiny"
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
|
||||
_ParamTex ("Parameter Texture", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
@@ -56,15 +58,14 @@ Shader "UI/Hidden/UI-Effect-Shiny"
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
#include "UI-Effect.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
|
||||
float2 uv1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
@@ -74,9 +75,8 @@ Shader "UI/Hidden/UI-Effect-Shiny"
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
|
||||
half4 effectFactor : TEXCOORD2;
|
||||
half2 effectFactor2 : TEXCOORD3;
|
||||
|
||||
half2 param : TEXCOORD2;
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
@@ -84,38 +84,7 @@ Shader "UI/Hidden/UI-Effect-Shiny"
|
||||
float4 _ClipRect;
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
fixed4 UnpackToVec4(float value)
|
||||
{
|
||||
const int PACKER_STEP = 64;
|
||||
const int PRECISION = PACKER_STEP - 1;
|
||||
fixed4 color;
|
||||
|
||||
color.r = (value % PACKER_STEP) / PRECISION;
|
||||
value = floor(value / PACKER_STEP);
|
||||
|
||||
color.g = (value % PACKER_STEP) / PRECISION;
|
||||
value = floor(value / PACKER_STEP);
|
||||
|
||||
color.b = (value % PACKER_STEP) / PRECISION;
|
||||
value = floor(value / PACKER_STEP);
|
||||
|
||||
color.a = (value % PACKER_STEP) / PRECISION;
|
||||
return color;
|
||||
}
|
||||
|
||||
half2 UnpackToVec2(float value)
|
||||
{
|
||||
const int PACKER_STEP = 4096;
|
||||
const int PRECISION = PACKER_STEP - 1;
|
||||
fixed4 color;
|
||||
|
||||
color.x = (value % PACKER_STEP) / PRECISION;
|
||||
value = floor(value / PACKER_STEP);
|
||||
|
||||
color.y = (value % PACKER_STEP) / PRECISION;
|
||||
return color;
|
||||
}
|
||||
sampler2D _ParamTex;
|
||||
|
||||
v2f vert(appdata_t IN)
|
||||
{
|
||||
@@ -126,19 +95,25 @@ Shader "UI/Hidden/UI-Effect-Shiny"
|
||||
|
||||
OUT.vertex = UnityObjectToClipPos(IN.vertex);
|
||||
|
||||
OUT.texcoord = IN.texcoord;
|
||||
|
||||
OUT.color = IN.color * _Color;
|
||||
|
||||
OUT.effectFactor = UnpackToVec4(IN.uv1.x);
|
||||
OUT.effectFactor2 = UnpackToVec2(IN.uv1.y);
|
||||
|
||||
OUT.effectFactor2.x = OUT.effectFactor2.x * 2 - 0.5;
|
||||
OUT.texcoord = UnpackToVec2(IN.texcoord.x);
|
||||
OUT.param = UnpackToVec2(IN.texcoord.y);
|
||||
return OUT;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
fixed nomalizedPos = IN.param.x;
|
||||
|
||||
fixed4 param1 = tex2D(_ParamTex, float2(0.25, IN.param.y));
|
||||
fixed4 param2 = tex2D(_ParamTex, float2(0.75, IN.param.y));
|
||||
half location = param1.x * 2 - 0.5;
|
||||
fixed width = param1.y;
|
||||
fixed softness = param1.z;
|
||||
fixed brightness = param1.w;
|
||||
fixed gloss = param2.x;
|
||||
|
||||
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd);
|
||||
fixed4 originAlpha = color.a;
|
||||
color *= IN.color;
|
||||
@@ -148,13 +123,11 @@ Shader "UI/Hidden/UI-Effect-Shiny"
|
||||
clip (color.a - 0.001);
|
||||
#endif
|
||||
|
||||
half pos = IN.effectFactor.x - IN.effectFactor2.x;
|
||||
half normalized = 1 - saturate(abs((nomalizedPos - location) / width));
|
||||
half shinePower = smoothstep(0, softness*2, normalized);
|
||||
half3 reflectColor = lerp(1, color.rgb * 10, gloss);
|
||||
|
||||
half normalized = 1 - saturate(abs(pos / IN.effectFactor.z));
|
||||
half shinePower = smoothstep(0, IN.effectFactor.y*2, normalized);
|
||||
half3 reflectColor = lerp(1, color.rgb * 10, IN.effectFactor2.y);
|
||||
|
||||
color.rgb += originAlpha * (shinePower / 2) * IN.effectFactor.w * reflectColor;
|
||||
color.rgb += originAlpha * (shinePower / 2) * brightness * reflectColor;
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@@ -17,6 +17,7 @@ Shader "UI/Hidden/UI-Effect-Transition"
|
||||
|
||||
[Header(Transition)]
|
||||
_TransitionTexture("Transition Texture (A)", 2D) = "white" {}
|
||||
_ParamTex ("Parameter Texture", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
@@ -56,8 +57,8 @@ Shader "UI/Hidden/UI-Effect-Transition"
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
#pragma shader_feature __ FADE CUTOFF
|
||||
|
||||
#pragma shader_feature __ FADE CUTOFF DISSOLVE
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "UI-Effect.cginc"
|
||||
@@ -67,7 +68,6 @@ Shader "UI/Hidden/UI-Effect-Transition"
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
half2 factor : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ Shader "UI/Hidden/UI-Effect-Transition"
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 wpos : TEXCOORD1;
|
||||
half3 factor : TEXCOORD2;
|
||||
half3 param : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
@@ -86,6 +86,7 @@ Shader "UI/Hidden/UI-Effect-Transition"
|
||||
float4 _ClipRect;
|
||||
sampler2D _MainTex;
|
||||
sampler2D _TransitionTexture;
|
||||
sampler2D _ParamTex;
|
||||
|
||||
v2f vert(appdata_t IN)
|
||||
{
|
||||
@@ -95,10 +96,10 @@ Shader "UI/Hidden/UI-Effect-Transition"
|
||||
OUT.wpos = IN.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(OUT.wpos);
|
||||
|
||||
OUT.texcoord = IN.texcoord;
|
||||
OUT.texcoord = UnpackToVec2(IN.texcoord.x);
|
||||
OUT.param = UnpackToVec3(IN.texcoord.y);
|
||||
|
||||
OUT.color = IN.color * _Color;
|
||||
OUT.factor = half3(IN.factor.x, UnpackToVec2(IN.factor.y));
|
||||
|
||||
return OUT;
|
||||
}
|
||||
@@ -106,24 +107,37 @@ Shader "UI/Hidden/UI-Effect-Transition"
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
half effectFactor = IN.factor.x;
|
||||
half alpha = tex2D(_TransitionTexture, IN.factor.yz).a;
|
||||
|
||||
fixed4 param1 = tex2D(_ParamTex, float2(0.25, IN.param.z));
|
||||
fixed effectFactor = param1.x;
|
||||
float alpha = tex2D(_TransitionTexture, IN.param.xy).a;
|
||||
|
||||
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd);
|
||||
color.a *= UnityGet2DClipping(IN.wpos.xy, _ClipRect);
|
||||
|
||||
#if FADE
|
||||
color.a = color.a * alpha + (effectFactor * 2 - 1);
|
||||
color.a *= step(0.001, color.a);
|
||||
color.a *= saturate(alpha + (effectFactor * 2 - 1));
|
||||
#elif CUTOFF
|
||||
color.a = step(0.001, color.a * alpha - 1 + effectFactor);
|
||||
color.a *= step(0.001, color.a * alpha - 1 + effectFactor);
|
||||
#elif DISSOLVE
|
||||
|
||||
fixed width = param1.y/4;
|
||||
fixed softness = param1.z;
|
||||
fixed3 dissolveColor = tex2D(_ParamTex, float2(0.75, IN.param.z)).rgb;
|
||||
float factor = alpha - (1 - effectFactor) * ( 1 + width ) + width;
|
||||
|
||||
fixed edgeLerp = step(factor, color.a) * saturate((width - factor)*16/ softness);
|
||||
color.rgb += dissolveColor.rgb * edgeLerp;
|
||||
color.a *= saturate((factor)*32/ softness);
|
||||
|
||||
#endif
|
||||
|
||||
color *= IN.color;
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip (color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color * IN.color;
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
@@ -64,41 +64,67 @@ half2 UnpackToVec2(float value)
|
||||
return unpacked;
|
||||
}
|
||||
|
||||
// Sample texture with blurring.
|
||||
// * Fast: Sample texture with 3x3 kernel.
|
||||
// * Medium: Sample texture with 5x5 kernel.
|
||||
// * Detail: Sample texture with 7x7 kernel.
|
||||
fixed4 Tex2DBlurring (sampler2D tex, half2 texcood, half2 blur, half4 mask)
|
||||
{
|
||||
#if FASTBLUR && EX
|
||||
const int KERNEL_SIZE = 5;
|
||||
const float KERNEL_[5] = { 0.2486, 0.7046, 1.0, 0.7046, 0.2486};
|
||||
#elif MEDIUMBLUR && EX
|
||||
const int KERNEL_SIZE = 9;
|
||||
const float KERNEL_[9] = { 0.0438, 0.1719, 0.4566, 0.8204, 1.0, 0.8204, 0.4566, 0.1719, 0.0438};
|
||||
#elif DETAILBLUR && EX
|
||||
const int KERNEL_SIZE = 13;
|
||||
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};
|
||||
#elif FASTBLUR
|
||||
const int KERNEL_SIZE = 3;
|
||||
const float KERNEL_[3] = { 0.4566, 1.0, 0.4566};
|
||||
#elif MEDIUMBLUR
|
||||
const int KERNEL_SIZE = 5;
|
||||
const float KERNEL_[5] = { 0.2486, 0.7046, 1.0, 0.7046, 0.2486};
|
||||
#elif DETAILBLUR
|
||||
const int KERNEL_SIZE = 7;
|
||||
const float KERNEL_[7] = { 0.1719, 0.4566, 0.8204, 1.0, 0.8204, 0.4566, 0.1719};
|
||||
#else
|
||||
const int KERNEL_SIZE = 1;
|
||||
const float KERNEL_[1] = { 1.0 };
|
||||
#endif
|
||||
float4 o = 0;
|
||||
float sum = 0;
|
||||
float2 shift = 0;
|
||||
for(int x = 0; x < KERNEL_SIZE; x++)
|
||||
{
|
||||
shift.x = blur.x * (float(x) - KERNEL_SIZE/2);
|
||||
for(int y = 0; y < KERNEL_SIZE; y++)
|
||||
{
|
||||
shift.y = blur.y * (float(y) - KERNEL_SIZE/2);
|
||||
float2 uv = texcood + shift;
|
||||
float weight = KERNEL_[x] * KERNEL_[y];
|
||||
sum += weight;
|
||||
#if EX
|
||||
fixed masked = min(mask.x <= uv.x, uv.x <= mask.z) * min(mask.y <= uv.y, uv.y <= mask.w);
|
||||
o += lerp(fixed4(0.5, 0.5, 0.5, 0), tex2D(tex, uv), masked) * weight;
|
||||
#else
|
||||
o += tex2D(tex, uv) * weight;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return o / sum;
|
||||
}
|
||||
|
||||
// Sample texture with blurring.
|
||||
// * Fast: Sample texture with 3x3 kernel.
|
||||
// * Medium: Sample texture with 5x5 kernel.
|
||||
// * Detail: Sample texture with 7x7 kernel.
|
||||
fixed4 Tex2DBlurring (sampler2D tex, half2 uv, half2 blur)
|
||||
fixed4 Tex2DBlurring (sampler2D tex, half2 texcood, half2 blur)
|
||||
{
|
||||
#if FASTBLUR
|
||||
const int KERNEL_SIZE = 3;
|
||||
#elif MEDIUMBLUR
|
||||
const int KERNEL_SIZE = 5;
|
||||
#elif DETAILBLUR
|
||||
const int KERNEL_SIZE = 7;
|
||||
#else
|
||||
const int KERNEL_SIZE = 1;
|
||||
#endif
|
||||
float4 o = 0;
|
||||
float sum = 0;
|
||||
float weight;
|
||||
half2 texcood;
|
||||
for(int x = -KERNEL_SIZE/2; x <= KERNEL_SIZE/2; x++)
|
||||
{
|
||||
for(int y = -KERNEL_SIZE/2; y <= KERNEL_SIZE/2; y++)
|
||||
{
|
||||
texcood = uv;
|
||||
texcood.x += blur.x * x;
|
||||
texcood.y += blur.y * y;
|
||||
weight = 1.0/(abs(x)+abs(y)+2);
|
||||
o += tex2D(tex, texcood)*weight;
|
||||
sum += weight;
|
||||
}
|
||||
}
|
||||
return o / sum;
|
||||
return Tex2DBlurring(tex, texcood, blur, half4(0,0,1,1));
|
||||
}
|
||||
|
||||
|
||||
// Sample texture with blurring.
|
||||
// * Fast: Sample texture with 3x1 kernel.
|
||||
// * Medium: Sample texture with 5x1 kernel.
|
||||
|
||||
@@ -14,6 +14,8 @@ Shader "UI/Hidden/UI-Effect"
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
|
||||
_ParamTex ("Parameter Texture", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
@@ -58,9 +60,10 @@ Shader "UI/Hidden/UI-Effect"
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
#pragma shader_feature __ GRAYSCALE SEPIA NEGA PIXEL MONO CUTOFF HUE
|
||||
#pragma shader_feature __ GRAYSCALE SEPIA NEGA PIXEL
|
||||
#pragma shader_feature __ ADD SUBTRACT FILL
|
||||
#pragma shader_feature __ FASTBLUR MEDIUMBLUR DETAILBLUR
|
||||
#pragma shader_feature __ EX
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
@@ -73,7 +76,9 @@ Shader "UI/Hidden/UI-Effect"
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
|
||||
float2 uv1 : TEXCOORD1;
|
||||
#if defined(EX)
|
||||
float2 uvMask : TEXCOORD1;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct v2f
|
||||
@@ -83,16 +88,11 @@ Shader "UI/Hidden/UI-Effect"
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
|
||||
#if defined (UI_COLOR)
|
||||
fixed4 colorFactor : COLOR1;
|
||||
#endif
|
||||
|
||||
#if defined (UI_TONE) || defined (UI_BLUR)
|
||||
half4 effectFactor : TEXCOORD2;
|
||||
#endif
|
||||
#if HUE || PIXEL
|
||||
half2 extraFactor : TEXCOORD3;
|
||||
half param : TEXCOORD2;
|
||||
|
||||
#if defined(EX)
|
||||
half4 uvMask : TEXCOORD3;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -101,6 +101,7 @@ Shader "UI/Hidden/UI-Effect"
|
||||
float4 _ClipRect;
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize;
|
||||
sampler2D _ParamTex;
|
||||
|
||||
v2f vert(appdata_t IN)
|
||||
{
|
||||
@@ -110,23 +111,15 @@ Shader "UI/Hidden/UI-Effect"
|
||||
OUT.worldPosition = IN.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
||||
|
||||
OUT.texcoord = IN.texcoord;
|
||||
|
||||
OUT.color = IN.color * _Color;
|
||||
|
||||
#if defined (UI_TONE) || defined (UI_BLUR)
|
||||
OUT.effectFactor = UnpackToVec4(IN.uv1.x);
|
||||
#endif
|
||||
OUT.texcoord = UnpackToVec2(IN.texcoord.x) * 2 - 0.5;
|
||||
|
||||
#if HUE
|
||||
OUT.extraFactor.x = cos(OUT.effectFactor.x*3.14159265359 * 2);
|
||||
OUT.extraFactor.y = sin(OUT.effectFactor.x*3.14159265359 * 2);
|
||||
#elif PIXEL
|
||||
OUT.extraFactor.xy = max(2, (1-OUT.effectFactor.x*0.98) * _MainTex_TexelSize.zw);
|
||||
#endif
|
||||
|
||||
#if defined (UI_COLOR)
|
||||
OUT.colorFactor = UnpackToVec4(IN.uv1.y);
|
||||
OUT.param = IN.texcoord.y;
|
||||
|
||||
#if defined(EX)
|
||||
OUT.uvMask.xy = UnpackToVec2(IN.uvMask.x);
|
||||
OUT.uvMask.zw = UnpackToVec2(IN.uvMask.y);
|
||||
#endif
|
||||
|
||||
return OUT;
|
||||
@@ -135,35 +128,36 @@ Shader "UI/Hidden/UI-Effect"
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
fixed4 param = tex2D(_ParamTex, float2(0.5, IN.param));
|
||||
fixed effectFactor = param.x;
|
||||
fixed colorFactor = param.y;
|
||||
fixed blurFactor = param.z;
|
||||
|
||||
#if PIXEL
|
||||
IN.texcoord = round(IN.texcoord * IN.extraFactor.xy) / IN.extraFactor.xy;
|
||||
half2 pixelSize = max(2, (1-effectFactor*0.95) * _MainTex_TexelSize.zw);
|
||||
IN.texcoord = round(IN.texcoord * pixelSize) / pixelSize;
|
||||
#endif
|
||||
|
||||
#if defined (UI_BLUR)
|
||||
half4 color = (Tex2DBlurring(_MainTex, IN.texcoord, IN.effectFactor.z * _MainTex_TexelSize.xy * 2) + _TextureSampleAdd) * IN.color;
|
||||
#if defined(UI_BLUR) && EX
|
||||
half4 color = (Tex2DBlurring(_MainTex, IN.texcoord, blurFactor * _MainTex_TexelSize.xy * 2, IN.uvMask) + _TextureSampleAdd);
|
||||
#elif defined(UI_BLUR)
|
||||
half4 color = (Tex2DBlurring(_MainTex, IN.texcoord, blurFactor * _MainTex_TexelSize.xy * 2) + _TextureSampleAdd);
|
||||
#else
|
||||
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
|
||||
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd);
|
||||
#endif
|
||||
|
||||
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
|
||||
#ifdef CUTOFF
|
||||
clip (color.a - 1 + IN.effectFactor.x * 1.001);
|
||||
#elif UNITY_UI_ALPHACLIP
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip (color.a - 0.001);
|
||||
#endif
|
||||
|
||||
#if MONO
|
||||
color.rgb = IN.color.rgb;
|
||||
color.a = color.a * tex2D(_MainTex, IN.texcoord).a + IN.effectFactor.x * 2 - 1;
|
||||
#elif HUE
|
||||
color.rgb = shift_hue(color.rgb, IN.extraFactor.x, IN.extraFactor.y);
|
||||
#elif defined (UI_TONE) & !CUTOFF
|
||||
color = ApplyToneEffect(color, IN.effectFactor.x);
|
||||
#if defined (UI_TONE)
|
||||
color = ApplyToneEffect(color, effectFactor);
|
||||
#endif
|
||||
|
||||
#if defined (UI_COLOR)
|
||||
color = ApplyColorEffect(color, IN.colorFactor) * IN.color;
|
||||
#endif
|
||||
color = ApplyColorEffect(color, fixed4(IN.color.rgb, colorFactor));
|
||||
color.a *= IN.color.a;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2381d5cb31034d1fbcdb9c1e70fad2d
|
||||
folderAsset: yes
|
||||
timeCreated: 1527748593
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,67 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
public static class MaterialBundle
|
||||
{
|
||||
[MenuItem("UIEffect/Generate Material Bundle")]
|
||||
static void Generate()
|
||||
{
|
||||
#if UIEFFECT_SEPARATE
|
||||
// On "UIEFFECT_SEPARATE" mode, generate effect materials on demand.
|
||||
return;
|
||||
#endif
|
||||
|
||||
// Export materials.
|
||||
AssetDatabase.StartAssetEditing();
|
||||
GenerateMaterialVariants(
|
||||
Shader.Find(UIEffect.shaderName)
|
||||
, (ToneMode[])Enum.GetValues(typeof(ToneMode))
|
||||
, (ColorMode[])Enum.GetValues(typeof(ColorMode))
|
||||
, (BlurMode[])Enum.GetValues(typeof(BlurMode))
|
||||
);
|
||||
|
||||
GenerateMaterialVariants(
|
||||
Shader.Find(UIEffectCapturedImage.shaderName)
|
||||
, new[] { ToneMode.None, ToneMode.Grayscale, ToneMode.Sepia, ToneMode.Nega, ToneMode.Pixel, ToneMode.Hue, }
|
||||
, (ColorMode[])Enum.GetValues(typeof(ColorMode))
|
||||
, (BlurMode[])Enum.GetValues(typeof(BlurMode))
|
||||
);
|
||||
|
||||
GenerateMaterialVariants(
|
||||
Shader.Find(UIDissolve.shaderName)
|
||||
, new ToneMode[]{ToneMode.None}
|
||||
, (ColorMode[])Enum.GetValues(typeof(ColorMode))
|
||||
, new BlurMode[]{BlurMode.None}
|
||||
);
|
||||
|
||||
AssetDatabase.StopAssetEditing();
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
static void GenerateMaterialVariants(Shader shader, ToneMode[] tones, ColorMode[] colors, BlurMode[] blurs)
|
||||
{
|
||||
var combinations = (from tone in tones
|
||||
from color in colors
|
||||
from blur in blurs
|
||||
select new { tone, color, blur }).ToArray();
|
||||
|
||||
for (int i = 0; i < combinations.Length; i++)
|
||||
{
|
||||
var comb = combinations[i];
|
||||
var name = MaterialResolver.GetVariantName(shader, comb.tone, comb.color, comb.blur);
|
||||
EditorUtility.DisplayProgressBar("Genarate Effect Material Bundle", name, (float)i / combinations.Length);
|
||||
|
||||
MaterialResolver.GetOrGenerateMaterialVariant(shader, comb.tone, comb.color, comb.blur);
|
||||
}
|
||||
EditorUtility.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 862bf82ce26d647879e5918559c07976
|
||||
timeCreated: 1527674400
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+87
-30
@@ -1,5 +1,54 @@
|
||||
# Changelog
|
||||
|
||||
## [v3.0.1](https://github.com/mob-sakai/UIEffect/tree/v3.0.1) (2018-11-07)
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v3.0.0...v3.0.1)
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- Compile error in 2018.3 [\#139](https://github.com/mob-sakai/UIEffect/issues/139)
|
||||
|
||||
## [v3.0.0](https://github.com/mob-sakai/UIEffect/tree/v3.0.0) (2018-10-10)
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.8.3...v3.0.0)
|
||||
|
||||
### New architecture: easier, faster and more beautiful.
|
||||
* Simple & easy-to-use
|
||||
* 20% faster
|
||||
* High precision parameter
|
||||
|
||||
### Immediate capturing (UIEffectCapturedImage option)
|
||||
* Capture the previous frame immediately without any camera.
|
||||
* You no longer have to wait one frame to capture!
|
||||
* *NOTE: LWRP, WebGL and Unity 5.x for iOS/Mac are not supported.*
|
||||
|
||||
### Advanced blur (UIEffect option)
|
||||
* Remove common artifacts in the blur effect for uGUI.
|
||||

|
||||
* It is effective for small padding size atlases, including dynamic fonts!
|
||||
|
||||
**Breaking changes:**
|
||||
|
||||
- Remove 'additional shadow' in UIShadow component [\#110](https://github.com/mob-sakai/UIEffect/issues/110)
|
||||
- Remove 'custom effect' feature in UIEffect component [\#98](https://github.com/mob-sakai/UIEffect/issues/98)
|
||||
- Remove 'shadow effect' feature in UIEffect component [\#97](https://github.com/mob-sakai/UIEffect/issues/97)
|
||||
- Remove 'hue effect' in UIEffect component [\#91](https://github.com/mob-sakai/UIEffect/issues/91)
|
||||
- Remove 'cutoff' and 'mono' effect in UIEffect component [\#78](https://github.com/mob-sakai/UIEffect/issues/78)
|
||||
- UIEffectCapturedImage: Remove 'TargetTexture' feature [\#136](https://github.com/mob-sakai/UIEffect/issues/136)
|
||||
- Change: Change `ToneMode` to `EffectMode` [\#61](https://github.com/mob-sakai/UIEffect/issues/61)
|
||||
- UIShiny: change parameter name `highlight` to `gloss` [\#93](https://github.com/mob-sakai/UIEffect/issues/93)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- New architecture: Shared texture for effect parameter [\#63](https://github.com/mob-sakai/UIEffect/issues/63)
|
||||
- Improve blurring for atlas [\#95](https://github.com/mob-sakai/UIEffect/issues/95)
|
||||
- Use Canvas.willRenderCanvases event instead of Update method [\#87](https://github.com/mob-sakai/UIEffect/issues/87)
|
||||
- UITransitionEffect: "Pass ray on hidden" option [\#135](https://github.com/mob-sakai/UIEffect/issues/135)
|
||||
- Add component menu in editor [\#133](https://github.com/mob-sakai/UIEffect/issues/133)
|
||||
- UITransitionEffect: Add Show/Hide method [\#132](https://github.com/mob-sakai/UIEffect/issues/132)
|
||||
- UIEffectCapturedImage: Immediate capturing [\#130](https://github.com/mob-sakai/UIEffect/issues/130)
|
||||
- Add tooltip [\#92](https://github.com/mob-sakai/UIEffect/issues/92)
|
||||
|
||||
## [v2.8.3](https://github.com/mob-sakai/UIEffect/tree/v2.8.3) (2018-09-29)
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.8.2...v2.8.3)
|
||||
@@ -31,10 +80,10 @@
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.7.1...v2.8.0)
|
||||
|
||||
* Create a screen transition!
|
||||

|
||||
|
||||
* Some updates make UIEffectCapturedImage easier to use!
|
||||
* Create a screen transition!
|
||||

|
||||
|
||||
* Some updates make UIEffectCapturedImage easier to use!
|
||||
|
||||
|
||||
**Implemented enhancements:**
|
||||
@@ -60,10 +109,10 @@
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.6.2...v2.7.0)
|
||||
|
||||
UIHsvModifier: Modify hue, saturation, and value as you like!
|
||||

|
||||
|
||||
* Note: `Hue` mode in UIEffect component will be obsolete in the near future. Please use UIHsvModifier component instead.
|
||||
UIHsvModifier: Modify hue, saturation, and value as you like!
|
||||

|
||||
|
||||
* Note: `Hue` mode in UIEffect component will be obsolete in the near future. Please use UIHsvModifier component instead.
|
||||
* Note: `Cutoff` and `Mono` mode in UIEffect component will be obsolete in the near future. Please use UITransitionEffect component instead.
|
||||
|
||||
**Implemented enhancements:**
|
||||
@@ -98,13 +147,13 @@ UIHsvModifier: Modify hue, saturation, and value as you like!
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.5.2...v2.6.0)
|
||||
|
||||
Blurring effect has been improved about 6 times faster!
|
||||

|
||||
|
||||
You can change noise texture for dissolve effect from inspector or script!
|
||||

|
||||
|
||||
|
||||
Blurring effect has been improved about 6 times faster!
|
||||

|
||||
|
||||
You can change noise texture for dissolve effect from inspector or script!
|
||||

|
||||
|
||||
|
||||
|
||||
|
||||
**Implemented enhancements:**
|
||||
@@ -139,11 +188,11 @@ You can change noise texture for dissolve effect from inspector or script!
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.4.1...v2.5.0)
|
||||
|
||||
Shiny effect has been update!
|
||||
|
||||

|
||||
|
||||
* NOTE: `UIEffect.shadow***` will be obsolete in the near future. Please use `UIShadow` component instead.
|
||||
Shiny effect has been update!
|
||||
|
||||

|
||||
|
||||
* NOTE: `UIEffect.shadow***` will be obsolete in the near future. Please use `UIShadow` component instead.
|
||||
* NOTE: `UIEffect.custom***` will be obsolete in the near future. Please use `UICustomEffect` component (experimental) instead.
|
||||
|
||||
**Implemented enhancements:**
|
||||
@@ -176,9 +225,9 @@ Shiny effect has been update!
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.3.2...v2.4.0)
|
||||
|
||||
UIDissolve has been updated!
|
||||
|
||||

|
||||
UIDissolve has been updated!
|
||||
|
||||

|
||||

|
||||
|
||||
**Implemented enhancements:**
|
||||
@@ -205,14 +254,18 @@ UIDissolve has been updated!
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.2.0...v2.3.0)
|
||||
|
||||
New components has been available!
|
||||
|
||||
* **UIShiny** : Shiny effect WITHOUT Mask component. This will suppress extra draw calls and improve performance.
|
||||
* **UIDissolve** : Dissolve effect WITHOUT material instancing. This will suppress extra draw calls and improve performance.
|
||||
* **UIFlip** : Flip graphic horizontal/vertical.
|
||||
|
||||

|
||||
New components has been available!
|
||||
|
||||
* **UIShiny** : Shiny effect WITHOUT Mask component. This will suppress extra draw calls and improve performance.
|
||||
* **UIDissolve** : Dissolve effect WITHOUT material instancing. This will suppress extra draw calls and improve performance.
|
||||
* **UIFlip** : Flip graphic horizontal/vertical.
|
||||
|
||||

|
||||
|
||||
|
||||
**Breaking changes:**
|
||||
|
||||
- Use the graphic color as effect color, to reduce parameters [\#50](https://github.com/mob-sakai/UIEffect/issues/50)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
@@ -242,6 +295,10 @@ New components has been available!
|
||||
|
||||
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.0.0...v2.1.0)
|
||||
|
||||
**Breaking changes:**
|
||||
|
||||
- Separate shadow effect to other component [\#52](https://github.com/mob-sakai/UIEffect/issues/52)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- Feature: UIEffectCapturedImage support iterative operation [\#48](https://github.com/mob-sakai/UIEffect/issues/48)
|
||||
|
||||
@@ -35,7 +35,8 @@ GraphicsSettings:
|
||||
- {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_PreloadedShaders: []
|
||||
m_PreloadedShaders:
|
||||
- {fileID: 20000000, guid: 73036fa061ee340dcb3c04b9d8872e66, type: 2}
|
||||
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
||||
type: 0}
|
||||
m_TierSettings_Tier1:
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
UIEffect
|
||||
===
|
||||
|
||||
UIEffect contains visual effect components for uGUI element in Unity.
|
||||
UIEffect provide visual effect components for uGUI element in Unity.
|
||||
|
||||
[](https://github.com/mob-sakai/UIEffect/releases)
|
||||
[](https://github.com/mob-sakai/UIEffect/releases)
|
||||

|
||||
[](https://github.com/mob-sakai/UIEffect/blob/master/LICENSE.txt)
|
||||
[](http://makeapullrequest.com)
|
||||
|
||||
|
||||
|
||||
<< [Description](#Description) | [WebGL Demo](#demo) | [Download](https://github.com/mob-sakai/UIEffect/releases) | [Usage](#usage) | [Development Note](#development-note) >>
|
||||
<< [Description](#Description) | [WebGL Demo](#demo) | [Download](https://github.com/mob-sakai/UIEffect/releases) | [Usage](#usage) | [Example of using](#example-of-using) | [Development Note](#development-note) >>
|
||||
|
||||
### What's new? [See changelog ](https://github.com/mob-sakai/UIEffect/blob/develop/CHANGELOG.md)
|
||||
### Do you want to receive notifications for new releases? [Watch this repo ](https://github.com/mob-sakai/UIEffect/subscription)
|
||||
@@ -32,21 +31,21 @@ AnimationClip is supported as a matter of course!
|
||||
|
||||
| Component | Features | Screenshot |
|
||||
|-|-|-|
|
||||
|**UIEffect**|Combine some visual effects.<br><br>**ToneMode:** Grayscale, Sepia, Nega, Pixelation, Hue shift, Cutoff (alpha-based), Mono (alpha-based)<br>**ColorMode:** Multiply, Fill, Additive, Subtract<br>**BlurMode:** Fast, Medium, Detail<br><br>*NOTE: ToneMode, ColorMode and BlurMode are changeable only in editor.*<br>*NOTE: Custom Effect feature is deprecated. Please use `UICustomEffect` component instead.*<br>*NOTE: Shadow feature is deprecated. Please use `UIShadow` component instead.*<br>*NOTE: Hue is deprecated. Please use UIHsvModifier component instead.*<br>*NOTE: Cutoff and Mono is deprecated. Please use UITransitionEffect component instead.*|<img src="https://user-images.githubusercontent.com/12690315/40757428-68277f0c-64c3-11e8-89e5-4a19616a85c1.png" width="1000px">|
|
||||
|**UICaptured EffectImage**|Capture a screenshot of a specific frame with effect, and display it.<br>This effect is non-realtime, light-weight, less-camera, but be effective enough.<br><br>**ToneMode:** Grayscale, Sepia, Nega, Pixelation<br>**ColorMode:** Multiply, Fill, Additive, Subtract<br>**BlurMode:** Fast, Medium, Detail<br>**QualityMode:** Fast, Medium, Detail, Custom<br>**Options:** Capture on enable, Blur iterations, Reduction rate, Target texture, Fit size to screen.<br><br>NOTE: Use this component in 'ScreenSpace - Camera' or 'ScreenSpace - Overlay' mode.|<img src="https://user-images.githubusercontent.com/12690315/44078752-4c2e4114-9fe2-11e8-97f0-54d3a36a562e.gif" width="1000px">|
|
||||
|**UIShiny**|Apply shinning effect to a graphic.<br>The effect does not require Mask component or normal map.<br><br>**Options:** Location, Width, Rotation, Softness, Brightness, Highlight|<img src="https://user-images.githubusercontent.com/12690315/41398144-5c2ca126-6ff1-11e8-954b-394b611e2316.gif" width="1000px">|
|
||||
|**UIDissolve**|Apply dissolve effect to a graphic.<br><br>**ColorMode:** Overwrite, Additive, Subtract<br>**Options:** Location, Width, Rotation, Softness, Color|<img src="https://user-images.githubusercontent.com/12690315/41397973-d1038f7e-6ff0-11e8-919f-affb427393ee.gif" width="1000px">|
|
||||
|**UIHsvModifier**|Modify HSV for graphic.<br><br>**Target:** Color, Range<br>**Adjustment:** Hue, Saturation, Value|<img src="https://user-images.githubusercontent.com/12690315/43200006-d6e2bf54-904e-11e8-9f22-0c0f9ce5912f.gif" width="1000px">|
|
||||
|**UITransition Effect**|Apply transition effect with a single channel texture.<br><br>**EffectMode:** Cutoff, Fade|<img src="https://user-images.githubusercontent.com/12690315/44077521-f1b07c82-9fde-11e8-8487-2294c8d8f843.gif" width="1000px">|
|
||||
|**UIEffect**|Combine some visual effects.<br><br>**Effect Mode:** Grayscale, Sepia, Nega, Pixelation<br>**Color Mode:** Multiply, Fill, Additive, Subtract<br>**Blur Mode:** Fast, Medium, Detail<br>**Advanced Blur:** Enable more beautiful blurring.|<img src="https://user-images.githubusercontent.com/12690315/46639603-258df180-cba2-11e8-8f50-9e93bdc4c96e.png" width="600px">|
|
||||
|**UICaptured EffectImage**|Capture a screenshot of a specific frame with effect, and display it.<br>This effect is non-realtime, light-weight, less-camera, but be effective enough.<br><br>**Effect Mode:** Grayscale, Sepia, Nega, Pixelation<br>**Color Mode:** Multiply, Fill, Additive, Subtract<br>**Blur Mode:** Fast, Medium, Detail<br>**Quality Mode:** Fast, Medium, Detail, Custom<br>**Capture On Enable:** When the component is enable, capture screen automatically.<br>**Blur iterations:** Number of blur iterations.<br>**Reduction/Downsampling Rate:** None, x1, x2, x4, x8<br>**Fit size to screen:** Fit RectTransform to the screen on captured.<br>**Immediate Capturing:**<br><br>*NOTE: This component can be used with UIEffect, UITransition etc.*<br>*NOTE: Immediate capturing does not support LWRP, WebGL and Unity 5.x for iOS/Mac.*|<img src="https://user-images.githubusercontent.com/12690315/44078752-4c2e4114-9fe2-11e8-97f0-54d3a36a562e.gif" width="600px">|
|
||||
|**UIShiny**|Apply shining effect to a graphic.<br>The effect does not require Mask component or normal map.<br><br>**Parameters:** Effect factor, Width, Rotation, Softness, Brightness, Gloss<br>**Effect Player:** To play shining, enable `Play` in inspector or call `Play()` from script.|<img src="https://user-images.githubusercontent.com/12690315/46639689-b1078280-cba2-11e8-8716-cbc634af7293.gif" width="600px">|
|
||||
|**UIDissolve**|Apply dissolve effect to a graphic.<br><br>**Color Mode for edge:** Multiply, Fill, Additive, Subtract<br>**Parameters:** Effect factor, Width, Rotation, Softness, Edge color<br>**Options:** Effect area, Keep effect aspect ratio<br>**Effect Player:** To play dissolving, call `Play()` from script.|<img src="https://user-images.githubusercontent.com/12690315/46639690-b1078280-cba2-11e8-8aa9-1d2650fe9a62.gif" width="600px">|
|
||||
|**UIHsvModifier**|Modify HSV for graphic.<br><br>**Target:** Color, Range<br>**Adjustment:** Hue, Saturation, Value|<img src="https://user-images.githubusercontent.com/12690315/43200006-d6e2bf54-904e-11e8-9f22-0c0f9ce5912f.gif" width="600px">|
|
||||
|**UITransition Effect**|Apply transition effect with a single channel texture.<br><br>**Effect Mode:** Cutoff, Fade, Dissolve<br>**Options:** Effect area, Keep effect aspect ratio, transition texture<br>**Pass Ray On Hidden:** Disable the graphic's raycastTarget on hidden.<br>**Effect Player:** To show/hide transition, call `Show()/Hide()` from script.|<img src="https://user-images.githubusercontent.com/12690315/46639688-b1078280-cba2-11e8-8bbb-16b8498bca5f.gif" width="600px">|
|
||||
|
||||
<br><br>
|
||||
##### The following effects can be used with the above components.
|
||||
|
||||
| Component | Features | Screenshot |
|
||||
|-|-|-|
|
||||
|**UIShadow**|Add shadow/outline to a graphic.<br>Performance is better than the default Shadow/Outline component.<br>See also [Development note](#the-issue-of-default-outline-component).<br><br>**ShadowStyle:** Shadow, Shadow3, Outline, Outline8<br>**Additional Shadows** reduce vertices for multiple Shadows or Outlines.<br>*NOTE: AdditionalShadow is deprecated. Please use multiple `UIShadow` component instead.*|<img src="https://user-images.githubusercontent.com/12690315/40716994-ca5c13d2-6445-11e8-96d0-25a3ce704e2e.png" width="1000px">|
|
||||
|**UIGradient**|Change vertex color as gradient with angle and offset.<br><br>**Direction:** Horizontal, Vertical, Angle, Diagonal<br>**Options:** Offset, Color space|<img src="https://user-images.githubusercontent.com/12690315/40716995-ca87665e-6445-11e8-8233-ec2e21fefd6b.png" width="1000px">|
|
||||
|**UIFlip**|Flip a graphic.<br><br>**Direction:** Horizontal, Vertical, Both|<img src="https://user-images.githubusercontent.com/12690315/40716996-cab1fd7e-6445-11e8-9753-962d23991d86.png" width="1000px">|
|
||||
|**UIShadow**|Add shadow/outline to a graphic.<br>The performance is better than the default Shadow/Outline component.<br><br>**ShadowStyle:** Shadow, Shadow3, Outline, Outline8|<img src="https://user-images.githubusercontent.com/12690315/46639604-258df180-cba2-11e8-98a9-aa31f04c695d.png" width="600px">|
|
||||
|**UIGradient**|Change vertex color as gradient with angle and offset.<br><br>**Direction:** Horizontal, Vertical, Angle, Diagonal<br>**Options:** Offset, Color space|<img src="https://user-images.githubusercontent.com/12690315/40716995-ca87665e-6445-11e8-8233-ec2e21fefd6b.png" width="600px">|
|
||||
|**UIFlip**|Flip a graphic.<br><br>**Direction:** Horizontal, Vertical, Both|<img src="https://user-images.githubusercontent.com/12690315/40716996-cab1fd7e-6445-11e8-9753-962d23991d86.png" width="600px">|
|
||||
|
||||
|
||||
|
||||
@@ -68,10 +67,15 @@ AnimationClip is supported as a matter of course!
|
||||
## Usage
|
||||
|
||||
1. Download UIEffect.unitypackage from [Releases](https://github.com/mob-sakai/UIEffect/releases).
|
||||
1. Import the package into your Unity project. Select `Import Package > Custom Package` from the `Assets` menu.
|
||||
1. In Unity5.6+, enable `TexCoord1` channel of canvas. See also [Development Note](##note-unity-56).
|
||||
1. Add any effect component to UI element (Image, RawImage, Text, etc...) from `Add Component` in inspector.
|
||||
1. Enjoy!
|
||||
2. Import the package into your Unity project. Select `Import Package > Custom Package` from the `Assets` menu.
|
||||

|
||||
3. In Unity5.6+, enable `TexCoord1` channel of canvas. See also [Development Note](##note-unity-56).
|
||||

|
||||
4. Add any effect component to UI element (Image, RawImage, Text, etc...) from `Add Component` in inspector or `Component > UI > UIEffect > ...` menu.
|
||||

|
||||
6. Adjust the parameters of the effect as you like, in inspector.
|
||||

|
||||
7. Enjoy!
|
||||
|
||||
|
||||
##### Requirement
|
||||
@@ -82,6 +86,24 @@ AnimationClip is supported as a matter of course!
|
||||
|
||||
|
||||
|
||||
<br><br><br><br>
|
||||
## Example of using
|
||||
|
||||
| Case | Description | Screenshot |
|
||||
|-|-|-|
|
||||
|Lock/unlock contents|Use UIEffect to apply grayscale.<br>Indicate to user that the content is unavailable.||
|
||||
|Silhouette|Use UIEffect for filling color.||
|
||||
|Soft shadow/<br>Outer glow|Use UIEffect and UIShadow to blur the shadow.<br>To blur only shadow, set `Blur Factor` in UIEffect to 0.||
|
||||
|Colored shadow|Use UIEffect and UIShadow to fill shadow with color.<br>To fill only shadow, set `Color Factor` in UIEffect to 0.||
|
||||
|Blurred dynamic font|Use UIEffect to blur text.<br>To blur dynamic font cleanly, enable `Advanced Blur` option.||
|
||||
|Text with outline & shadow|Use two UIShadows to add outline and shadow.<br>There is less overdraw than default Outline/Shadow `(Default: 1 x 5 x 2 = 10 overdraws, UIShadow: 1 + 4 + 1 = 6 overdraws)`.||
|
||||
|Shining button|Use UIShiny for shining button.<br>Shine the button and indicate to user that you can press the button.<br>Enable `Play` and `Loop` option to shine it without any AnimationClip.||
|
||||
|Blurring the background of a menu|Use UIEffectCapturedImage to blur the background of a menu.<br>UIEffectCapturedImage applies an effect to the screen of the previous frame, without adding a camera or layer.<br>It's not a real-time post effect, so it's good performance and works well on mobile.||
|
||||
|Screen transition|Use UITransitionEffect to add screen transition.<br>You can change transition texture (single channel texture).<br>Enable `Pass Ray On Hidden` option and use `Show()/Hide()` method to play transition without AnimationClip.||
|
||||
|
||||
|
||||
|
||||
|
||||
<br><br><br><br>
|
||||
## Development Note
|
||||
|
||||
@@ -121,6 +143,12 @@ See also [Demo](#demo).
|
||||
| x(32bit float) | Tone level | *Empty* | Blur level | *Empty* |
|
||||
| y(32bit float) | Red channel | Green channel | Blue channel | Alpha channel |
|
||||
|
||||
* In v3.0.0+, UIEffect uploads the parameter value to a shared texture and the shader refers to it.
|
||||
This approach has the following advantages:
|
||||
* More parameters for the effect are available.
|
||||
* The parameter accuracy is improved from 6 bits to 8 bits.
|
||||
* ModifyMesh is not called when parameter value is changed.
|
||||
|
||||
|
||||
#### Note: Unity 5.6+
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "UIEffect",
|
||||
"version": "2.8.3",
|
||||
"version": "3.0.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mob-sakai/UIEffect.git"
|
||||
|
||||
Reference in New Issue
Block a user