Compare commits

..

11 Commits

Author SHA1 Message Date
Takashi Sakai ccd6637a27 Export 1.2.0 2018-01-05 13:51:24 +09:00
Takashi Sakai 5f5257cc5c Add: License file is included in package. 2018-01-05 13:23:19 +09:00
Takashi Sakai 1a7cf1090a Demo: Add transition button & multiple shadows. 2018-01-04 23:54:19 +09:00
Takashi Sakai 7e220e0159 Changed: Blur range is [0-2]. 2018-01-04 23:54:18 +09:00
Takashi Sakai 35a8c65e8b Refactoring: Shader refactoring. 2018-01-04 23:54:16 +09:00
Takashi Sakai ba819d8ba8 Feature: Fix button to enable TexCoord1 of Canvas.additionalShaderChannels to use UIEffect. 2018-01-04 23:51:26 +09:00
Takashi Sakai 6eb94706e3 Changed : UIEffect.color is obsolete, use UIEffect.effectColor instead. 2018-01-04 16:18:18 +09:00
Takashi Sakai cdb04036f5 Feature: Supports multiple shadow effect for reduce rendering vertices. 2018-01-04 16:18:16 +09:00
Takashi Sakai 25d8d4c1b1 Fixed: Cutoff alpha is incorrect. 2018-01-04 14:59:15 +09:00
Takashi Sakai 107c348fe2 Feature: New blur effect mode : Medium. 2018-01-04 14:59:08 +09:00
Takashi Sakai c9ab0e70dc Fixed : Pixelaration shifts to the lower right. 2018-01-04 14:57:52 +09:00
13 changed files with 5742 additions and 2870 deletions
+8 -8
View File
@@ -77,7 +77,7 @@ AnimationClip:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.r
attribute: m_EffectColor.r
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
@@ -132,7 +132,7 @@ AnimationClip:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.g
attribute: m_EffectColor.g
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
@@ -177,7 +177,7 @@ AnimationClip:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.b
attribute: m_EffectColor.b
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
@@ -217,7 +217,7 @@ AnimationClip:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
attribute: m_EffectColor.a
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
@@ -336,7 +336,7 @@ AnimationClip:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.r
attribute: m_EffectColor.r
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
@@ -391,7 +391,7 @@ AnimationClip:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.g
attribute: m_EffectColor.g
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
@@ -436,7 +436,7 @@ AnimationClip:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.b
attribute: m_EffectColor.b
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
@@ -476,7 +476,7 @@ AnimationClip:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.a
attribute: m_EffectColor.a
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
File diff suppressed because it is too large Load Diff
+687
View File
@@ -0,0 +1,687 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &-1746834952
AnimationClip:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: 0 to 1
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 2
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 3
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_ToneLevel
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
m_PPtrCurves: []
m_SampleRate: 12
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- path: 0
attribute: 2148837408
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
classID: 114
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 3
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 2
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 3
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_ToneLevel
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_GenerateMotionCurves: 0
m_Events: []
--- !u!1102 &-1537770706
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Animation
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_Motion: {fileID: 0}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
--- !u!74 &7450624
AnimationClip:
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: 1 to 0
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 2
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 3
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_ToneLevel
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
m_PPtrCurves: []
m_SampleRate: 12
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- path: 0
attribute: 2148837408
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
classID: 114
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 3
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 2
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 3
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_ToneLevel
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_GenerateMotionCurves: 0
m_Events: []
--- !u!74 &7451788
AnimationClip:
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: 0 to 1
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: 0}
attribute: m_Sprite
path:
classID: 212
script: {fileID: 0}
m_SampleRate: 12
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- path: 0
attribute: 0
script: {fileID: 0}
classID: 212
customType: 23
isPPtrCurve: 1
pptrCurveMapping:
- {fileID: 0}
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.083333336
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_GenerateMotionCurves: 0
m_Events: []
--- !u!74 &7475794
AnimationClip:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: 1 to 0
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 2
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 3
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_ToneLevel
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
m_PPtrCurves: []
m_SampleRate: 12
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- path: 0
attribute: 2148837408
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
classID: 114
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 3
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 2
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 3
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_ToneLevel
path:
classID: 114
script: {fileID: 11500000, guid: f8b2ed11d675446c5a49da1ea296d490, type: 3}
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_GenerateMotionCurves: 0
m_Events: []
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Transition
serializedVersion: 5
m_AnimatorParameters:
- m_Name: Cutoff
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
- m_Name: Mono
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: 110755890}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &110109394
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Mono
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 110244674}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0.9
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &110120972
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Cutoff
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 110299230}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0.9
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &110147560
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 0}
m_Solo: 0
m_Mute: 0
m_IsExit: 1
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0
m_HasExitTime: 1
m_HasFixedDuration: 0
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &110176334
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 0}
m_Solo: 0
m_Mute: 0
m_IsExit: 1
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0
m_HasExitTime: 1
m_HasFixedDuration: 0
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &110200840
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: 1 to 0 (Exported)
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_Motion: {fileID: 0}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
--- !u!1102 &110201538
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Idle
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_Motion: {fileID: 0}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
--- !u!1102 &110244674
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: 0 to 1
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 110147560}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_Motion: {fileID: -1746834952}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
--- !u!1102 &110299230
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: 1 to 0
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 110176334}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_Motion: {fileID: 7475794}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
--- !u!1107 &110755890
AnimatorStateMachine:
serializedVersion: 5
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 110244674}
m_Position: {x: 12, y: 108, z: 0}
- serializedVersion: 1
m_State: {fileID: 110299230}
m_Position: {x: 276, y: 108, z: 0}
- serializedVersion: 1
m_State: {fileID: 110201538}
m_Position: {x: 336, y: -12, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions:
- {fileID: 110109394}
- {fileID: 110120972}
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 144, y: 48, z: 0}
m_EntryPosition: {x: 144, y: -12, z: 0}
m_ExitPosition: {x: 144, y: 180, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 110201538}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e3cb99c58283f294a9e51c0c30046b18
timeCreated: 1515075779
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
+135 -63
View File
@@ -1,5 +1,6 @@
using UnityEngine.UI;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.UI;
namespace UnityEditor.UI
{
@@ -10,95 +11,166 @@ namespace UnityEditor.UI
[CanEditMultipleObjects]
public class UIEffectEditor : Editor
{
ReorderableList roAdditionalShadows;
SerializedProperty spAdditionalShadows;
SerializedProperty spBlurMode;
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
public static void DrawEffectProperties(SerializedObject serializedObject)
{
//
serializedObject.Update();
UIEffect current = target as UIEffect;
//================
// Tone setting.
//================
var spToneMode = serializedObject.FindProperty("m_ToneMode");
var spColorMode = serializedObject.FindProperty("m_ColorMode");
var spBlurMode = serializedObject.FindProperty("m_BlurMode");
var spShadowMode = serializedObject.FindProperty("m_ShadowMode");
EditorGUILayout.PropertyField(spToneMode);
//================
// Only the main effect can change effect modes.
// They change shader keywords of the material.
//================
if (current.mainEffect == current)
{
// Tone setting.
EditorGUILayout.PropertyField(spToneMode);
// If tone is enable, show parameters.
if (spToneMode.intValue != (int)UIEffect.ToneMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ToneLevel"));
EditorGUI.indentLevel--;
}
// Color setting.
EditorGUILayout.PropertyField(spColorMode);
// If color is enable, show parameters.
if (spColorMode.intValue != (int)UIEffect.ColorMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Color"));
EditorGUI.indentLevel--;
}
}
// Set effect mode from main effect.
else
{
spToneMode.intValue = (int)current.mainEffect.toneMode;
spColorMode.intValue = (int)current.mainEffect.colorMode;
spBlurMode.intValue = (int)current.mainEffect.blurMode;
}
//================
// Shadow setting.
//================
EditorGUILayout.PropertyField(spShadowMode);
// If shadow is enable, show parameters.
if (spShadowMode.intValue != (int)UIEffect.ShadowMode.None)
// When tone is enable, show parameters.
if (spToneMode.intValue != (int)UIEffect.ToneMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectDistance"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ShadowColor"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_UseGraphicAlpha"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ToneLevel"));
EditorGUI.indentLevel--;
}
//================
// Color setting.
//================
var spColorMode = serializedObject.FindProperty("m_ColorMode");
EditorGUILayout.PropertyField(spColorMode);
// When color is enable, show parameters.
if (spColorMode.intValue != (int)UIEffect.ColorMode.None)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectColor"));
EditorGUI.indentLevel--;
}
//================
// Blur setting.
//================
var spBlurMode = serializedObject.FindProperty("m_BlurMode");
EditorGUILayout.PropertyField(spBlurMode);
// If blur is enable, show parameters.
// When blur is enable, show parameters.
if (spBlurMode.intValue != (int)UIEffect.BlurMode.None)
{
EditorGUI.indentLevel++;
// Blur parameter.
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Blur"));
EditorGUI.indentLevel--;
}
}
// Shadow blur parameter.
if (spShadowMode.intValue != (int)UIEffect.ShadowMode.None)
void OnEnable()
{
spAdditionalShadows = serializedObject.FindProperty("m_AdditionalShadows");
spBlurMode = serializedObject.FindProperty("m_BlurMode");
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)UIEffect.ShadowMode.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)UIEffect.ShadowMode.None)
return 16;
return (spBlurMode.intValue == (int)UIEffect.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)UIEffect.ShadowMode.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)UIEffect.BlurMode.None)
{
r.y += r.height;
EditorGUI.PropertyField(r, sp.FindPropertyRelative("shadowBlur"));
}
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
public override void OnInspectorGUI()
{
serializedObject.Update();
DrawEffectProperties(serializedObject);
//================
// Shadow setting.
//================
var spShadowMode = serializedObject.FindProperty("m_ShadowMode");
EditorGUILayout.PropertyField(spShadowMode);
// When shadow is enable, show parameters.
if (spShadowMode.intValue != (int)UIEffect.ShadowMode.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)UIEffect.BlurMode.None)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ShadowBlur"));
}
EditorGUI.indentLevel--;
}
//
//================
// Additional shadow setting.
//================
roAdditionalShadows.DoLayoutList();
serializedObject.ApplyModifiedProperties();
#if UNITY_5_6_OR_NEWER
var canvas = (target as UIEffect).graphic.canvas;
if( 0 == (canvas.additionalShaderChannels & AdditionalCanvasShaderChannels.TexCoord1))
{
using (new GUILayout.HorizontalScope())
{
EditorGUILayout.HelpBox("[Unity5.6+] Enable TexCoord1 of Canvas.additionalShaderChannels to use UIEffect.", MessageType.Warning);
if (GUILayout.Button("Fix"))
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord1;
}
}
#endif
}
}
}
+7
View File
@@ -0,0 +1,7 @@
Copyright 2017 mob-sakai
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5c8ea34522dd786479be28b1347542b7
timeCreated: 1515125149
licenseType: Free
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:
+49 -8
View File
@@ -3,6 +3,8 @@ UIEffect
Easy to use effects for uGUI. Supports following effects.
![image](https://user-images.githubusercontent.com/12690315/34595716-695a3bee-f21d-11e7-9a34-7a089ab7f6ea.gif)
* Grayscale tone
* Sepia tone
* Nega tone
@@ -12,10 +14,14 @@ Easy to use effects for uGUI. Supports following effects.
* Color setting
* Color additive
* Color subtract
* Blur fast
* Blur detail
* Blur fast(3x4)
* Blur medium(6x4)
* Blur detail(6x8)
* Use for transition
![image](https://user-images.githubusercontent.com/12690315/34595717-6b00e8c6-f21d-11e7-98b6-798cf03f2ed5.gif)
* Supports multiple shadow effect for reduce rendering vertices
![image](https://user-images.githubusercontent.com/12690315/34552373-600fdab2-f164-11e7-8565-21c15af92a93.png)
![demo](https://user-images.githubusercontent.com/12690315/29394440-3479d624-8345-11e7-8b1d-68d35e4a20de.gif)
@@ -26,37 +32,59 @@ Easy to use effects for uGUI. Supports following effects.
## Usage
1. Download [UIEffect.unitypackage](https://github.com/mob-sakai/UIEffect/raw/master/UIEffect.unitypackage) and install to your project.
1. Import the package into your Unity project. Select `Import Package > Custom Package` from the `Assets` menu.
1. Add `UIEffect` component to UI element (Image, RawImage, Text, etc...) from `Add Component` in inspector.
1. Choose effect type and adjust values in inspector.
![image](https://user-images.githubusercontent.com/12690315/28405920-56fa5d96-6d69-11e7-9aaa-832cfecc72c6.png)
![image](https://user-images.githubusercontent.com/12690315/34595809-3838dc54-f21e-11e7-858b-72821dca8b44.png)
1. Enjoy!
## Note: Unity 5.6+
In Unity 5.6+, Canvas supports **Additional Shader Channels**.
Please enable `TexCoord1` to use UIEffect.
![image](https://user-images.githubusercontent.com/12690315/28405830-f4f261e8-6d68-11e7-9faf-7e5442062f59.png)
![image](https://user-images.githubusercontent.com/12690315/34560894-191b6cda-f18b-11e7-9de2-9a9d13f72ccd.png)
## Demo
[WebGL Demo](https://developer.cloud.unity3d.com/share/W1fv8sYS9f/)
[WebGL Demo](https://developer.cloud.unity3d.com/share/b1Ow2w4KbX/webgl/)
## Release Notes
### ver.1.2.0
* Fixed : Pixelaration shifts to the lower right.
* Fixed : Cutoff alpha is incorrect.
* Feature: Supports multiple shadow effect for reduce rendering vertices.
![image](https://user-images.githubusercontent.com/12690315/34552373-600fdab2-f164-11e7-8565-21c15af92a93.png)
* Feature: New blur effect mode : `Medium`.
* Feature: Fix button to enable TexCoord1 of Canvas.additionalShaderChannels to use UIEffect.
![image](https://user-images.githubusercontent.com/12690315/34560894-191b6cda-f18b-11e7-9de2-9a9d13f72ccd.png)
* Changed : UIEffect.color is obsolete, use UIEffect.effectColor instead.
* Changed: Blur range is [0-2].
* Refactoring: Shader refactoring.
* Demo: Add transition button & multiple shadows.
### ver.1.1.0
* Feature: Add Pixelaration effect.
* Feature: Add Cutoff/Mono effect for patterned alpha images. It can be used for masks and transitions!
* Feature: Add Cutoff/Mono effect for patterned alpha images. It can be used for masks and transitions!
![image](https://user-images.githubusercontent.com/12690315/34595717-6b00e8c6-f21d-11e7-98b6-798cf03f2ed5.gif)
### ver.1.0.0
@@ -81,10 +109,23 @@ Please enable `TexCoord1` to use UIEffect.
## License
MIT
* MIT
* © UTJ/UCL
## Author
[mob-sakai](https://github.com/mob-sakai)
[mob-sakai](https://github.com/mob-sakai)
## See Also
* GitHub Page : https://github.com/mob-sakai/UIEffect
* Issue tracker : https://github.com/mob-sakai/UIEffect/issues
+41 -41
View File
@@ -14,14 +14,13 @@
#define UI_COLOR
#endif
#if UI_BLUR_FAST | UI_BLUR_DETAIL
#if UI_BLUR_FAST | UI_BLUR_MEDIUM | UI_BLUR_DETAIL
#define UI_BLUR
#endif
//################################
// Unpacker to vector
//################################
#if defined (UI_COLOR)
// Unpack float to low-precision [0-1] fixed4.
fixed4 UnpackToVec4(float value)
{
@@ -40,9 +39,7 @@ fixed4 UnpackToVec4(float value)
color.a = (value % PACKER_STEP) / PRECISION;
return color;
}
#endif
#if defined (UI_TONE) || defined (UI_BLUR)
// Unpack float to low-precision [0-1] half3.
// The z value is a little high precision.
half3 UnpackToVec3(float value)
@@ -62,61 +59,63 @@ half3 UnpackToVec3(float value)
return color;
}
#endif
//################################
// Blur effect
//################################
#if defined (UI_BLUR)
// Calculate blur effect.
// Sample texture by blured uv, with bias.
fixed4 Blur(sampler2D tex, half2 uv, half2 addUv, half bias)
fixed4 Blur(sampler2D tex, half2 uv, half addUv, half bias)
{
half4 color = tex2D( tex, uv + addUv);
color += tex2D( tex, uv - addUv);
addUv.x *= -1;
color += tex2D( tex, uv + addUv);
color += tex2D( tex, uv - addUv);
return color * bias;
return
(
tex2D(tex, uv + half2(addUv, addUv))
+ tex2D(tex, uv + half2(-addUv, addUv))
+ tex2D(tex, uv + half2(addUv, -addUv))
+ tex2D(tex, uv + half2(-addUv, -addUv))
#if UI_BLUR_DETAIL
+ tex2D(tex, uv + half2(addUv, 0))
+ tex2D(tex, uv + half2(-addUv, 0))
+ tex2D(tex, uv + half2(0, addUv))
+ tex2D(tex, uv + half2(0, -addUv))
)
* bias / 2;
#else
)
* bias;
#endif
}
// Sample texture with blurring.
// * Fast: Sample texture with 3x4 blurring.
// * Detail: Sample texture with 6x4 blurring.
fixed4 Tex2DBlurring(sampler2D tex, half2 uv, fixed blurring)
// * Medium: Sample texture with 6x4 blurring.
// * Detail: Sample texture with 6x8 blurring.
fixed4 Tex2DBlurring(sampler2D tex, half2 uv, half blur)
{
half4 color = tex2D(tex, uv);
half2 dir = half2( blurring, blurring);
fixed4 blurring_color;
#if UI_BLUR_FAST // Blur(Fast)
const half originalBias = 0.41511;
blurring_color
= Blur( tex, uv, dir * 3, 0.12924 )
+ Blur( tex, uv, dir * 5, 0.01343 )
+ Blur( tex, uv, dir * 6, 0.00353 );
#if UI_BLUR_FAST
return color * 0.41511
+ Blur( tex, uv, blur * 3, 0.12924 )
+ Blur( tex, uv, blur * 5, 0.01343 )
+ Blur( tex, uv, blur * 6, 0.00353 );
#elif UI_BLUR_DETAIL // Blur(Detail)
const half originalBias = 0.14387;
blurring_color
= Blur( tex, uv, dir * 1, 0.06781 )
+ Blur( tex, uv, dir * 2, 0.05791 )
+ Blur( tex, uv, dir * 3, 0.04360 )
+ Blur( tex, uv, dir * 4, 0.02773 )
+ Blur( tex, uv, dir * 5, 0.01343 )
+ Blur( tex, uv, dir * 6, 0.00353 );
#elif UI_BLUR_MEDIUM | UI_BLUR_DETAIL
return color * 0.14387
+ Blur( tex, uv, blur * 1, 0.06781 )
+ Blur( tex, uv, blur * 2, 0.05791 )
+ Blur( tex, uv, blur * 3, 0.04360 )
+ Blur( tex, uv, blur * 4, 0.02773 )
+ Blur( tex, uv, blur * 5, 0.01343 )
+ Blur( tex, uv, blur * 6, 0.00353 );
#else
return color;
#endif
return color * originalBias + blurring_color;
}
#endif
//################################
// Tone effect
//################################
#if defined (UI_TONE)
// Apply tone effect.
fixed4 ApplyToneEffect(fixed4 color, fixed factor)
{
@@ -132,13 +131,11 @@ fixed4 ApplyToneEffect(fixed4 color, fixed factor)
return color;
}
#endif
//################################
// Color effect
//################################
#if defined (UI_COLOR)
// Apply color effect.
fixed4 ApplyColorEffect(fixed4 color, fixed4 factor)
{
@@ -152,8 +149,11 @@ fixed4 ApplyColorEffect(fixed4 color, fixed4 factor)
color.rgb -= factor.rgb * factor.a;
#endif
#if UI_TONE_CUTOFF
color.a = factor.a;
#endif
return color;
}
#endif
#endif // UI_EFFECT_INCLUDED
+3 -7
View File
@@ -61,7 +61,7 @@ Shader "UI/Hidden/UIEffect"
// vvvv [For UIEffect] vvvv : Define keyword and include.
#pragma multi_compile __ UI_TONE_GRAYSCALE UI_TONE_SEPIA UI_TONE_NEGA UI_TONE_PIXEL UI_TONE_MONO UI_TONE_CUTOFF
#pragma multi_compile __ UI_COLOR_ADD UI_COLOR_SUB UI_COLOR_SET
#pragma multi_compile __ UI_BLUR_FAST UI_BLUR_DETAIL
#pragma multi_compile __ UI_BLUR_FAST UI_BLUR_MEDIUM UI_BLUR_DETAIL
#include "UI-Effect.cginc"
// ^^^^ [For UIEffect] ^^^^
@@ -112,11 +112,7 @@ Shader "UI/Hidden/UIEffect"
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
#endif
OUT.worldPosition = IN.vertex;
#if UNITY_VERSION >= 540
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
#else
OUT.vertex = mul(UNITY_MATRIX_MVP, OUT.worldPosition);
#endif
OUT.texcoord = IN.texcoord;
@@ -124,7 +120,7 @@ Shader "UI/Hidden/UIEffect"
#if UNITY_VERSION >= 540
OUT.vertex.xy += (_ScreenParams.zw-1.0) * float2(-1,1) * OUT.vertex.w;
#else
OUT.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1);
OUT.vertex.xy += (_ScreenParams.zw-1.0) * float2(-1,1);
#endif
#endif
@@ -150,7 +146,7 @@ Shader "UI/Hidden/UIEffect"
{
#if UI_TONE_PIXEL
float pixelRate = max(1,(1-IN.effectFactor.x) * 256);
IN.texcoord = floor(IN.texcoord * pixelRate) / pixelRate;
IN.texcoord = round(IN.texcoord * pixelRate) / pixelRate;
#endif
#if defined (UI_BLUR)
+220 -177
View File
@@ -1,6 +1,6 @@
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.Serialization;
namespace UnityEngine.UI
{
@@ -9,28 +9,45 @@ namespace UnityEngine.UI
/// </summary>
[ExecuteInEditMode]
[RequireComponent(typeof(Graphic))]
[DisallowMultipleComponent]
public class UIEffect : MonoBehaviour, IMeshModifier
{
/// <summary>
/// Additional shadow.
/// </summary>
[System.Serializable]
public class AdditionalShadow
{
/// <summary>
/// How far is the blurring shadow from the graphic.
/// </summary>
[Range(0, 2)]
public float shadowBlur = 0.25f;
/// <summary>
/// Shadow effect mode.
/// </summary>
public ShadowMode shadowMode = ShadowMode.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 Members.
//################################
/// <summary>
/// Precision shift. Each value has 6 bits.
/// </summary>
const int PACKER_SHIFT_1 = 6;
const int PACKER_SHIFT_2 = PACKER_SHIFT_1 * 2;
const int PACKER_SHIFT_3 = PACKER_SHIFT_1 * 3;
/// <summary>
/// Precision bits. Each value [0-1] has 64 steps.
/// </summary>
const int PACKER_PRECISION = (1 << PACKER_SHIFT_1) - 1;
/// <summary>
/// Effect shader name.
/// </summary>
const string ShaderName = "UI/Hidden/UIEffect";
/// <summary>
/// Tone effect mode.
/// </summary>
@@ -74,6 +91,7 @@ namespace UnityEngine.UI
{
None = 0,
Fast,
Medium,
Detail,
}
@@ -82,10 +100,7 @@ namespace UnityEngine.UI
// Static Members.
//################################
static readonly List<UIVertex> s_Verts = new List<UIVertex>();
static readonly List<UIEffect> s_UIEffects = new List<UIEffect>();
static readonly Material[] s_SharedMaterials = new Material[128];
static readonly Dictionary<Shader, Material[]> s_SharedMaterials = new Dictionary<Shader, Material[]>();
//################################
// Public or Serialize Members.
@@ -95,21 +110,21 @@ namespace UnityEngine.UI
/// </summary>
public float toneLevel{ get { return m_ToneLevel; } set { m_ToneLevel = Mathf.Clamp(value, 0, 1); SetDirty(); } }
[SerializeField][Range(0, 1)]protected float m_ToneLevel = 1;
[SerializeField][Range(0, 1)] float m_ToneLevel = 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); SetDirty(); } }
[SerializeField][Range(0, 4)]protected float m_Blur = 0;
[SerializeField][Range(0, 2)] float m_Blur = 0.25f;
/// <summary>
/// How far is the blurring shadow from the graphic.
/// </summary>
public float shadowBlur { get { return m_ShadowBlur; } set { m_ShadowBlur = Mathf.Clamp(value, 0, 4); SetDirty(); } }
[SerializeField][Range(0, 4)]protected float m_ShadowBlur = 0;
[SerializeField][Range(0, 2)] float m_ShadowBlur = 0.25f;
/// <summary>
/// Shadow effect mode.
@@ -144,7 +159,7 @@ namespace UnityEngine.UI
/// </summary>
public Color shadowColor { get { return m_ShadowColor; } set { m_ShadowColor = value; SetDirty(); } }
[SerializeField] Color m_ShadowColor = Color.white;
[SerializeField] Color m_ShadowColor = Color.black;
/// <summary>
/// How far is the shadow from the graphic.
@@ -163,14 +178,20 @@ namespace UnityEngine.UI
/// <summary>
/// Color for the color effect.
/// </summary>
public Color color { get { return m_Color; } set { m_Color = value; SetDirty(); } }
[Obsolete("UIEffect.color is obsolete, use UIEffect.effectColor instead. (UnityUpgradable) -> effectColor")]
public Color color { get { return m_EffectColor; } set { m_EffectColor = value; SetDirty(); } }
[SerializeField] Color m_Color = Color.white;
/// <summary>
/// Color for the color effect.
/// </summary>
public Color effectColor { get { return m_EffectColor; } set { m_EffectColor = value; SetDirty(); } }
[SerializeField][FormerlySerializedAs("m_Color")] Color m_EffectColor = Color.white;
/// <summary>
/// Effect shader.
/// </summary>
public virtual Shader shader { get { if (m_Shader == null) m_Shader = Shader.Find(ShaderName); return m_Shader; } }
public virtual Shader shader { get { if (m_Shader == null) m_Shader = Shader.Find("UI/Hidden/UIEffect"); return m_Shader; } }
[SerializeField] Shader m_Shader;
@@ -182,10 +203,12 @@ namespace UnityEngine.UI
Graphic m_Graphic;
/// <summary>
/// Main effect in the gameobject.
/// * It is top most UIEffect component in inspector.
/// Additional Shadows.
/// </summary>
public UIEffect mainEffect{ get; private set; }
public List<AdditionalShadow> additionalShadows { get { return m_AdditionalShadows; } }
[SerializeField] List<AdditionalShadow> m_AdditionalShadows = new List<AdditionalShadow>();
//################################
// MonoBehaior Callbacks.
@@ -195,7 +218,7 @@ namespace UnityEngine.UI
/// </summary>
protected virtual void OnEnable()
{
SetDirty(this);
SetDirty(true);
}
/// <summary>
@@ -203,14 +226,7 @@ namespace UnityEngine.UI
/// </summary>
protected virtual void OnDisable()
{
// When all effect modes are disable, graphic uses default material.
GetComponents<UIEffect>(s_UIEffects);
if (s_UIEffects.All(effect => !effect.enabled))
{
graphic.material = null;
graphic.SetVerticesDirty();
}
s_UIEffects.Clear();
graphic.material = null;
SetDirty();
}
@@ -236,18 +252,14 @@ namespace UnityEngine.UI
vh.GetUIVertexStream(s_Verts);
//================================
// Only main effect modify original vertices.
// Effect modify original vertices.
//================================
if (mainEffect == this)
{
// Calcurate bluring uv from blur factor and texture size.
float blurringUv = m_Blur / graphic.mainTexture.width;
// Pack some effect factors to 1 float.
Vector2 factor = new Vector2(
PackToFloat(m_ToneLevel, 0, blurringUv * 4),
PackToFloat(m_Color.r, m_Color.g, m_Color.b, m_Color.a)
);
PackToFloat(toneLevel, 0, blur / graphic.mainTexture.width * 4),
PackToFloat(effectColor.r, effectColor.g, effectColor.b, effectColor.a)
);
for (int i = 0; i < s_Verts.Count; i++)
{
@@ -262,40 +274,20 @@ namespace UnityEngine.UI
//================================
// Append shadow vertices.
//================================
if (ShadowMode.Shadow <= m_ShadowMode)
{
var inputVertCount = s_Verts.Count;
var start = 0;
var end = inputVertCount;
// Calcurate bluring uv from blur factor and texture size.
float blurringUv = m_ShadowBlur / graphic.mainTexture.width;
// Pack some effect factors to 1 float.
Vector2 factor = new Vector2(
PackToFloat(m_ToneLevel, 0, blurringUv * 4),
PackToFloat(m_ShadowColor.r, m_ShadowColor.g, m_ShadowColor.b, 1)
);
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, m_EffectDistance.x, m_EffectDistance.y, factor);
// Append shadow for Outline.
if (ShadowMode.Outline <= m_ShadowMode)
// Additional Shadows.
for (int i = additionalShadows.Count - 1; 0 <= i; i--)
{
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, m_EffectDistance.x, -m_EffectDistance.y, factor);
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, -m_EffectDistance.x, m_EffectDistance.y, factor);
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, -m_EffectDistance.x, -m_EffectDistance.y, factor);
AdditionalShadow shadow = additionalShadows[i];
ApplyShadow(s_Verts, ref start, ref end, shadow.shadowMode, toneLevel, shadow.shadowBlur / graphic.mainTexture.width * 4, shadow.effectDistance, shadow.shadowColor, shadow.useGraphicAlpha);
}
// Append shadow for Outline8.
if (ShadowMode.Outline8 <= m_ShadowMode)
{
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, -m_EffectDistance.x, 0, factor);
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, 0, -m_EffectDistance.y, factor);
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, m_EffectDistance.x, 0, factor);
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, 0, m_EffectDistance.y, factor);
}
// Shadow.
ApplyShadow(s_Verts, ref start, ref end, shadowMode, toneLevel, shadowBlur / graphic.mainTexture.width * 4, effectDistance, shadowColor, useGraphicAlpha);
}
vh.Clear();
@@ -318,7 +310,7 @@ namespace UnityEngine.UI
/// </summary>
protected virtual void OnValidate()
{
SetDirty(this);
SetDirty(true);
}
#endif
@@ -329,7 +321,42 @@ namespace UnityEngine.UI
/// Append shadow vertices.
/// * It is similar to Shadow component implementation.
/// </summary>
protected void ApplyShadowZeroAlloc(List<UIVertex> verts, ref int start, ref int end, float x, float y, Vector2 factor)
static void ApplyShadow(List<UIVertex> verts, ref int start, ref int end, ShadowMode mode, float toneLevel, float blur, Vector2 effectDistance, Color color, bool useGraphicAlpha)
{
if (ShadowMode.None == mode)
return;
var factor = new Vector2(
PackToFloat(toneLevel, 0, blur),
PackToFloat(color.r, color.g, color.b, 1)
);
// Append Shadow.
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, effectDistance.x, effectDistance.y, factor, color, useGraphicAlpha);
// Append Outline.
if (ShadowMode.Outline <= mode)
{
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, effectDistance.x, -effectDistance.y, factor, color, useGraphicAlpha);
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, -effectDistance.x, effectDistance.y, factor, color, useGraphicAlpha);
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, -effectDistance.x, -effectDistance.y, factor, color, useGraphicAlpha);
}
// Append Outline8.
if (ShadowMode.Outline8 <= mode)
{
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, -effectDistance.x, 0, factor, color, useGraphicAlpha);
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, 0, -effectDistance.y, factor, color, useGraphicAlpha);
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, effectDistance.x, 0, factor, color, useGraphicAlpha);
ApplyShadowZeroAlloc(s_Verts, ref start, ref end, 0, effectDistance.y, factor, color, useGraphicAlpha);
}
}
/// <summary>
/// Append shadow vertices.
/// * It is similar to Shadow component implementation.
/// </summary>
static 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;
@@ -347,8 +374,8 @@ namespace UnityEngine.UI
Vector3 v = vt.position;
vt.position.Set(v.x + x, v.y + y, v.z);
Color vertColor = m_ShadowColor;
vertColor.a = m_UseGraphicAlpha ? m_ShadowColor.a * vt.color.a / 255 : m_ShadowColor.a;
Color vertColor = color;
vertColor.a = useGraphicAlpha ? color.a * vt.color.a / 255 : color.a;
vt.color = vertColor;
// Set UIEffect prameters to vertex.
@@ -367,121 +394,137 @@ namespace UnityEngine.UI
/// <param name="isMaterialDirty">If set to true material dirty.</param>
void SetDirty(bool isMaterialDirty = false)
{
//
if (!mainEffect)
{
mainEffect = GetComponent<UIEffect>();
}
// Only main effect update material.
if (mainEffect != this)
{
m_ToneMode = mainEffect.m_ToneMode;
m_ColorMode = mainEffect.m_ColorMode;
m_BlurMode = mainEffect.m_BlurMode;
return;
}
// Update material if needed.
if (isMaterialDirty && mainEffect == this)
if (isMaterialDirty)
{
const int TONE_SHIFT = 0;
const int TONE_GRAYSCALE = (int)ToneMode.Grayscale;
const int TONE_SEPIA = (int)ToneMode.Sepia;
const int TONE_NEGA = (int)ToneMode.Nega;
const int TONE_PIXEL = (int)ToneMode.Pixel;
const int TONE_MONO = (int)ToneMode.Mono;
const int TONE_CUTOFF = (int)ToneMode.Cutoff;
const int COLOR_SHIFT = 3;
const int COLOR_SET = (int)ColorMode.Set;
const int COLOR_ADD = (int)ColorMode.Add;
const int COLOR_SUB = (int)ColorMode.Sub;
const int BLUR_SHIFT = 5;
const int BLUR_FAST = (int)BlurMode.Fast;
const int BLUR_DETAIL = (int)BlurMode.Detail;
// Calculate shader keyword identifier from effect modes.
int identifier = ((int)m_ToneMode << TONE_SHIFT) | ((int)m_ColorMode << COLOR_SHIFT) | ((int)m_BlurMode << BLUR_SHIFT);
// When all effect modes are disable(None), graphic uses default material.
if (identifier == 0)
{
graphic.material = null;
graphic.SetVerticesDirty();
return;
}
// Generate and cache new material by given identifier.
if (!s_SharedMaterials[identifier])
{
if (!s_SharedMaterials[0])
{
s_SharedMaterials[0] = new Material(shader);
}
Material mat = new Material(s_SharedMaterials[0]);
// Bits for tone effect.
int toneBits = identifier >> TONE_SHIFT;
mat.EnableKeyword(
TONE_CUTOFF == (toneBits & TONE_CUTOFF) ? "UI_TONE_CUTOFF"
: TONE_MONO == (toneBits & TONE_MONO) ? "UI_TONE_MONO"
: TONE_PIXEL == (toneBits & TONE_PIXEL) ? "UI_TONE_PIXEL"
: TONE_NEGA == (toneBits & TONE_NEGA) ? "UI_TONE_NEGA"
: TONE_SEPIA == (toneBits & TONE_SEPIA) ? "UI_TONE_SEPIA"
: TONE_GRAYSCALE == (toneBits & TONE_GRAYSCALE) ? "UI_TONE_GRAYSCALE"
: "UI_TONE_OFF"
);
// Bits for color effect.
int colorBits = identifier >> COLOR_SHIFT;
mat.EnableKeyword(
COLOR_SUB == (colorBits & COLOR_SUB) ? "UI_COLOR_SUB"
: COLOR_ADD == (colorBits & COLOR_ADD) ? "UI_COLOR_ADD"
: COLOR_SET == (colorBits & COLOR_SET) ? "UI_COLOR_SET"
: "UI_COLOR_OFF"
);
// Bits for blur effect.
int blurBits = identifier >> BLUR_SHIFT;
mat.EnableKeyword(
BLUR_DETAIL == (blurBits & BLUR_DETAIL) ? "UI_BLUR_DETAIL"
: BLUR_FAST == (blurBits & BLUR_FAST) ? "UI_BLUR_FAST"
: "UI_BLUR_OFF"
);
mat.name += identifier.ToString();
s_SharedMaterials[identifier] = mat;
}
graphic.material = s_SharedMaterials[identifier];
graphic.material = GetSharedMaterial(shader, toneMode, colorMode, blurMode);
}
graphic.SetVerticesDirty();
}
/// <summary>
/// Get shared material for identifier.
/// </summary>
/// <param name="isMaterialDirty">If set to true material dirty.</param>
public static Material GetSharedMaterial(Shader shader, ToneMode toneMode, ColorMode colorMode, BlurMode blurMode, bool nullDefault = true)
{
// Update material if needed.
const int TONE_SHIFT = 0;
const int TONE_GRAYSCALE = (int)ToneMode.Grayscale;
const int TONE_SEPIA = (int)ToneMode.Sepia;
const int TONE_NEGA = (int)ToneMode.Nega;
const int TONE_PIXEL = (int)ToneMode.Pixel;
const int TONE_MONO = (int)ToneMode.Mono;
const int TONE_CUTOFF = (int)ToneMode.Cutoff;
const int COLOR_SHIFT = 3;
const int COLOR_SET = (int)ColorMode.Set;
const int COLOR_ADD = (int)ColorMode.Add;
const int COLOR_SUB = (int)ColorMode.Sub;
const int BLUR_SHIFT = 5;
const int BLUR_FAST = (int)BlurMode.Fast;
const int BLUR_MEDIUM = (int)BlurMode.Medium;
const int BLUR_DETAIL = (int)BlurMode.Detail;
// Calculate shader keyword identifier from effect modes.
int identifier = ((int)toneMode << TONE_SHIFT)
| ((int)colorMode << COLOR_SHIFT)
| ((int)blurMode << BLUR_SHIFT);
// When all effect modes are disable(None), graphic uses default material.
if (nullDefault && identifier == 0)
{
return null;
}
Material[] materials;
if (!s_SharedMaterials.TryGetValue(shader, out materials))
{
materials = new Material[128];
s_SharedMaterials.Add(shader, materials);
}
// Generate and cache new material by given identifier.
if (!materials[identifier])
{
if (!materials[0])
{
materials[0] = new Material(shader);
materials[0].name += identifier.ToString();
}
if (identifier == 0)
{
return materials[0];
}
Material mat = new Material(materials[0]);
// Bits for tone effect.
int toneBits = identifier >> TONE_SHIFT;
mat.EnableKeyword(
TONE_CUTOFF == (toneBits & TONE_CUTOFF) ? "UI_TONE_CUTOFF"
: TONE_MONO == (toneBits & TONE_MONO) ? "UI_TONE_MONO"
: TONE_PIXEL == (toneBits & TONE_PIXEL) ? "UI_TONE_PIXEL"
: TONE_NEGA == (toneBits & TONE_NEGA) ? "UI_TONE_NEGA"
: TONE_SEPIA == (toneBits & TONE_SEPIA) ? "UI_TONE_SEPIA"
: TONE_GRAYSCALE == (toneBits & TONE_GRAYSCALE) ? "UI_TONE_GRAYSCALE"
: "UI_TONE_OFF"
);
// Bits for color effect.
int colorBits = identifier >> COLOR_SHIFT;
mat.EnableKeyword(
COLOR_SUB == (colorBits & COLOR_SUB) ? "UI_COLOR_SUB"
: COLOR_ADD == (colorBits & COLOR_ADD) ? "UI_COLOR_ADD"
: COLOR_SET == (colorBits & COLOR_SET) ? "UI_COLOR_SET"
: "UI_COLOR_OFF"
);
// Bits for blur effect.
int blurBits = identifier >> BLUR_SHIFT;
mat.EnableKeyword(
BLUR_DETAIL == (blurBits & BLUR_DETAIL) ? "UI_BLUR_DETAIL"
: BLUR_MEDIUM == (blurBits & BLUR_MEDIUM) ? "UI_BLUR_MEDIUM"
: BLUR_FAST == (blurBits & BLUR_FAST) ? "UI_BLUR_FAST"
: "UI_BLUR_OFF"
);
mat.name += identifier.ToString();
materials[identifier] = mat;
}
return materials[identifier];
}
/// <summary>
/// Pack 4 low-precision [0-1] floats values to a float.
/// Each value [0-1] has 64 steps(6 bits).
/// </summary>
static float PackToFloat(float x, float y, float z, float w)
{
return (Mathf.FloorToInt(w * PACKER_PRECISION) << PACKER_SHIFT_3)
+ (Mathf.FloorToInt(z * PACKER_PRECISION) << PACKER_SHIFT_2)
+ (Mathf.FloorToInt(y * PACKER_PRECISION) << PACKER_SHIFT_1)
+ Mathf.FloorToInt(x * PACKER_PRECISION);
{
const int PRECISION = (1 << 6) - 1;
return (Mathf.FloorToInt(w * PRECISION) << 18)
+ (Mathf.FloorToInt(z * PRECISION) << 12)
+ (Mathf.FloorToInt(y * PRECISION) << 6)
+ Mathf.FloorToInt(x * PRECISION);
}
/// <summary>
/// Pack 3 low-precision [0-1] floats values to a float.
/// The z value is a little high precision(12 bits).
/// The x and y values [0-1] have 64 steps(6 bits).
/// The z value [0-1] is a little high precision(12 bits).
/// </summary>
static float PackToFloat(float x, float y, float z)
{
const int PRECISION_BITS_HIGH = (1 << PACKER_SHIFT_2) - 1;
{
const int PRECISION = (1 << 6) - 1;
const int PRECISION_HIGH = (1 << 12) - 1;
return (Mathf.FloorToInt(z * PRECISION_BITS_HIGH) << PACKER_SHIFT_2)
+ (Mathf.FloorToInt(y * PACKER_PRECISION) << PACKER_SHIFT_1)
+ Mathf.FloorToInt(x * PACKER_PRECISION);
return (Mathf.FloorToInt(z * PRECISION_HIGH) << 12)
+ (Mathf.FloorToInt(y * PRECISION) << 6)
+ Mathf.FloorToInt(x * PRECISION);
}
}
}
-7
View File
@@ -1,7 +0,0 @@
Copyright 2017 mob-sakai
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+1
View File
@@ -0,0 +1 @@
./Assets/UIEffect/LICENSE.txt
Binary file not shown.