mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-20 01:42:37 +08:00
Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 811f5762e6 | |||
| 2f63adfba0 | |||
| 7cb8325e44 | |||
| eafb9ce365 | |||
| 0ef6027371 | |||
| 92f9611a39 | |||
| edf694313f | |||
| 894c5610d0 | |||
| f7175c0373 | |||
| 238a17d57d | |||
| 97237b3aa8 | |||
| 1be0cd45db | |||
| 9799069633 | |||
| 43bc2e29a8 | |||
| 4a6007a467 | |||
| 08e9ba73d7 | |||
| aeb78ed577 | |||
| 7fc8b1599a | |||
| c9fe854b5d | |||
| 20a6ca0815 | |||
| f2df1889d1 | |||
| bbe57df7a0 | |||
| e9522d3f0e | |||
| d0a3ca6090 | |||
| a66baea1e8 | |||
| 5bee8adc83 | |||
| 9a97c50c54 | |||
| bc20f28ac9 | |||
| d9bf0e12fe | |||
| 2b43bc42d4 | |||
| 23ac3985d2 | |||
| e17b4a0bfd | |||
| 155873669d | |||
| 54825eedc8 | |||
| bdd8e08572 | |||
| 88609f5e36 | |||
| 476a0ba23d | |||
| 9d98c5d3e1 | |||
| bc11095020 | |||
| f74279fb83 |
@@ -21,7 +21,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
- develop-preview
|
||||
- "develop-*"
|
||||
tags:
|
||||
- "!*"
|
||||
paths-ignore:
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97c7740b360fd49ea9da163b5b877c8e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,754 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481676, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 12
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 256
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVRDenoiserTypeDirect: 1
|
||||
m_PVRDenoiserTypeIndirect: 1
|
||||
m_PVRDenoiserTypeAO: 1
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_LightingSettings: {fileID: 0}
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &320007018
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 320007022}
|
||||
- component: {fileID: 320007021}
|
||||
- component: {fileID: 320007020}
|
||||
- component: {fileID: 320007019}
|
||||
m_Layer: 5
|
||||
m_Name: Canvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &320007019
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 320007018}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &320007020
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 320007018}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 1
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 200, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 0
|
||||
--- !u!223 &320007021
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 320007018}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_AdditionalShaderChannelsFlag: 1
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!224 &320007022
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 320007018}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1299999091}
|
||||
- {fileID: 591404685}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!1 &591404684
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 591404685}
|
||||
- component: {fileID: 591404687}
|
||||
- component: {fileID: 591404686}
|
||||
m_Layer: 5
|
||||
m_Name: Image (1)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!224 &591404685
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 591404684}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 320007022}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 44.9, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &591404686
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 591404684}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &591404687
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 591404684}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &1076137586
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1076137589}
|
||||
- component: {fileID: 1076137588}
|
||||
- component: {fileID: 1076137587}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &1076137587
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1076137586}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &1076137588
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1076137586}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &1076137589
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1076137586}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1299999090
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1299999091}
|
||||
- component: {fileID: 1299999094}
|
||||
- component: {fileID: 1299999093}
|
||||
- component: {fileID: 1299999096}
|
||||
- component: {fileID: 1299999095}
|
||||
m_Layer: 5
|
||||
m_Name: Image
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1299999091
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1299999090}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 320007022}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 44.9, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1299999093
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1299999090}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &1299999094
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1299999090}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &1299999095
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1299999090}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 90ac5d06c7b714c29a6b7b3b80e443a7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_CullingMask: -1
|
||||
m_Direction: 0
|
||||
m_Curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 1
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 1
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
m_Delay: 0
|
||||
m_Duration: 1
|
||||
m_Interval: 0
|
||||
m_PlayOnEnable: 1
|
||||
m_WrapMode: 1
|
||||
m_UpdateMode: 0
|
||||
--- !u!114 &1299999096
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1299999090}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 938fce054c42f40a3969e27a88d9bdd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_ToneFilter: 0
|
||||
m_ToneIntensity: 1
|
||||
m_ToneParams: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_ColorFilter: 0
|
||||
m_ColorIntensity: 1
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_SamplingFilter: 0
|
||||
m_SamplingIntensity: 0.5
|
||||
m_SamplingScale: 1
|
||||
m_TransitionFilter: 0
|
||||
m_TransitionRate: 0.5
|
||||
m_TransitionReverse: 0
|
||||
m_TransitionTex: {fileID: 0}
|
||||
m_TransitionTexScale: {x: 1, y: 1}
|
||||
m_TransitionTexOffset: {x: 0, y: 0}
|
||||
m_TransitionRotation: 0
|
||||
m_TransitionKeepAspectRatio: 1
|
||||
m_TransitionWidth: 0.2
|
||||
m_TransitionSoftness: 0.2
|
||||
m_TransitionColorFilter: 6
|
||||
m_TransitionColor: {r: 0, g: 0.5, b: 1, a: 1}
|
||||
m_TargetMode: 0
|
||||
m_TargetColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_TargetRange: 0.1
|
||||
m_TargetSoftness: 0.5
|
||||
m_BlendType: 1
|
||||
m_SrcBlendMode: 1
|
||||
m_DstBlendMode: 10
|
||||
m_ShadowMode: 0
|
||||
m_ShadowDistance: {x: 1, y: -1}
|
||||
m_ShadowIteration: 1
|
||||
m_ShadowFade: 0.9
|
||||
m_ShadowMirrorScale: 0.5
|
||||
m_ShadowBlurIntensity: 1
|
||||
m_ShadowColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_ShadowGlow: 0
|
||||
m_GradationMode: 2
|
||||
m_GradationColor1: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_GradationColor2: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_GradationGradient:
|
||||
serializedVersion: 2
|
||||
key0: {r: 1, g: 0, b: 0, a: 1}
|
||||
key1: {r: 1, g: 0.8571428, b: 0, a: 1}
|
||||
key2: {r: 0.2857144, g: 1, b: 0, a: 0}
|
||||
key3: {r: 0, g: 1, b: 0.57142854, a: 0}
|
||||
key4: {r: 0, g: 0.5714288, b: 1, a: 0}
|
||||
key5: {r: 0.28571415, g: 0, b: 1, a: 0}
|
||||
key6: {r: 1, g: 0, b: 0.8571429, a: 0}
|
||||
key7: {r: 1, g: 0, b: 0, a: 0}
|
||||
ctime0: 0
|
||||
ctime1: 9830
|
||||
ctime2: 18724
|
||||
ctime3: 28720
|
||||
ctime4: 38165
|
||||
ctime5: 46838
|
||||
ctime6: 56173
|
||||
ctime7: 65535
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 0
|
||||
atime3: 0
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 8
|
||||
m_NumAlphaKeys: 2
|
||||
m_GradationOffset: 1
|
||||
m_GradationScale: 2
|
||||
m_AllowExtendVertex: 1
|
||||
--- !u!1 &1303535690
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1303535693}
|
||||
- component: {fileID: 1303535692}
|
||||
- component: {fileID: 1303535691}
|
||||
m_Layer: 0
|
||||
m_Name: EventSystem
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1303535691
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1303535690}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_SendPointerHoverToParent: 1
|
||||
m_HorizontalAxis: Horizontal
|
||||
m_VerticalAxis: Vertical
|
||||
m_SubmitButton: Submit
|
||||
m_CancelButton: Cancel
|
||||
m_InputActionsPerSecond: 10
|
||||
m_RepeatDelay: 0.5
|
||||
m_ForceModuleActive: 0
|
||||
--- !u!114 &1303535692
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1303535690}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_FirstSelected: {fileID: 0}
|
||||
m_sendNavigationEvents: 1
|
||||
m_DragThreshold: 10
|
||||
--- !u!4 &1303535693
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1303535690}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1740148341
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1740148343}
|
||||
- component: {fileID: 1740148342}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &1740148342
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1740148341}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 10
|
||||
m_Type: 1
|
||||
m_Shape: 0
|
||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &1740148343
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1740148341}
|
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54b78b8690dfe482aaaad53253d23214
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2a4c1061dec2448abe5ae1b412140af
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,108 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: CarterOne-Regular SDF - Mobile
|
||||
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Cube:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _FaceTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: -5656930091445551790, guid: bc6ef582a0efa420683ff976adff235a,
|
||||
type: 2}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OutlineTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _Ambient: 0.5
|
||||
- _Bevel: 0.5
|
||||
- _BevelClamp: 0
|
||||
- _BevelOffset: 0
|
||||
- _BevelRoundness: 0
|
||||
- _BevelWidth: 0
|
||||
- _BumpFace: 0
|
||||
- _BumpOutline: 0
|
||||
- _ColorMask: 15
|
||||
- _CullMode: 0
|
||||
- _Diffuse: 0.5
|
||||
- _FaceDilate: 0
|
||||
- _FaceUVSpeedX: 0
|
||||
- _FaceUVSpeedY: 0
|
||||
- _GlowInner: 0.05
|
||||
- _GlowOffset: 0
|
||||
- _GlowOuter: 0.05
|
||||
- _GlowPower: 0.75
|
||||
- _GradientScale: 10
|
||||
- _LightAngle: 3.1416
|
||||
- _MaskSoftnessX: 0
|
||||
- _MaskSoftnessY: 0
|
||||
- _OutlineSoftness: 0
|
||||
- _OutlineUVSpeedX: 0
|
||||
- _OutlineUVSpeedY: 0
|
||||
- _OutlineWidth: 0
|
||||
- _PerspectiveFilter: 0.875
|
||||
- _Reflectivity: 10
|
||||
- _ScaleRatioA: 0.9
|
||||
- _ScaleRatioB: 0.73125
|
||||
- _ScaleRatioC: 0.73125
|
||||
- _ScaleX: 1
|
||||
- _ScaleY: 1
|
||||
- _ShaderFlags: 0
|
||||
- _Sharpness: 0
|
||||
- _SpecularPower: 2
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _TextureHeight: 1024
|
||||
- _TextureWidth: 1024
|
||||
- _UnderlayDilate: 0
|
||||
- _UnderlayOffsetX: 0
|
||||
- _UnderlayOffsetY: 0
|
||||
- _UnderlaySoftness: 0
|
||||
- _VertexOffsetX: 0
|
||||
- _VertexOffsetY: 0
|
||||
- _WeightBold: 0.75
|
||||
- _WeightNormal: 0
|
||||
m_Colors:
|
||||
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
||||
- _EnvMatrixRotation: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _GlowColor: {r: 0, g: 1, b: 0, a: 0.5}
|
||||
- _MaskCoord: {r: 0, g: 0, b: 32767, a: 32767}
|
||||
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _ReflectFaceColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f0416a8fecb64e86b4d6c301e638f2d
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4e892194038942ed9ff756a9f5b0dba
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15dc1da3b4d49479897101a68acaa39f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38bc56dae9c524546aba0a50b4e970af
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
using Coffee.UIEffects;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[RequireComponent(typeof(UIEffectTweener))]
|
||||
public class UIEffectTweenerControl : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Text m_Info;
|
||||
|
||||
[SerializeField]
|
||||
private Slider m_SeekBar;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject m_SeekBarBgInterval1;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject m_SeekBarBgDuration2;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject m_SeekBarBgInterval2;
|
||||
|
||||
private UIEffectTweener _tweener;
|
||||
private UIEffectTweener tweener => _tweener != null ? _tweener : GetComponent<UIEffectTweener>();
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (m_Info)
|
||||
{
|
||||
var tw = tweener;
|
||||
m_Info.text =
|
||||
$"{tw.time:F2}/{tw.totalTime:F2} ({tw.rate:F2}), {tw.direction}, isTweening={tw.isTweening}, isDelaying={tw.isDelaying}, isPaused={tw.isPaused}";
|
||||
}
|
||||
|
||||
if (m_SeekBar)
|
||||
{
|
||||
m_SeekBar.value = tweener.time / tweener.totalTime;
|
||||
}
|
||||
|
||||
if (m_SeekBarBgInterval1)
|
||||
{
|
||||
m_SeekBarBgInterval1.SetActive(UIEffectTweener.WrapMode.Loop <= tweener.wrapMode);
|
||||
}
|
||||
|
||||
if (m_SeekBarBgDuration2)
|
||||
{
|
||||
m_SeekBarBgDuration2.SetActive(UIEffectTweener.WrapMode.PingPongOnce <= tweener.wrapMode);
|
||||
}
|
||||
|
||||
if (m_SeekBarBgInterval2)
|
||||
{
|
||||
m_SeekBarBgInterval2.SetActive(UIEffectTweener.WrapMode.PingPongLoop <= tweener.wrapMode);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetWrapMode(int value)
|
||||
{
|
||||
tweener.wrapMode = (UIEffectTweener.WrapMode)value;
|
||||
}
|
||||
|
||||
public void SetPlayForwardOnEnable(bool value)
|
||||
{
|
||||
tweener.playOnEnable = value
|
||||
? UIEffectTweener.PlayOnEnable.Forward
|
||||
: UIEffectTweener.PlayOnEnable.None;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f901d0537c0db429e808496022199910
|
||||
guid: 28bd9918eae59466bacbec5522174db6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dda1700a67f894a5cafc5d16748cf4fb
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -18,11 +18,12 @@ MonoBehaviour:
|
||||
m_EnabledInEditor: 1
|
||||
m_AlwaysIncludeAssembly: 1
|
||||
m_InstantiateOnLoad: 1
|
||||
m_Prefab: {fileID: 7211429669315726685, guid: 78a484d8074c74e9c80786d1e55962c8,
|
||||
m_Prefab: {fileID: 4567906826058368312, guid: 7cebff2d255b9433cbe23b243c193329,
|
||||
type: 3}
|
||||
m_Interval: 0.5
|
||||
m_Anchor: 0
|
||||
m_Width: 750
|
||||
m_Width: 800
|
||||
m_HelpUrl: https://github.com/mob-sakai/UIEffect
|
||||
m_CustomMonitorItems:
|
||||
- m_Format: Screen:{0}x{1}
|
||||
m_Arg0:
|
||||
|
||||
@@ -29,64 +29,15 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY SAMPLING_BLUR_FAST SHADOW_COLOR_REPLACE TARGET_HUE
|
||||
TONE_GRAYSCALE TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_ADDITIVE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_ADDITIVE SAMPLING_BLUR_FAST TONE_GRAYSCALE TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: COLOR_REPLACE SAMPLING_BLUR_FAST
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_DETAIL
|
||||
passType: 0
|
||||
- keywords: TONE_GRAYSCALE
|
||||
passType: 0
|
||||
- keywords: TONE_SEPIA
|
||||
passType: 0
|
||||
- keywords: TONE_NEGATIVE
|
||||
passType: 0
|
||||
- keywords: TONE_RETRO
|
||||
passType: 0
|
||||
- keywords: TONE_POSTERIZE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY
|
||||
passType: 0
|
||||
- keywords: COLOR_ADDITIVE
|
||||
passType: 0
|
||||
- keywords: COLOR_SUBTRACTIVE
|
||||
passType: 0
|
||||
- keywords: COLOR_REPLACE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_LUMINANCE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_ADDITIVE
|
||||
passType: 0
|
||||
- keywords: COLOR_HSV_MODIFIER
|
||||
passType: 0
|
||||
- keywords: COLOR_CONTRAST
|
||||
passType: 0
|
||||
- keywords: COLOR_HSV_MODIFIER TARGET_HUE
|
||||
passType: 0
|
||||
- keywords: COLOR_REPLACE SAMPLING_BLUR_FAST
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_FAST
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_FAST TONE_GRAYSCALE
|
||||
passType: 0
|
||||
- keywords: COLOR_ADDITIVE SAMPLING_BLUR_FAST
|
||||
passType: 0
|
||||
- keywords: COLOR_ADDITIVE SAMPLING_BLUR_FAST UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: COLOR_HSV_MODIFIER
|
||||
passType: 0
|
||||
- keywords: COLOR_HSV_MODIFIER TARGET_HUE
|
||||
passType: 0
|
||||
- keywords: COLOR_HSV_MODIFIER TARGET_LUMINANCE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_ADDITIVE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_ADDITIVE SAMPLING_BLUR_FAST TONE_GRAYSCALE TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
- keywords: COLOR_MULTIPLY_ADDITIVE SAMPLING_RGB_SHIFT TONE_GRAYSCALE TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_LUMINANCE
|
||||
@@ -105,14 +56,6 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_MEDIUM
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_DETAIL
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_FAST
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_FAST TONE_GRAYSCALE
|
||||
passType: 0
|
||||
- keywords: SAMPLING_BLUR_MEDIUM
|
||||
passType: 0
|
||||
- keywords: SAMPLING_EDGE_ALPHA
|
||||
passType: 0
|
||||
- keywords: SAMPLING_EDGE_LUMINANCE
|
||||
@@ -127,47 +70,6 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: SAMPLING_RGB_SHIFT
|
||||
passType: 0
|
||||
- keywords: SAMPLING_EDGE_LUMINANCE
|
||||
passType: 0
|
||||
- keywords: SAMPLING_EDGE_ALPHA
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TONE_RETRO
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TONE_RETRO UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: SAMPLING_RGB_SHIFT
|
||||
passType: 0
|
||||
- keywords: TONE_GRAYSCALE
|
||||
passType: 0
|
||||
- keywords: TONE_NEGATIVE
|
||||
passType: 0
|
||||
- keywords: TONE_POSTERIZE
|
||||
passType: 0
|
||||
- keywords: TONE_RETRO
|
||||
passType: 0
|
||||
- keywords: TRANSITION_BURN TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
passType: 0
|
||||
- keywords: TRANSITION_BURN TRANSITION_COLOR_MULTIPLY_ADDITIVE UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: TRANSITION_FADE
|
||||
passType: 0
|
||||
- keywords: TRANSITION_CUTOFF
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_REPLACE TRANSITION_MELT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_DISSOLVE UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: COLOR_MULTIPLY_ADDITIVE SAMPLING_BLUR_FAST TONE_GRAYSCALE TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TONE_RETRO UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TONE_GRAYSCALE
|
||||
passType: 0
|
||||
- keywords: TONE_NEGATIVE
|
||||
@@ -190,28 +92,6 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MELT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_SHINY
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_SHINY UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MASK
|
||||
passType: 0
|
||||
- keywords: SAMPLING_EDGE_LUMINANCE TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MASK
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MELT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MELT UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_BURN TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
passType: 0
|
||||
- keywords: TRANSITION_BURN TRANSITION_COLOR_MULTIPLY_ADDITIVE UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: COLOR_HSV_MODIFIER TARGET_HUE
|
||||
passType: 0
|
||||
- keywords: COLOR_HSV_MODIFIER TARGET_LUMINANCE
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_DISSOLVE
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MELT UNITY_UI_CLIP_RECT
|
||||
passType: 0
|
||||
- keywords: TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_SHINY
|
||||
@@ -224,35 +104,45 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: TRANSITION_FADE
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: e65241fa80a374114b3f55ed746c04d9, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TRANSITION_CUTOFF
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 935b7be1c88464d2eb87204fdfab5a38, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: GLOW_ON TONE_RETRO UNDERLAY_ON
|
||||
- keywords: COLOR_ADDITIVE GLOW_ON SAMPLING_BLUR_FAST UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: COLOR_HSV_MODIFIER GLOW_ON UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: COLOR_ADDITIVE GLOW_ON SAMPLING_BLUR_FAST UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON SAMPLING_BLUR_DETAIL UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON SAMPLING_PIXELATION UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TONE_RETRO
|
||||
passType: 0
|
||||
- keywords: GLOW_ON SAMPLING_RGB_SHIFT UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON SAMPLING_EDGE_LUMINANCE UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_REPLACE TRANSITION_MELT UNDERLAY_ON
|
||||
- keywords: GLOW_ON SAMPLING_PIXELATION UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON SAMPLING_RGB_SHIFT UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON SHADOW_COLOR_REPLACE TRANSITION_BURN TRANSITION_COLOR_MULTIPLY_ADDITIVE
|
||||
UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TONE_RETRO UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_BURN TRANSITION_COLOR_MULTIPLY_ADDITIVE UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_DISSOLVE
|
||||
UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_SHINY UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_MELT UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_BURN TRANSITION_COLOR_MULTIPLY_ADDITIVE UNDERLAY_ON
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_SHINY UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: GLOW_ON TRANSITION_COLOR_REPLACE TRANSITION_MELT UNDERLAY_ON
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TONE_RETRO
|
||||
passType: 0
|
||||
- keywords: SAMPLING_RGB_SHIFT TRANSITION_CUTOFF
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: c67f821adbb6348a3a21573a25b55de0, type: 3}
|
||||
second:
|
||||
@@ -284,6 +174,16 @@ ShaderVariantCollection:
|
||||
passType: 0
|
||||
- keywords: SAMPLING_PIXELATION TONE_RETRO
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: d1cb940e3804b4adcaf9b22083fadfad, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TRANSITION_CUTOFF
|
||||
passType: 0
|
||||
- first: {fileID: 4800000, guid: 63a1dba10bff94661a909d63808a9a3b, type: 3}
|
||||
second:
|
||||
variants:
|
||||
- keywords: SAMPLING_RGB_SHIFT TRANSITION_CUTOFF
|
||||
passType: 0
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -300,6 +200,9 @@ MonoBehaviour:
|
||||
m_RuntimePresets:
|
||||
- {fileID: 1645081683573595507, guid: 3b09ad143990c4c8795c6e93760e132a, type: 3}
|
||||
- {fileID: 1645081683573595507, guid: 4f70ff0f1e25b4388b9bcb38d619f7bf, type: 3}
|
||||
m_FallbackVariantBehaviour: 0
|
||||
m_UnregisteredShaderVariants: []
|
||||
m_ShaderVariantCollection: {fileID: -8740588384831342173}
|
||||
m_ShaderVariantRegistry:
|
||||
m_OptionalShaders: []
|
||||
m_Asset: {fileID: -8740588384831342173}
|
||||
m_ErrorOnUnregisteredVariant: 0
|
||||
m_UnregisteredVariants: []
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9a477d4a32184f16b50f56f7de5fa4e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 962016ab124fa4720be1e24ff58c8522
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "Coffee.UIEffect.EditorTests",
|
||||
"references": [
|
||||
"Coffee.UIEffect"
|
||||
],
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 182e53eada385475e905b8ca6d82d6ad
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor;
|
||||
|
||||
public class ReflectionTests
|
||||
{
|
||||
[Test]
|
||||
public void ShaderVariantCollectionInspector_DrawShaderEntry()
|
||||
{
|
||||
var type = Type.GetType("UnityEditor.ShaderVariantCollectionInspector, UnityEditor");
|
||||
Assert.IsNotNull(type, "'UnityEditor.ShaderVariantCollectionInspector, UnityEditor' is not found");
|
||||
|
||||
var miDrawShaderEntry = type.GetMethod("DrawShaderEntry", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
Assert.IsNotNull(miDrawShaderEntry);
|
||||
|
||||
var parameters = miDrawShaderEntry.GetParameters();
|
||||
Assert.AreEqual(1, parameters.Length);
|
||||
Assert.AreEqual(typeof(int), parameters[0].ParameterType);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializedProperty_gradientValue()
|
||||
{
|
||||
var piGradient = typeof(SerializedProperty)
|
||||
.GetProperty("gradientValue", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
Assert.IsNotNull(piGradient);
|
||||
|
||||
Assert.IsTrue(piGradient.CanRead);
|
||||
Assert.IsTrue(piGradient.CanWrite);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c5d391ce913d41fb9118c3d28b21059
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"com.coffee.development": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/Development",
|
||||
"com.coffee.minimal-resource": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/MinimalResource",
|
||||
"com.coffee.nano-monitor": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/NanoMonitor",
|
||||
"com.unity.ide.rider": "3.0.34",
|
||||
"com.unity.test-framework": "1.1.33",
|
||||
|
||||
@@ -5,7 +5,14 @@
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "805474a9e49f534ff01bf75405bcd415ed57083c"
|
||||
"hash": "5d0bd14be288153555f975240608e7ee1576b091"
|
||||
},
|
||||
"com.coffee.minimal-resource": {
|
||||
"version": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/MinimalResource",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "52987fb6e66e7fc48498d8d164c3c8808de4de6b"
|
||||
},
|
||||
"com.coffee.nano-monitor": {
|
||||
"version": "https://github.com/mob-sakai/Coffee.Internal.git?path=Packages/NanoMonitor",
|
||||
@@ -14,7 +21,7 @@
|
||||
"dependencies": {
|
||||
"com.unity.ugui": "1.0.0"
|
||||
},
|
||||
"hash": "4e5f735ccf956ee469b5014ae781068c49a2825d"
|
||||
"hash": "5d0bd14be288153555f975240608e7ee1576b091"
|
||||
},
|
||||
"com.coffee.ui-effect": {
|
||||
"version": "file:src",
|
||||
|
||||
@@ -1,3 +1,55 @@
|
||||
# [5.2.0](https://github.com/mob-sakai/UIEffect/compare/5.1.0...5.2.0) (2025-01-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `Gradation` properties do not update when a preset is loaded ([edf6943](https://github.com/mob-sakai/UIEffect/commit/edf694313f101b66f760bca64593fb87037dcb3d)), closes [#291](https://github.com/mob-sakai/UIEffect/issues/291)
|
||||
* an error occurs when saving a preset ([894c561](https://github.com/mob-sakai/UIEffect/commit/894c5610d044f211067037b6c69f9860ac496ffc)), closes [#293](https://github.com/mob-sakai/UIEffect/issues/293)
|
||||
* fix gradation gradient edge (angle gradient) ([0ef6027](https://github.com/mob-sakai/UIEffect/commit/0ef60273714c7b68131f2f0d233b16335a5cd367))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* `Angle Gradient` gradation supports fixed mode gradient ([7cb8325](https://github.com/mob-sakai/UIEffect/commit/7cb8325e445350d2175865f736186f719e1cbe00))
|
||||
* `Angle Gradient` gradation supports RectTransform pivot ([2f63adf](https://github.com/mob-sakai/UIEffect/commit/2f63adfba057bec7f8183a5b34654cdf84163a34))
|
||||
* add `Use HDR Color Picker` option for project settings (editor) ([1be0cd4](https://github.com/mob-sakai/UIEffect/commit/1be0cd45db952d05e51d508c58f65a6541df9de0)), closes [#290](https://github.com/mob-sakai/UIEffect/issues/290)
|
||||
* the `Allow To Modify Mesh Shape` property should remain unchanged when loading a preset ([f7175c0](https://github.com/mob-sakai/UIEffect/commit/f7175c037371278eb7a0c7883cffccb5c31dba0a)), closes [#294](https://github.com/mob-sakai/UIEffect/issues/294)
|
||||
* the `Sampling Scale` property should remain unchanged when loading a preset ([238a17d](https://github.com/mob-sakai/UIEffect/commit/238a17d57ddf1f6b859ce830e80a1be6c3d739f1)), closes [#292](https://github.com/mob-sakai/UIEffect/issues/292)
|
||||
|
||||
# [5.1.0](https://github.com/mob-sakai/UIEffect/compare/5.0.2...5.1.0) (2024-12-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* changing the `shadowMirrorScale` property via code does not update the effect ([d9bf0e1](https://github.com/mob-sakai/UIEffect/commit/d9bf0e12fe918fc36120be3e1df2acbb00b1762b))
|
||||
* fix reverse direction mode for UIEffectTweener ([54825ee](https://github.com/mob-sakai/UIEffect/commit/54825eedc8070e74fc276e1e08ea0073cf265189)), closes [#281](https://github.com/mob-sakai/UIEffect/issues/281) [#282](https://github.com/mob-sakai/UIEffect/issues/282) [#283](https://github.com/mob-sakai/UIEffect/issues/283)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add `Color Glow`, `Transition Color Glow` and `Shadow Color Glow` options ([e9522d3](https://github.com/mob-sakai/UIEffect/commit/e9522d3f0e3bc0c429ef32f240625e903ca790ee))
|
||||
* add `GradationMode.Angle` and `GradationMode.AngleGradient` ([08e9ba7](https://github.com/mob-sakai/UIEffect/commit/08e9ba73d78ba52502a6e795587441061377cd99))
|
||||
* add `OnComplete` event for UIEffectTweener ([aeb78ed](https://github.com/mob-sakai/UIEffect/commit/aeb78ed577d70c47aacd754ea2aa3916e6e49c1b)), closes [#289](https://github.com/mob-sakai/UIEffect/issues/289) [#188](https://github.com/mob-sakai/UIEffect/issues/188)
|
||||
* add `PlayOnEnable` option for UIEffectTweener ([1558736](https://github.com/mob-sakai/UIEffect/commit/155873669d77fc3281caaa0fc9f861e62aa489f2))
|
||||
* add `SamplingScale` option ([2b43bc4](https://github.com/mob-sakai/UIEffect/commit/2b43bc42d4a9e0a1c224139ccf91f7a6f76656fc)), closes [#269](https://github.com/mob-sakai/UIEffect/issues/269)
|
||||
* add `Shadow Color` and `Shadow Blur` options ([d0a3ca6](https://github.com/mob-sakai/UIEffect/commit/d0a3ca60904c0eebf63178a0fb899bb17ecefe75))
|
||||
* add a button to swap gradation colors (editor) ([20a6ca0](https://github.com/mob-sakai/UIEffect/commit/20a6ca0815aaa899934fde318beecc1dde5e1132))
|
||||
* add option to not automatically plays tweener effect ([88609f5](https://github.com/mob-sakai/UIEffect/commit/88609f5e368e38224a698270113b4f3190580a19))
|
||||
* automatically display a dialog to import TextMeshPro support ([f2df188](https://github.com/mob-sakai/UIEffect/commit/f2df1889d152ae68926067978c60b4810fdef3f1))
|
||||
* gradation feature ([bbe57df](https://github.com/mob-sakai/UIEffect/commit/bbe57df7a0a184793bd6d98a2b929055f69860b3)), closes [#277](https://github.com/mob-sakai/UIEffect/issues/277) [#66](https://github.com/mob-sakai/UIEffect/issues/66)
|
||||
* on-demand UIEffect shader support ([bdd8e08](https://github.com/mob-sakai/UIEffect/commit/bdd8e0857235c56b7013fe768a333c5575aaa0ef)), closes [#212](https://github.com/mob-sakai/UIEffect/issues/212) [#271](https://github.com/mob-sakai/UIEffect/issues/271)
|
||||
* support `TextMeshPro/Bitmap` and `TextMeshPro/Mobile/Bitmap` shaders. ([23ac398](https://github.com/mob-sakai/UIEffect/commit/23ac3985d2a2d9497b2d50b3755be671f3a07aa9)), closes [#284](https://github.com/mob-sakai/UIEffect/issues/284)
|
||||
* support non full-rect graphics for some effect ([a66baea](https://github.com/mob-sakai/UIEffect/commit/a66baea1e8d895c424ba3dc1fce64f969d79561e))
|
||||
* UIEffectTweener animation preview in edit mode ([e17b4a0](https://github.com/mob-sakai/UIEffect/commit/e17b4a0bfd262dc22ad2a13af5b0571b43a74abd)), closes [#279](https://github.com/mob-sakai/UIEffect/issues/279)
|
||||
|
||||
## [5.0.2](https://github.com/mob-sakai/UIEffect/compare/5.0.1...5.0.2) (2024-12-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* incorrect transparency when applying the shiny filter to TextMeshProUGUI ([f74279f](https://github.com/mob-sakai/UIEffect/commit/f74279fb8353226b494f00582ed5eb7fe87d147f)), closes [#287](https://github.com/mob-sakai/UIEffect/issues/287)
|
||||
* TextMeshProUGUI disappears when the Y-axis scale is changed ([9d98c5d](https://github.com/mob-sakai/UIEffect/commit/9d98c5d3e1c6ead8e3312a7e3a36fe89b38aed68)), closes [#286](https://github.com/mob-sakai/UIEffect/issues/286)
|
||||
|
||||
## [5.0.1](https://github.com/mob-sakai/UIEffect/compare/5.0.0...5.0.1) (2024-12-14)
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Object = UnityEngine.Object;
|
||||
#if TMP_ENABLE
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace Coffee.UIEffects.Editors
|
||||
{
|
||||
@@ -16,15 +14,28 @@ namespace Coffee.UIEffects.Editors
|
||||
[CanEditMultipleObjects]
|
||||
public class UIEffect2Editor : Editor
|
||||
{
|
||||
private static readonly PropertyInfo s_PiGradient = typeof(SerializedProperty)
|
||||
.GetProperty("gradientValue", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
private static readonly Func<SerializedProperty, Gradient> s_GetGradient =
|
||||
(Func<SerializedProperty, Gradient>)Delegate.CreateDelegate(typeof(Func<SerializedProperty, Gradient>),
|
||||
s_PiGradient.GetMethod);
|
||||
|
||||
private static readonly Action<SerializedProperty, Gradient> s_SetGradient =
|
||||
(Action<SerializedProperty, Gradient>)Delegate.CreateDelegate(typeof(Action<SerializedProperty, Gradient>),
|
||||
s_PiGradient.SetMethod);
|
||||
|
||||
private SerializedProperty _toneFilter;
|
||||
private SerializedProperty _toneIntensity;
|
||||
|
||||
private SerializedProperty _colorFilter;
|
||||
private SerializedProperty _color;
|
||||
private SerializedProperty _colorIntensity;
|
||||
private SerializedProperty _colorGlow;
|
||||
|
||||
private SerializedProperty _samplingFilter;
|
||||
private SerializedProperty _samplingIntensity;
|
||||
private SerializedProperty _samplingScale;
|
||||
|
||||
private SerializedProperty _transitionFilter;
|
||||
private SerializedProperty _transitionRate;
|
||||
@@ -38,6 +49,7 @@ namespace Coffee.UIEffects.Editors
|
||||
private SerializedProperty _transitionSoftness;
|
||||
private SerializedProperty _transitionColorFilter;
|
||||
private SerializedProperty _transitionColor;
|
||||
private SerializedProperty _transitionColorGlow;
|
||||
|
||||
private SerializedProperty _targetMode;
|
||||
private SerializedProperty _targetColor;
|
||||
@@ -54,8 +66,22 @@ namespace Coffee.UIEffects.Editors
|
||||
private SerializedProperty _shadowDistanceY;
|
||||
private SerializedProperty _shadowIteration;
|
||||
private SerializedProperty _shadowFade;
|
||||
private SerializedProperty _shadowEffectOnOrigin;
|
||||
private SerializedProperty _shadowMirrorScale;
|
||||
private SerializedProperty _shadowBlurIntensity;
|
||||
private SerializedProperty _shadowColorFilter;
|
||||
private SerializedProperty _shadowColor;
|
||||
private SerializedProperty _shadowColorGlow;
|
||||
|
||||
private SerializedProperty _gradationMode;
|
||||
private SerializedProperty _gradationColor1;
|
||||
private SerializedProperty _gradationColor2;
|
||||
private SerializedProperty _gradationGradient;
|
||||
private SerializedProperty _gradationOffset;
|
||||
private SerializedProperty _gradationScale;
|
||||
private SerializedProperty _gradationRotation;
|
||||
|
||||
private bool _expandOthers = true;
|
||||
private SerializedProperty _allowToModifyMeshShape;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -63,14 +89,15 @@ namespace Coffee.UIEffects.Editors
|
||||
|
||||
_toneFilter = serializedObject.FindProperty("m_ToneFilter");
|
||||
_toneIntensity = serializedObject.FindProperty("m_ToneIntensity");
|
||||
var toneParams = serializedObject.FindProperty("m_ToneParams");
|
||||
|
||||
_colorFilter = serializedObject.FindProperty("m_ColorFilter");
|
||||
_color = serializedObject.FindProperty("m_Color");
|
||||
_colorIntensity = serializedObject.FindProperty("m_ColorIntensity");
|
||||
_colorGlow = serializedObject.FindProperty("m_ColorGlow");
|
||||
|
||||
_samplingFilter = serializedObject.FindProperty("m_SamplingFilter");
|
||||
_samplingIntensity = serializedObject.FindProperty("m_SamplingIntensity");
|
||||
_samplingScale = serializedObject.FindProperty("m_SamplingScale");
|
||||
|
||||
_transitionFilter = serializedObject.FindProperty("m_TransitionFilter");
|
||||
_transitionRate = serializedObject.FindProperty("m_TransitionRate");
|
||||
@@ -84,6 +111,7 @@ namespace Coffee.UIEffects.Editors
|
||||
_transitionSoftness = serializedObject.FindProperty("m_TransitionSoftness");
|
||||
_transitionColorFilter = serializedObject.FindProperty("m_TransitionColorFilter");
|
||||
_transitionColor = serializedObject.FindProperty("m_TransitionColor");
|
||||
_transitionColorGlow = serializedObject.FindProperty("m_TransitionColorGlow");
|
||||
|
||||
_targetMode = serializedObject.FindProperty("m_TargetMode");
|
||||
_targetColor = serializedObject.FindProperty("m_TargetColor");
|
||||
@@ -100,8 +128,21 @@ namespace Coffee.UIEffects.Editors
|
||||
_shadowDistanceY = _shadowDistance.FindPropertyRelative("y");
|
||||
_shadowIteration = serializedObject.FindProperty("m_ShadowIteration");
|
||||
_shadowFade = serializedObject.FindProperty("m_ShadowFade");
|
||||
_shadowEffectOnOrigin = serializedObject.FindProperty("m_ShadowEffectOnOrigin");
|
||||
_shadowMirrorScale = serializedObject.FindProperty("m_ShadowMirrorScale");
|
||||
_shadowBlurIntensity = serializedObject.FindProperty("m_ShadowBlurIntensity");
|
||||
_shadowColorFilter = serializedObject.FindProperty("m_ShadowColorFilter");
|
||||
_shadowColor = serializedObject.FindProperty("m_ShadowColor");
|
||||
_shadowColorGlow = serializedObject.FindProperty("m_ShadowColorGlow");
|
||||
|
||||
_gradationMode = serializedObject.FindProperty("m_GradationMode");
|
||||
_gradationColor1 = serializedObject.FindProperty("m_GradationColor1");
|
||||
_gradationColor2 = serializedObject.FindProperty("m_GradationColor2");
|
||||
_gradationGradient = serializedObject.FindProperty("m_GradationGradient");
|
||||
_gradationOffset = serializedObject.FindProperty("m_GradationOffset");
|
||||
_gradationScale = serializedObject.FindProperty("m_GradationScale");
|
||||
_gradationRotation = serializedObject.FindProperty("m_GradationRotation");
|
||||
|
||||
_allowToModifyMeshShape = serializedObject.FindProperty("m_AllowToModifyMeshShape");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
@@ -122,7 +163,6 @@ namespace Coffee.UIEffects.Editors
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_toneIntensity);
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
@@ -133,7 +173,8 @@ namespace Coffee.UIEffects.Editors
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_colorIntensity);
|
||||
DrawColor(_colorFilter, _color, prevColorFilter);
|
||||
DrawColor(_colorFilter, _color, prevColorFilter, false);
|
||||
EditorGUILayout.PropertyField(_colorGlow);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
@@ -171,6 +212,7 @@ namespace Coffee.UIEffects.Editors
|
||||
prevColorFilter = (ColorFilter)_transitionColorFilter.intValue;
|
||||
EditorGUILayout.PropertyField(_transitionColorFilter);
|
||||
DrawColor(_transitionColorFilter, _transitionColor, prevColorFilter);
|
||||
EditorGUILayout.PropertyField(_transitionColorGlow);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
@@ -192,7 +234,6 @@ namespace Coffee.UIEffects.Editors
|
||||
if (!DrawHeaderPopup(_blendType))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
EditorGUILayout.PropertyField(_srcBlendMode);
|
||||
EditorGUILayout.PropertyField(_dstBlendMode);
|
||||
EditorGUI.indentLevel--;
|
||||
@@ -228,13 +269,117 @@ namespace Coffee.UIEffects.Editors
|
||||
EditorGUILayout.PropertyField(_shadowIteration);
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_shadowColorFilter);
|
||||
DrawColorPickerField(_shadowColor, false);
|
||||
EditorGUILayout.PropertyField(_shadowColorGlow);
|
||||
EditorGUILayout.PropertyField(_shadowFade);
|
||||
EditorGUILayout.PropertyField(_shadowEffectOnOrigin);
|
||||
|
||||
switch ((SamplingFilter)_samplingFilter.intValue)
|
||||
{
|
||||
case SamplingFilter.BlurFast:
|
||||
case SamplingFilter.BlurMedium:
|
||||
case SamplingFilter.BlurDetail:
|
||||
EditorGUILayout.PropertyField(_shadowBlurIntensity);
|
||||
break;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Gradient
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_gradationMode))
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
switch ((GradationMode)_gradationMode.intValue)
|
||||
{
|
||||
case GradationMode.HorizontalGradient:
|
||||
case GradationMode.VerticalGradient:
|
||||
case GradationMode.AngleGradient:
|
||||
DrawGradientField(_gradationGradient);
|
||||
break;
|
||||
default:
|
||||
DrawColorPickerField(_gradationColor1);
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
r.width -= 24;
|
||||
r.height = EditorGUIUtility.singleLineHeight;
|
||||
DrawColorPickerField(r, _gradationColor2);
|
||||
|
||||
r.x += r.width + 4;
|
||||
r.width = 20;
|
||||
// Swap colors
|
||||
if (GUI.Button(r, EditorGUIUtility.IconContent("preaudioloopoff"), "iconbutton"))
|
||||
{
|
||||
(_gradationColor1.colorValue, _gradationColor2.colorValue)
|
||||
= (_gradationColor2.colorValue, _gradationColor1.colorValue);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_gradationOffset);
|
||||
EditorGUILayout.PropertyField(_gradationScale);
|
||||
|
||||
if ((GradationMode)_gradationMode.intValue == GradationMode.Angle
|
||||
|| (GradationMode)_gradationMode.intValue == GradationMode.AngleGradient)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_gradationRotation);
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
DrawSeparator();
|
||||
_expandOthers = EditorGUILayout.BeginFoldoutHeaderGroup(_expandOthers, "Others");
|
||||
if (_expandOthers)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_samplingScale);
|
||||
EditorGUILayout.PropertyField(_allowToModifyMeshShape);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawColor(SerializedProperty filter, SerializedProperty color, ColorFilter prevFilter)
|
||||
private static void DrawColorPickerField(SerializedProperty color, bool showAlpha = true)
|
||||
{
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
r.height = EditorGUIUtility.singleLineHeight;
|
||||
DrawColorPickerField(r, color, showAlpha);
|
||||
}
|
||||
|
||||
private static void DrawColorPickerField(Rect rect, SerializedProperty color, bool showAlpha = true)
|
||||
{
|
||||
var label = EditorGUIUtility.TrTempContent(color.displayName);
|
||||
label.tooltip = color.tooltip;
|
||||
var hdr = UIEffectProjectSettings.useHdrColorPicker;
|
||||
EditorGUI.showMixedValue = color.hasMultipleDifferentValues;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var colorValue = EditorGUI.ColorField(rect, label, color.colorValue, true, showAlpha, hdr);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
color.colorValue = colorValue;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawGradientField(SerializedProperty gradient)
|
||||
{
|
||||
var r = EditorGUILayout.GetControlRect();
|
||||
r.height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
var label = EditorGUIUtility.TrTempContent(gradient.displayName);
|
||||
label.tooltip = gradient.tooltip;
|
||||
var hdr = UIEffectProjectSettings.useHdrColorPicker;
|
||||
EditorGUI.showMixedValue = gradient.hasMultipleDifferentValues;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var gradientValue = EditorGUI.GradientField(r, label, s_GetGradient(gradient), hdr);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
s_SetGradient(gradient, gradientValue);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawColor(SerializedProperty filter, SerializedProperty color, ColorFilter prevFilter,
|
||||
bool showAlpha = true)
|
||||
{
|
||||
if (filter.intValue == (int)ColorFilter.None)
|
||||
{
|
||||
@@ -269,7 +414,7 @@ namespace Coffee.UIEffects.Editors
|
||||
color.colorValue = Color.white;
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(color);
|
||||
DrawColorPickerField(color, showAlpha);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +457,10 @@ namespace Coffee.UIEffects.Editors
|
||||
r.x += r.width;
|
||||
if (GUI.Button(r, EditorGUIUtility.TrTempContent("Save As New"), "MiniButton"))
|
||||
{
|
||||
UIEffectProjectSettings.SaveAsNewPreset(targets.OfType<UIEffect>().FirstOrDefault());
|
||||
EditorApplication.delayCall += () =>
|
||||
{
|
||||
UIEffectProjectSettings.SaveAsNewPreset(targets.OfType<UIEffect>().FirstOrDefault());
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Coffee.UIEffectInternal;
|
||||
using UnityEditorInternal;
|
||||
|
||||
namespace Coffee.UIEffects.Editors
|
||||
@@ -11,17 +9,17 @@ namespace Coffee.UIEffects.Editors
|
||||
public class UIEffectProjectSettingsEditor : Editor
|
||||
{
|
||||
private ReorderableList _reorderableList;
|
||||
private SerializedProperty _fallbackVariantBehaviour;
|
||||
private SerializedProperty _useHDRColorPicker;
|
||||
private SerializedProperty _transformSensitivity;
|
||||
private Editor _editor;
|
||||
private bool _isInitialized;
|
||||
private ShaderVariantRegistryEditor _shaderVariantRegistryEditor;
|
||||
|
||||
private void InitializeIfNeeded()
|
||||
{
|
||||
if (_isInitialized) return;
|
||||
|
||||
_fallbackVariantBehaviour = serializedObject.FindProperty("m_FallbackVariantBehaviour");
|
||||
_transformSensitivity = serializedObject.FindProperty("m_TransformSensitivity");
|
||||
_useHDRColorPicker = serializedObject.FindProperty("m_UseHDRColorPicker");
|
||||
var runtimePresets = serializedObject.FindProperty("m_RuntimePresets");
|
||||
_reorderableList = new ReorderableList(serializedObject, runtimePresets, true, true, true, true);
|
||||
_reorderableList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Runtime Presets");
|
||||
@@ -53,19 +51,11 @@ namespace Coffee.UIEffects.Editors
|
||||
menu.DropDown(rect);
|
||||
};
|
||||
|
||||
var collection = serializedObject.FindProperty("m_ShaderVariantCollection").objectReferenceValue;
|
||||
_editor = CreateEditor(collection);
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_editor)
|
||||
{
|
||||
DestroyImmediate(_editor);
|
||||
}
|
||||
|
||||
_editor = null;
|
||||
_isInitialized = false;
|
||||
}
|
||||
|
||||
@@ -75,89 +65,29 @@ namespace Coffee.UIEffects.Editors
|
||||
InitializeIfNeeded();
|
||||
|
||||
// Settings
|
||||
// Transform sensitivity.
|
||||
EditorGUILayout.PropertyField(_transformSensitivity);
|
||||
|
||||
// Runtime Presets
|
||||
_reorderableList.DoLayoutList();
|
||||
|
||||
// Editor
|
||||
EditorGUILayout.PropertyField(_fallbackVariantBehaviour);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
// Use HDR color pickers.
|
||||
EditorGUILayout.PropertyField(_useHDRColorPicker);
|
||||
|
||||
// Shader
|
||||
EditorGUILayout.Space(20);
|
||||
EditorGUILayout.LabelField("Shader Variants", EditorStyles.boldLabel);
|
||||
EditorGUILayout.Space(-12);
|
||||
DrawUnregisteredShaderVariants(UIEffectProjectSettings.instance.m_UnregisteredShaderVariants);
|
||||
DrawRegisteredShaderVariants(_editor);
|
||||
// Shader registry
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Shader", EditorStyles.boldLabel);
|
||||
if (_shaderVariantRegistryEditor == null)
|
||||
{
|
||||
var property = serializedObject.FindProperty("m_ShaderVariantRegistry");
|
||||
_shaderVariantRegistryEditor = new ShaderVariantRegistryEditor(property, "(UIEffect)");
|
||||
}
|
||||
|
||||
_shaderVariantRegistryEditor.Draw();
|
||||
GUILayout.FlexibleSpace();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private static void DrawUnregisteredShaderVariants(List<string> variants)
|
||||
{
|
||||
if (variants.Count == 0) return;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
var array = variants.ToArray();
|
||||
var r = EditorGUILayout.GetControlRect(false, 20);
|
||||
var rLabel = new Rect(r.x, r.y, r.width - 80, r.height);
|
||||
EditorGUI.LabelField(rLabel, "Registered Shader Variants");
|
||||
|
||||
var rButtonClear = new Rect(r.x + r.width - 80, r.y + 2, 80, r.height - 4);
|
||||
if (GUI.Button(rButtonClear, "Clear All", EditorStyles.miniButton))
|
||||
{
|
||||
UIEffectProjectSettings.ClearUnregisteredShaderVariants();
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginVertical("RL Background");
|
||||
for (var i = 0; i < array.Length; i++)
|
||||
{
|
||||
var values = array[i].Split(';');
|
||||
r = EditorGUILayout.GetControlRect();
|
||||
var rShader = new Rect(r.x, r.y, 150, r.height);
|
||||
EditorGUI.ObjectField(rShader, Shader.Find(values[0]), typeof(Shader), false);
|
||||
|
||||
var rKeywords = new Rect(r.x + 150, r.y, r.width - 150 - 20, r.height);
|
||||
EditorGUI.TextField(rKeywords, values[1]);
|
||||
|
||||
var rButton = new Rect(r.x + r.width - 20 + 2, r.y, 20, r.height);
|
||||
if (GUI.Button(rButton, EditorGUIUtility.IconContent("icons/toolbar plus.png"), "iconbutton"))
|
||||
{
|
||||
UIEffectProjectSettings.RegisterVariant(array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private static void DrawRegisteredShaderVariants(Editor editor)
|
||||
{
|
||||
var collection = editor.target as ShaderVariantCollection;
|
||||
if (collection == null) return;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
var r = EditorGUILayout.GetControlRect(false, 20);
|
||||
var rLabel = new Rect(r.x, r.y, r.width - 80, r.height);
|
||||
EditorGUI.LabelField(rLabel, "Registered Shader Variants");
|
||||
|
||||
var rButton = new Rect(r.x + r.width - 80, r.y + 2, 80, r.height - 4);
|
||||
if (GUI.Button(rButton, "Clear All", EditorStyles.miniButton))
|
||||
{
|
||||
collection.Clear();
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginVertical("RL Background");
|
||||
editor.serializedObject.Update();
|
||||
var shaders = editor.serializedObject.FindProperty("m_Shaders");
|
||||
for (var i = 0; i < shaders.arraySize; i++)
|
||||
{
|
||||
s_MiDrawShaderEntry.Invoke(editor, new object[] { i });
|
||||
}
|
||||
|
||||
editor.serializedObject.ApplyModifiedProperties();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private static readonly MethodInfo s_MiDrawShaderEntry =
|
||||
Type.GetType("UnityEditor.ShaderVariantCollectionInspector, UnityEditor")
|
||||
?.GetMethod("DrawShaderEntry", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,12 +11,16 @@ namespace Coffee.UIEffects.Editors
|
||||
{
|
||||
private SerializedProperty _target;
|
||||
private SerializedProperty _useTargetTransform;
|
||||
private SerializedProperty _samplingScale;
|
||||
private SerializedProperty _allowToModifyMeshShape;
|
||||
private Editor _uiEffectEditor;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_target = serializedObject.FindProperty("m_Target");
|
||||
_useTargetTransform = serializedObject.FindProperty("m_UseTargetTransform");
|
||||
_samplingScale = serializedObject.FindProperty("m_SamplingScale");
|
||||
_allowToModifyMeshShape = serializedObject.FindProperty("m_AllowToModifyMeshShape");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
@@ -24,6 +28,8 @@ namespace Coffee.UIEffects.Editors
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(_target);
|
||||
EditorGUILayout.PropertyField(_useTargetTransform);
|
||||
EditorGUILayout.PropertyField(_samplingScale);
|
||||
EditorGUILayout.PropertyField(_allowToModifyMeshShape);
|
||||
|
||||
if (_target.objectReferenceValue)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEditor;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
@@ -6,7 +7,7 @@ namespace Coffee.UIEffects.Editors
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(UIEffectTweener))]
|
||||
internal class UIMaterialPropertyTweenerEditor : Editor
|
||||
internal class UIEffectTweenerEditor : Editor
|
||||
{
|
||||
private SerializedProperty _cullingMask;
|
||||
private SerializedProperty _direction;
|
||||
@@ -14,26 +15,37 @@ namespace Coffee.UIEffects.Editors
|
||||
private SerializedProperty _delay;
|
||||
private SerializedProperty _duration;
|
||||
private SerializedProperty _interval;
|
||||
private SerializedProperty _restartOnEnable;
|
||||
private SerializedProperty _playOnEnable;
|
||||
private SerializedProperty _updateMode;
|
||||
private SerializedProperty _wrapMode;
|
||||
private SerializedProperty _onComplete;
|
||||
private bool _isPlaying = false;
|
||||
private double _lastTime;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_cullingMask = serializedObject.FindProperty("m_CullingMask");
|
||||
_direction = serializedObject.FindProperty("m_Direction");
|
||||
_curve = serializedObject.FindProperty("m_Curve");
|
||||
_restartOnEnable = serializedObject.FindProperty("m_RestartOnEnable");
|
||||
_playOnEnable = serializedObject.FindProperty("m_PlayOnEnable");
|
||||
_delay = serializedObject.FindProperty("m_Delay");
|
||||
_duration = serializedObject.FindProperty("m_Duration");
|
||||
_interval = serializedObject.FindProperty("m_Interval");
|
||||
_wrapMode = serializedObject.FindProperty("m_WrapMode");
|
||||
_updateMode = serializedObject.FindProperty("m_UpdateMode");
|
||||
_onComplete = serializedObject.FindProperty("m_OnComplete");
|
||||
|
||||
EditorApplication.update += UpdateTweeners;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
EditorApplication.update -= UpdateTweeners;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
Profiler.BeginSample("(MPI)[MPTweenerEditor] OnInspectorGUI");
|
||||
Profiler.BeginSample("(UIE)[UIEffectTweener] OnInspectorGUI");
|
||||
serializedObject.UpdateIfRequiredOrScript();
|
||||
EditorGUILayout.PropertyField(_cullingMask);
|
||||
EditorGUILayout.PropertyField(_direction);
|
||||
@@ -41,9 +53,10 @@ namespace Coffee.UIEffects.Editors
|
||||
EditorGUILayout.PropertyField(_delay);
|
||||
EditorGUILayout.PropertyField(_duration);
|
||||
EditorGUILayout.PropertyField(_interval);
|
||||
EditorGUILayout.PropertyField(_restartOnEnable);
|
||||
EditorGUILayout.PropertyField(_playOnEnable);
|
||||
EditorGUILayout.PropertyField(_wrapMode);
|
||||
EditorGUILayout.PropertyField(_updateMode);
|
||||
EditorGUILayout.PropertyField(_onComplete);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
DrawPlayer(target as UIEffectTweener);
|
||||
Profiler.EndSample();
|
||||
@@ -53,74 +66,62 @@ namespace Coffee.UIEffects.Editors
|
||||
{
|
||||
if (!tweener) return;
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
EditorGUI.BeginDisabledGroup(!Application.isPlaying);
|
||||
var icon = EditorGUIUtility.IconContent("icons/playbutton.png");
|
||||
var r = EditorGUILayout.GetControlRect(false);
|
||||
EditorGUILayout.Space(4);
|
||||
GUILayout.Label(GUIContent.none, "sv_iconselector_sep", GUILayout.ExpandWidth(true));
|
||||
|
||||
var rButton = new Rect(r.x, r.y, 20, r.height);
|
||||
if (GUI.Button(rButton, icon, "IconButton"))
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
var r = EditorGUILayout.GetControlRect(false);
|
||||
var rResetTimeButton = new Rect(r.x, r.y, 20, r.height);
|
||||
if (GUI.Button(rResetTimeButton, EditorGUIUtility.IconContent("animation.firstkey"), "IconButton"))
|
||||
{
|
||||
tweener.SetTime(0);
|
||||
SetTime(0);
|
||||
}
|
||||
|
||||
EditorGUI.EndDisabledGroup();
|
||||
var rPlayButton = new Rect(r.x + 20, r.y, 20, r.height);
|
||||
if (GUI.Button(rPlayButton, EditorGUIUtility.IconContent("playbutton"), "IconButton"))
|
||||
{
|
||||
SetPlaying(true);
|
||||
}
|
||||
|
||||
var rPauseButton = new Rect(r.x + 40, r.y, 20, r.height);
|
||||
if (GUI.Button(rPauseButton, EditorGUIUtility.IconContent("pausebutton"), "IconButton"))
|
||||
{
|
||||
SetPlaying(false);
|
||||
}
|
||||
|
||||
var totalTime = tweener.totalTime;
|
||||
var time = tweener.time;
|
||||
var label = EditorGUIUtility.TrTempContent($"{time:N2}/{totalTime:N2}");
|
||||
var wLabel = Mathf.CeilToInt(EditorStyles.label.CalcSize(label).x / 5f) * 5f;
|
||||
wLabel = 80;
|
||||
var rLabel = new Rect(r.x + r.width - wLabel, r.y, wLabel, r.height);
|
||||
var rLabel = new Rect(r.x + r.width - 80, r.y, 80, r.height);
|
||||
GUI.Label(rLabel, label, "RightLabel");
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var rSlider = new Rect(r.x + 20, r.y, r.width - wLabel - 20, r.height);
|
||||
var rSlider = new Rect(r.x + 60, r.y, r.width - 140, r.height);
|
||||
var r0 = new Rect(rSlider.x, rSlider.y + 4, rSlider.width, rSlider.height - 8);
|
||||
r0.x += DrawBackground(r0, rSlider.width * tweener.delay / totalTime, Color.blue);
|
||||
r0.x += DrawBackground(r0, rSlider.width * tweener.duration / totalTime, Color.green);
|
||||
|
||||
//
|
||||
|
||||
var
|
||||
r0 = rSlider; //new Rect(rSlider.x, rSlider.y, rSlider.width * tweener.interval / totalTime, rSlider.height);
|
||||
r0.y += 4;
|
||||
r0.height -= 8;
|
||||
r0.width = rSlider.width * tweener.delay / totalTime;
|
||||
GUI.color = Color.blue;
|
||||
GUI.Label(r0, GUIContent.none, "TE DefaultTime");
|
||||
|
||||
r0.x += r0.width;
|
||||
r0.width = rSlider.width * tweener.duration / totalTime;
|
||||
GUI.color = Color.green;
|
||||
GUI.Label(r0, GUIContent.none, "TE DefaultTime");
|
||||
|
||||
r0.x += r0.width;
|
||||
r0.width = rSlider.width * tweener.interval / totalTime;
|
||||
GUI.color = Color.red;
|
||||
GUI.Label(r0, GUIContent.none, "TE DefaultTime");
|
||||
if (UIEffectTweener.WrapMode.Loop <= tweener.wrapMode)
|
||||
{
|
||||
r0.x += DrawBackground(r0, rSlider.width * tweener.interval / totalTime, Color.red);
|
||||
}
|
||||
|
||||
if (UIEffectTweener.WrapMode.PingPongOnce <= tweener.wrapMode)
|
||||
{
|
||||
r0.x += r0.width;
|
||||
r0.width = rSlider.width * tweener.duration / totalTime;
|
||||
GUI.color = Color.green;
|
||||
GUI.Label(r0, GUIContent.none, "TE DefaultTime");
|
||||
r0.x += DrawBackground(r0, rSlider.width * tweener.duration / totalTime, Color.green);
|
||||
}
|
||||
|
||||
if (UIEffectTweener.WrapMode.PingPongLoop <= tweener.wrapMode)
|
||||
{
|
||||
r0.x += r0.width;
|
||||
r0.width = rSlider.width * tweener.interval / totalTime;
|
||||
GUI.color = Color.red;
|
||||
GUI.Label(r0, GUIContent.none, "TE DefaultTime");
|
||||
r0.x += DrawBackground(r0, rSlider.width * tweener.interval / totalTime, Color.red);
|
||||
}
|
||||
|
||||
|
||||
GUI.color = Color.white;
|
||||
|
||||
time = GUI.HorizontalSlider(rSlider, time, 0, totalTime);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
tweener.SetTime(time);
|
||||
SetTime(time);
|
||||
}
|
||||
|
||||
if (Application.isPlaying && tweener.isActiveAndEnabled)
|
||||
@@ -129,21 +130,56 @@ namespace Coffee.UIEffects.Editors
|
||||
}
|
||||
}
|
||||
|
||||
// private static void PostAddElement(SerializedProperty prop, string propertyName)
|
||||
// {
|
||||
// prop.FindPropertyRelative("m_From.m_Type").intValue = -1;
|
||||
// prop.FindPropertyRelative("m_From.m_PropertyName").stringValue = propertyName;
|
||||
// prop.FindPropertyRelative("m_To.m_Type").intValue = -1;
|
||||
// prop.FindPropertyRelative("m_To.m_PropertyName").stringValue = propertyName;
|
||||
// }
|
||||
//
|
||||
// private void ResetCallback()
|
||||
// {
|
||||
// var current = serializedObject.targetObject as UIEffectTweener;
|
||||
// if (!current) return;
|
||||
//
|
||||
// Undo.RecordObject(current, "Reset Values");
|
||||
// current.ResetPropertiesToDefault();
|
||||
// }
|
||||
private static float DrawBackground(Rect r, float width, Color color)
|
||||
{
|
||||
r.width = width;
|
||||
GUI.color = color;
|
||||
GUI.Label(r, GUIContent.none, "TE DefaultTime");
|
||||
return width;
|
||||
}
|
||||
|
||||
private void SetTime(float time)
|
||||
{
|
||||
foreach (var tweener in targets.OfType<UIEffectTweener>())
|
||||
{
|
||||
tweener.SetTime(time);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPlaying(bool enable)
|
||||
{
|
||||
if (!EditorApplication.isPlaying)
|
||||
{
|
||||
_isPlaying = enable;
|
||||
_lastTime = EditorApplication.timeSinceStartup;
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var tweener in targets.OfType<UIEffectTweener>())
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
tweener.Play(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
tweener.SetPause(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTweeners()
|
||||
{
|
||||
if (!_isPlaying || EditorApplication.isPlayingOrWillChangePlaymode) return;
|
||||
|
||||
var delta = (float)(EditorApplication.timeSinceStartup - _lastTime);
|
||||
_lastTime = EditorApplication.timeSinceStartup;
|
||||
foreach (var tweener in targets.OfType<UIEffectTweener>())
|
||||
{
|
||||
tweener.UpdateTime(tweener.direction == UIEffectTweener.Direction.Forward ? delta : -delta);
|
||||
}
|
||||
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+120
-30
@@ -19,8 +19,8 @@
|
||||
|
||||
## 📝 Description <!-- omit in toc -->
|
||||
|
||||
**_"Decorate your uGUI, simply and powerfully."_**
|
||||
UIEffect is an open-source package that allows you to intuitively apply rich UI effects directly from the Inspector or via code.
|
||||
**_"Decorate your UI, simply and powerfully."_**
|
||||
UIEffect is an open-source package that allows you to intuitively apply rich Unity UI effects directly from the Inspector or via code.
|
||||
Combine various filters, such as grayscale, blur, and dissolve, to decorate your UI with a unique visual style!
|
||||
|
||||

|
||||
@@ -32,7 +32,7 @@ Combine various filters, such as grayscale, blur, and dissolve, to decorate your
|
||||
- [Install via UPM (with Package Manager UI)](#install-via-upm-with-package-manager-ui)
|
||||
- [Install via UPM (Manually)](#install-via-upm-manually)
|
||||
- [Install as Embedded Package](#install-as-embedded-package)
|
||||
- [Additional Resource Imports](#additional-resource-imports)
|
||||
- [Import Additional Resources](#import-additional-resources)
|
||||
- [🔄 Upgrading from v4 to v5](#-upgrading-from-v4-to-v5)
|
||||
- [🚀 Usage](#-usage)
|
||||
- [Getting Started](#getting-started)
|
||||
@@ -56,7 +56,7 @@ Combine various filters, such as grayscale, blur, and dissolve, to decorate your
|
||||
|
||||
## 📌 Key Features
|
||||
|
||||

|
||||

|
||||
|
||||
- **UIEffect is out-of-the-box!**: Easily apply effects by adjusting parameters directly in the inspector.
|
||||
- **Rich effect combinations**: Decorate your UI with a variety of effects, such as grayscale, blur, and dissolve, by combining multiple filters and parameters.
|
||||
@@ -73,7 +73,7 @@ Combine various filters, such as grayscale, blur, and dissolve, to decorate your
|
||||
|
||||
## 🎮 Demo
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
[WebGL Demo](https://mob-sakai.github.io/UIEffect/)
|
||||
@@ -86,7 +86,7 @@ _This package requires **Unity 2020.3 or later**._
|
||||
|
||||
### Install via OpenUPM
|
||||
|
||||
- This package is available on [OpenUPM](https://openupm.com) package registry.
|
||||
- This package is available on [OpenUPM](https://openupm.com/packages/com.coffee.ui-effect/) package registry.
|
||||
- This is the preferred method of installation, as you can easily receive updates as they're released.
|
||||
- If you have [openupm-cli](https://github.com/openupm/openupm-cli) installed, then run the following command in your project's directory:
|
||||
```
|
||||
@@ -122,16 +122,17 @@ _This package requires **Unity 2020.3 or later**._
|
||||
|
||||
### Install as Embedded Package
|
||||
|
||||
1. Download a source code zip file from [Releases](https://github.com/mob-sakai/UIEffect/releases) and extract it.
|
||||
2. Place `<extracted_dir>/Packages/src` directory in your project's `Packages` directory.
|
||||
1. Download the `Source code (zip)` file from [Releases](https://github.com/mob-sakai/UIEffect/releases) and
|
||||
extract it.
|
||||
2. Move the `<extracted_dir>/Packages/src` directory into your project's `Packages` directory.
|
||||

|
||||
- You can rename the `src` directory.
|
||||
- If you want to fix bugs or add features, install it as an embedded package.
|
||||
- To update the package, you need to re-download it and replace the contents.
|
||||
- You can rename the `src` directory if needed.
|
||||
- If you intend to fix bugs or add features, installing it as an embedded package is recommended.
|
||||
- To update the package, re-download it and replace the existing contents.
|
||||
|
||||
### Additional Resource Imports
|
||||
### Import Additional Resources
|
||||
|
||||
UIEffect includes additional resources to import.
|
||||
Additional resources can be imported to extend functionality.
|
||||
|
||||
- [🔄 Upgrading from v4 to v5](#-upgrading-from-v4-to-v5)
|
||||
- [Usage with TextMeshPro](#usage-with-textmeshpro)
|
||||
@@ -182,71 +183,133 @@ If upgrading from UIEffect v4 to v5, note the following breaking changes:
|
||||
|
||||
### Component: UIEffect
|
||||
|
||||

|
||||

|
||||
|
||||
The `UIEffect` component applies visual effects to UI elements, allowing various effects to be achieved by combining multiple filters.
|
||||
|
||||
#### Tone Filter
|
||||
|
||||
- **Tone Filter**: `None`, `Grayscale`, `Sepia`, `Nega`, `Retro`, `Posterize`
|
||||
- **Tone Intensity**: 0.0 (no effect) - 1.0 (full effect).
|
||||
|
||||
#### Color Filter
|
||||
|
||||
- **Color Filter**: `None`, `Multiply`, `Additive`, `Subtractive`, `Replace`, `Multiply Luminance`, `Multiply Additive`, `Hsv Modifier`, `Contrast`
|
||||
- **Color Intensity**: 0.0 (no effect) - 1.0 (full effect).
|
||||
- **Color Glow**: Set the color to glow.
|
||||
|
||||
#### Sampling Filter
|
||||
|
||||
- **Sampling Filter**: `None`, `Blur Fast`, `Blur Medium`, `Blur Detail`, `Pixelation`, `Rgb Shift`, `Edge Luminescence`, `Edge Alpha`
|
||||
- **Sampling Intensity**: 0.0 (no effect) - 1.0 (full effect).
|
||||
|
||||
#### Transition Filter
|
||||
|
||||
- **Transition Filter**: `None`, `Fade`, `Cutoff`, `Dissolve`, `Shiny`, `Mask`, `Melt`, `Burn`
|
||||
- **Transition Rate**: 0.0 (no effect) - 1.0 (full effect).
|
||||
- **Transition Tex**: The texture used for the transition filter.- **Transition Width**: The width where the transition color is applied.
|
||||
- **Transition Softness**: The softness of the boundary for the transition color.
|
||||
- **Transition Color Filter/Transition Color**: Specifies the transition color.
|
||||
- **Transition Color Filter**: Specifies the transition color.
|
||||
- **Transition Color**: The color of the transition.
|
||||
- **Transition Color Glow**: Set the transition color to glow.
|
||||
|
||||
#### Target Mode
|
||||
|
||||
- **Target Mode**: `None`, `Hue`, `Luminance`
|
||||
- Restricts the effect application area based on hue or luminance.
|
||||
- **Target Range**: The range of target hue or luminance.
|
||||
- **Target Softness**: The softness of the target boundary.
|
||||
- **Blend Type**: `Alpha Blend`, `Multiply`, `Additive`, `Soft Additive`, `Multiply Additive`, `Custom (SrcBlend, DstBlend)`
|
||||
|
||||
#### Blend Type
|
||||
|
||||
- **Blend Type**: `Alpha Blend`, `Multiply`, `Additive`, `Soft Additive`, `Multiply Additive`, `Custom`
|
||||
- `Custom` blend type can be set using the `SrcBlend` and `DstBlend` properties.
|
||||
|
||||
#### Shadow Mode
|
||||
|
||||
- **Shadow Mode**: `None`, `Shadow`, `Shadow3`, `Outline`, `Outline8`, `Mirror`
|
||||
- **Shadow Distance**: Distance of the shadow or outline.
|
||||
- **Shadow Iteration**: Number of times the shadow or outline is applied.
|
||||
- **Shadow Color Filter**: Specifies the shadow color.
|
||||
- **Shadow Color**: The color of the shadow.
|
||||
- **Shadow Color Glow**: Set the shadow color to glow.
|
||||
- **Shadow Fade**: Alpha value of the shadow or outline.
|
||||
- **Shadow Effect On Origin**: Applies effects to meshes other than shadows.
|
||||
- **Shadow Blur Intensity**: Intensity of the shadow or outline blur.
|
||||
- **Mirror Reflection**: Distance of the mirrored image.
|
||||
- **Mirror Offset**: Offset for the mirrored image.
|
||||
- **Mirror Scale**: Scale of the mirrored image.
|
||||
|
||||
#### Gradation Mode
|
||||
|
||||
- **Gradation Mode**: `None`, `Horizontal Gradient`, `Horizontal`, `Vertical Gradient`, `Vertical`, `Radial Fast`, `Radial Detail`, `Diagonal To Right Bottom`, `Diagonal To Right Top`, `Diagonal To Left Bottom`, `Angle`, `Angle Gradient`
|
||||
- **Gradation Gradient**: The gradient of the gradation.
|
||||
- **Gradation Color 1**: The first color of the gradation.
|
||||
- **Gradation Color 2**: The second color of the gradation.
|
||||
- **Gradation Offset**: The offset of the gradation range.
|
||||
- **Gradation Scale**: The scale of the gradation range.
|
||||
- **Gradation Rotation**: The rotation of the gradation range.
|
||||
|
||||
> [!TIP]
|
||||
> `Horizontal Gradient` and `Vertical Gradient` divide the mesh horizontally or vertically and apply a gradient.
|
||||
> This is very fast but only supports Full Rect.
|
||||
> `Angle Gradient` divides the mesh at the specified angle and applies a gradient.
|
||||
> It can be applied to meshes other than Full Rect because it applies the gradient according to the original mesh shape.
|
||||
> `Gradation Gradient` has two modes, `Blend` and `Fixed`.
|
||||
|
||||
#### Others
|
||||
|
||||
- **Sampling Scale**: The referencing scale during sampling.
|
||||
- Larger values are suitable for high-resolution textures.
|
||||
- **Allow To Modify Mesh Shape**: If enabled, the mesh shape can be modified.
|
||||
|
||||
<br><br>
|
||||
|
||||
### Component: UIEffectTweener
|
||||
|
||||

|
||||

|
||||
|
||||
The `UIEffectTweener` component animates the effect, enabling easy control over effect animations without the need for an `AnimationClip`.
|
||||
|
||||
- **Culling Mask**: `Tone`, `Color`, `Sampling`, `Transition`
|
||||
- **Direction**: `Forward (0.0 -> 1.0)`, `Backward (1.0 -> 0.0)`
|
||||
- **Direction**: `Forward (0.0 -> 1.0)`, `Reverse (1.0 -> 0.0)`
|
||||
- **Curve**: The curve of the animation.
|
||||
- **Delay**: The delay time before starting the animation.
|
||||
- **Duration**: The duration of the animation.
|
||||
- **Interval**: The interval time between the animation.
|
||||
- **Curve**: The curve of the animation.
|
||||
- **Restart On Enable**: Play the animation automatically when the component is enabled.
|
||||
- **Play On Enable**: `None`, `Forward`, `Reverse`, `Keep Direction`
|
||||
- Play the animation automatically when the component is enabled.
|
||||
- If `None` is selected, the animation will not play automatically. You can play it using the `Play`, `PlayForward` or `PlayReverse` method.
|
||||
- **Wrap Mode**: `Once`, `Loop`, `PingPongOnce`, `PingPongLoop`
|
||||
- **Update Mode**: `Normal`, `UnscaledTime`, `Manual`
|
||||
- **On Complete**: A event that is triggered when the animation is completed.
|
||||
|
||||
You can preview the animation using the seek bar and play button.
|
||||
|
||||
<br><br>
|
||||
|
||||
### Component: UIEffectReplica
|
||||
|
||||

|
||||

|
||||
|
||||
The `UIEffectReplica` component applies visual effects to UI elements by replicating the settings of another `UIEffect` component. This allows the same effect to be applied across multiple UI elements simultaneously.
|
||||
|
||||
- **Target**: The target `UIEffect` component to replicate.
|
||||
- **Use Target Transform**: Use the target's transform for some effects.
|
||||
- **Use Target Transform**: Use the target's transform for some effects.
|
||||
- **Sampling Scale**: Override the sampling scale.
|
||||
- **Allow To Modify Mesh Shape**: If enabled, the mesh shape can be modified.
|
||||

|
||||
|
||||
<br><br>
|
||||
|
||||
### Usage with TextMeshPro
|
||||
|
||||

|
||||
To use UIEffect with TextMeshPro, you need to import additional resources.
|
||||
When a shader included in the samples is requested, an import dialog will automatically appear.
|
||||
Click the `Import` button.
|
||||
|
||||
UIEffect supports TextMeshProUGUI elements. To use UIEffect with TextMeshPro, follow these steps:
|
||||

|
||||
|
||||
Alternatively, you can manually import the resources by following these steps:
|
||||
|
||||
1. First, you must import [TMP Essential Resources](https://docs.unity3d.com/Packages/com.unity.textmeshpro@3.0/manual/index.html#installation) before using.
|
||||

|
||||
@@ -260,6 +323,10 @@ UIEffect supports TextMeshProUGUI elements. To use UIEffect with TextMeshPro, fo
|
||||
4. Add the `UIEffect` component to a TextMeshProUGUI element and adjust the effect settings. The `<font>` and `<sprite>` tags are also supported.
|
||||

|
||||
|
||||
> [!TIP]
|
||||
> `TextMeshPro Support` may change with updates to the UIEffect package.
|
||||
> If issues occur, try importing it again.
|
||||
|
||||
<br><br>
|
||||
|
||||
### Runtime/Editor Preset for UIEffect
|
||||
@@ -272,6 +339,10 @@ You can create and use presets for `UIEffect` components.
|
||||
- In the [Project Settings](#project-settings), you can register saved editor presets as runtime presets.
|
||||
- Runtime presets can be loaded using the `UIEffect.LoadPreset(presetName)` method.
|
||||
|
||||
> [!TIP]
|
||||
> Editor presets are saved in the `UIEffectPresets` directory.
|
||||
> You can also create subdirectories to customize the preset menu.
|
||||
|
||||
<br><br>
|
||||
|
||||
### Usage with Code
|
||||
@@ -301,18 +372,35 @@ UIEffectProjectSettings.shaderVariantCollection.WarmUp();
|
||||
|
||||
### Project Settings
|
||||
|
||||

|
||||

|
||||
|
||||
You can adjust the project-wide settings for UIEffect. (`Edit > Project Settings > UI > UIEffect`)
|
||||
|
||||
#### Settings
|
||||
|
||||
- **Transform Sensitivity**: `Low`, `Medium`, `High`
|
||||
- Set the sensitivity of the transformation when `Use Target Transform` is enabled in `UIEffectReplica` component.
|
||||
- **Runtime Presets**: A list of presets that can be loaded at runtime. Load them using `UIEffect.LoadPreset(presetName)` method.
|
||||
- **Fallback Variant Behavior**: Specifies the behavior when an unregistered shader variant is used in the editor.
|
||||
- `Register Variant`: Adds the variant to `Registered Variants` for runtime use.
|
||||
- `LogError`: Outputs a error and adds it to `Unregistered Variants`.
|
||||
|
||||
#### Editor
|
||||
|
||||
- **Use HDR Color Picker**: If enabled, the HDR color picker will be used in the inspector.
|
||||
|
||||
#### Shader
|
||||
|
||||
- **Optional Shaders (UIEffect)**: A list of shaders that will be prioritized when a ui-effect shader is
|
||||
requested.
|
||||
- If the shader is included in the list, that shader will be used.
|
||||
- If it is not in the list, the following shaders will be used in order:
|
||||
- If the shader name contains `(UIEffect)`, that shader will be used.
|
||||
- If `Hidden/<shader_name> (UIEffect)` exists, that shader will be used.
|
||||
- As a fallback, `UI/Default (UIEffect)` will be used.
|
||||
- **Registered Variants**: A list of shader variants available at runtime. Use "-" button to remove unused variants,
|
||||
reducing build time and file size.
|
||||
- By default, the used ui-effect shaders will be included in the build. You can remove them if you don't need.
|
||||
- **Unregistered Variants**: A list of shader variants that are not registered. Use "+" button to add variants.
|
||||
- **Registered Variants**: A list of shader variants available at runtime. Use "-" button to remove unused variants, reducing build time and file size.
|
||||
- **Error On Unregistered Variant**: If enabled, an error will be displayed when an unregistered shader variant is used.
|
||||
- The shader variant will be automatically added to the `Unregistered Variants` list.
|
||||
|
||||
<br><br>
|
||||
|
||||
@@ -323,6 +411,8 @@ Here are the limitations of UIEffect:
|
||||
- Shader variants used at runtime must be registered in the [Project Settings](#project-settings).
|
||||
- When using UIEffect with TextMeshProUGUI, `SamplingFilter.BlurMedium` and `SamplingFilter.BlurDetail` are not supported due to performance considerations.
|
||||
- These will automatically fall back to `SamplingFilter.BlurFast`.
|
||||
- UIEffect supports default UI components (`Image`, `RawImage`, `Text`) and `TextMeshProUGUI`.
|
||||
- If you want to use UIEffect with other components, create a issue or pull request.
|
||||
|
||||
<br><br>
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9c99c9c4ae6f4d4aa041ad31432e922
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -76,6 +76,21 @@ namespace Coffee.UIEffects
|
||||
Mirror
|
||||
}
|
||||
|
||||
public enum GradationMode
|
||||
{
|
||||
None = 0,
|
||||
Horizontal,
|
||||
HorizontalGradient,
|
||||
Vertical,
|
||||
VerticalGradient,
|
||||
RadialFast,
|
||||
RadialDetail,
|
||||
DiagonalToRightBottom,
|
||||
DiagonalToLeftBottom,
|
||||
Angle,
|
||||
AngleGradient
|
||||
}
|
||||
|
||||
internal static class BlendTypeConverter
|
||||
{
|
||||
public static (BlendMode, BlendMode) Convert(this (BlendType type, BlendMode src, BlendMode dst) self)
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace Coffee.UIEffectInternal
|
||||
public static T[] GetComponentsInChildren<T>(this Component self, int depth)
|
||||
where T : Component
|
||||
{
|
||||
var results = ListPool<T>.Rent();
|
||||
var results = InternalListPool<T>.Rent();
|
||||
self.GetComponentsInChildren_Internal(results, depth);
|
||||
var array = results.ToArray();
|
||||
ListPool<T>.Return(ref results);
|
||||
InternalListPool<T>.Return(ref results);
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Coffee.UIEffectInternal
|
||||
{
|
||||
internal static class MeshExtensions
|
||||
{
|
||||
internal static readonly ObjectPool<Mesh> s_MeshPool = new ObjectPool<Mesh>(
|
||||
internal static readonly InternalObjectPool<Mesh> s_MeshPool = new InternalObjectPool<Mesh>(
|
||||
() =>
|
||||
{
|
||||
var mesh = new Mesh
|
||||
@@ -38,10 +38,10 @@ namespace Coffee.UIEffectInternal
|
||||
{
|
||||
if (!self || !dst) return;
|
||||
|
||||
var vector3List = ListPool<Vector3>.Rent();
|
||||
var vector4List = ListPool<Vector4>.Rent();
|
||||
var color32List = ListPool<Color32>.Rent();
|
||||
var intList = ListPool<int>.Rent();
|
||||
var vector3List = InternalListPool<Vector3>.Rent();
|
||||
var vector4List = InternalListPool<Vector4>.Rent();
|
||||
var color32List = InternalListPool<Color32>.Rent();
|
||||
var intList = InternalListPool<int>.Rent();
|
||||
|
||||
dst.Clear(false);
|
||||
|
||||
@@ -73,10 +73,10 @@ namespace Coffee.UIEffectInternal
|
||||
dst.SetUVs(3, vector4List);
|
||||
|
||||
dst.RecalculateBounds();
|
||||
ListPool<Vector3>.Return(ref vector3List);
|
||||
ListPool<Vector4>.Return(ref vector4List);
|
||||
ListPool<Color32>.Return(ref color32List);
|
||||
ListPool<int>.Return(ref intList);
|
||||
InternalListPool<Vector3>.Return(ref vector3List);
|
||||
InternalListPool<Vector4>.Return(ref vector4List);
|
||||
InternalListPool<Color32>.Return(ref color32List);
|
||||
InternalListPool<int>.Return(ref intList);
|
||||
}
|
||||
|
||||
public static void CopyTo(this Mesh self, VertexHelper dst)
|
||||
@@ -92,13 +92,13 @@ namespace Coffee.UIEffectInternal
|
||||
{
|
||||
if (!self || dst == null) return;
|
||||
|
||||
var positions = ListPool<Vector3>.Rent();
|
||||
var normals = ListPool<Vector3>.Rent();
|
||||
var uv0 = ListPool<Vector4>.Rent();
|
||||
var uv1 = ListPool<Vector4>.Rent();
|
||||
var tangents = ListPool<Vector4>.Rent();
|
||||
var colors = ListPool<Color32>.Rent();
|
||||
var indices = ListPool<int>.Rent();
|
||||
var positions = InternalListPool<Vector3>.Rent();
|
||||
var normals = InternalListPool<Vector3>.Rent();
|
||||
var uv0 = InternalListPool<Vector4>.Rent();
|
||||
var uv1 = InternalListPool<Vector4>.Rent();
|
||||
var tangents = InternalListPool<Vector4>.Rent();
|
||||
var colors = InternalListPool<Color32>.Rent();
|
||||
var indices = InternalListPool<int>.Rent();
|
||||
self.GetVertices(positions);
|
||||
self.GetColors(colors);
|
||||
self.GetUVs(0, uv0);
|
||||
@@ -118,13 +118,13 @@ namespace Coffee.UIEffectInternal
|
||||
dst.AddTriangle(indices[i], indices[i + 1], indices[i + 2]);
|
||||
}
|
||||
|
||||
ListPool<Vector3>.Return(ref positions);
|
||||
ListPool<Vector3>.Return(ref normals);
|
||||
ListPool<Vector4>.Return(ref uv0);
|
||||
ListPool<Vector4>.Return(ref uv1);
|
||||
ListPool<Vector4>.Return(ref tangents);
|
||||
ListPool<Color32>.Return(ref colors);
|
||||
ListPool<int>.Return(ref indices);
|
||||
InternalListPool<Vector3>.Return(ref positions);
|
||||
InternalListPool<Vector3>.Return(ref normals);
|
||||
InternalListPool<Vector4>.Return(ref uv0);
|
||||
InternalListPool<Vector4>.Return(ref uv1);
|
||||
InternalListPool<Vector4>.Return(ref tangents);
|
||||
InternalListPool<Color32>.Return(ref colors);
|
||||
InternalListPool<int>.Return(ref indices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
|
||||
namespace Coffee.UIEffectInternal
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for Transform class.
|
||||
/// </summary>
|
||||
internal static class TransformExtensions
|
||||
{
|
||||
private const float k_DefaultEpsilon = 1f / (2 ^ 8);
|
||||
private static readonly Vector3[] s_Corners = new Vector3[4];
|
||||
|
||||
/// <summary>
|
||||
/// Compare the hierarchy index of one transform with another transform.
|
||||
/// </summary>
|
||||
public static int CompareHierarchyIndex(this Transform self, Transform other, Transform stopAt)
|
||||
{
|
||||
if (self == other) return 0;
|
||||
|
||||
Profiler.BeginSample("(COF)[TransformExt] CompareHierarchyIndex > GetTransforms");
|
||||
var lTrs = self.GetTransforms(stopAt, ListPool<Transform>.Rent());
|
||||
var rTrs = other.GetTransforms(stopAt, ListPool<Transform>.Rent());
|
||||
Profiler.EndSample();
|
||||
|
||||
Profiler.BeginSample("(COF)[TransformExt] CompareHierarchyIndex > Calc");
|
||||
var loop = Mathf.Max(lTrs.Count, rTrs.Count);
|
||||
var result = 0;
|
||||
for (var i = 0; i < loop; ++i)
|
||||
{
|
||||
var selfIndex = 0 <= lTrs.Count - i - 1 ? lTrs[lTrs.Count - i - 1].GetSiblingIndex() : -1;
|
||||
var otherIndex = 0 <= rTrs.Count - i - 1 ? rTrs[rTrs.Count - i - 1].GetSiblingIndex() : -1;
|
||||
if (selfIndex == otherIndex) continue;
|
||||
|
||||
result = selfIndex - otherIndex;
|
||||
break;
|
||||
}
|
||||
|
||||
Profiler.EndSample();
|
||||
|
||||
Profiler.BeginSample("(COF)[TransformExt] CompareHierarchyIndex > Return");
|
||||
ListPool<Transform>.Return(ref lTrs);
|
||||
ListPool<Transform>.Return(ref rTrs);
|
||||
Profiler.EndSample();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static List<Transform> GetTransforms(this Transform self, Transform stopAt, List<Transform> results)
|
||||
{
|
||||
results.Clear();
|
||||
while (self != stopAt)
|
||||
{
|
||||
results.Add(self);
|
||||
self = self.parent;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a transform has changed.
|
||||
/// </summary>
|
||||
public static bool HasChanged(this Transform self, ref Matrix4x4 prev, float epsilon = k_DefaultEpsilon)
|
||||
{
|
||||
return self.HasChanged(null, ref prev, epsilon);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a transform has changed.
|
||||
/// </summary>
|
||||
public static bool HasChanged(this Transform self, Transform baseTransform, ref Matrix4x4 prev,
|
||||
float epsilon = k_DefaultEpsilon)
|
||||
{
|
||||
if (!self) return false;
|
||||
|
||||
var hash = baseTransform ? baseTransform.GetHashCode() : 0;
|
||||
if (FrameCache.TryGet(self, nameof(HasChanged), hash, out bool result)) return result;
|
||||
|
||||
var matrix = baseTransform
|
||||
? baseTransform.worldToLocalMatrix * self.localToWorldMatrix
|
||||
: self.localToWorldMatrix;
|
||||
var current = matrix * Matrix4x4.Scale(Vector3.one * 10000);
|
||||
result = !Approximately(current, prev, epsilon);
|
||||
FrameCache.Set(self, nameof(HasChanged), hash, result);
|
||||
if (result)
|
||||
{
|
||||
prev = current;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool Approximately(Matrix4x4 self, Matrix4x4 other, float epsilon = k_DefaultEpsilon)
|
||||
{
|
||||
for (var i = 0; i < 16; i++)
|
||||
{
|
||||
if (epsilon < Mathf.Abs(self[i] - other[i]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Bounds GetRelativeBounds(this Transform self, Transform child)
|
||||
{
|
||||
if (!self || !child)
|
||||
{
|
||||
return new Bounds(Vector3.zero, Vector3.zero);
|
||||
}
|
||||
|
||||
var list = ListPool<RectTransform>.Rent();
|
||||
child.GetComponentsInChildren(false, list);
|
||||
if (list.Count == 0)
|
||||
{
|
||||
ListPool<RectTransform>.Return(ref list);
|
||||
return new Bounds(Vector3.zero, Vector3.zero);
|
||||
}
|
||||
|
||||
var max = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
|
||||
var min = new Vector3(float.MinValue, float.MinValue, float.MinValue);
|
||||
var worldToLocalMatrix = self.worldToLocalMatrix;
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
list[i].GetWorldCorners(s_Corners);
|
||||
for (var j = 0; j < 4; j++)
|
||||
{
|
||||
var lhs = worldToLocalMatrix.MultiplyPoint3x4(s_Corners[j]);
|
||||
max = Vector3.Min(lhs, max);
|
||||
min = Vector3.Max(lhs, min);
|
||||
}
|
||||
}
|
||||
|
||||
ListPool<RectTransform>.Return(ref list);
|
||||
|
||||
var rectTransformBounds = new Bounds(max, Vector3.zero);
|
||||
rectTransformBounds.Encapsulate(min);
|
||||
return rectTransformBounds;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace Coffee.UIEffectInternal
|
||||
public abstract class PreloadedProjectSettings : ScriptableObject
|
||||
#if UNITY_EDITOR
|
||||
{
|
||||
private class MyAllPostprocessor : AssetPostprocessor
|
||||
private class Postprocessor : AssetPostprocessor
|
||||
{
|
||||
private static void OnPostprocessAllAssets(string[] _, string[] __, string[] ___, string[] ____)
|
||||
{
|
||||
@@ -47,6 +47,11 @@ namespace Coffee.UIEffectInternal
|
||||
{
|
||||
SetDefaultSettings(defaultSettings);
|
||||
}
|
||||
|
||||
if (defaultSettings)
|
||||
{
|
||||
defaultSettings.OnInitialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +115,10 @@ namespace Coffee.UIEffectInternal
|
||||
protected virtual void OnCreateAsset()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnInitialize()
|
||||
{
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
@@ -124,6 +133,8 @@ namespace Coffee.UIEffectInternal
|
||||
#if UNITY_EDITOR
|
||||
private string _jsonText;
|
||||
|
||||
public static bool hasInstance => s_Instance;
|
||||
|
||||
public static T instance
|
||||
{
|
||||
get
|
||||
|
||||
@@ -10,8 +10,9 @@ namespace Coffee.UIEffectInternal
|
||||
/// </summary>
|
||||
internal class FastActionBase<T>
|
||||
{
|
||||
private static readonly ObjectPool<LinkedListNode<T>> s_NodePool =
|
||||
new ObjectPool<LinkedListNode<T>>(() => new LinkedListNode<T>(default), _ => true, x => x.Value = default);
|
||||
private static readonly InternalObjectPool<LinkedListNode<T>> s_NodePool =
|
||||
new InternalObjectPool<LinkedListNode<T>>(() => new LinkedListNode<T>(default), _ => true,
|
||||
x => x.Value = default);
|
||||
|
||||
private readonly LinkedList<T> _delegates = new LinkedList<T>();
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Coffee.UIEffectInternal
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
private static void Clear()
|
||||
public static void Clear()
|
||||
{
|
||||
s_Repository.Clear();
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ namespace Coffee.UIEffectInternal
|
||||
#if UNITY_EDITOR
|
||||
public static T[] GetAllComponentsInPrefabStage<T>() where T : Component
|
||||
{
|
||||
if (!PrefabStageUtility.GetCurrentPrefabStage()) return Array.Empty<T>();
|
||||
|
||||
var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
|
||||
if (!prefabStage) return Array.Empty<T>();
|
||||
if (prefabStage == null) return Array.Empty<T>();
|
||||
|
||||
return prefabStage.prefabContentsRoot.GetComponentsInChildren<T>(true);
|
||||
}
|
||||
|
||||
public static bool isBatchOrBuilding => Application.isBatchMode || BuildPipeline.isBuildingPlayer;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,58 @@ namespace Coffee.UIEffectInternal
|
||||
/// <summary>
|
||||
/// Object pool.
|
||||
/// </summary>
|
||||
internal class ObjectPool<T>
|
||||
internal class InternalObjectPool<T> where T : class
|
||||
{
|
||||
#if UNITY_2021_1_OR_NEWER
|
||||
private readonly Predicate<T> _onValid; // Delegate for checking if instances are valid
|
||||
private readonly UnityEngine.Pool.ObjectPool<T> _pool;
|
||||
|
||||
public InternalObjectPool(Func<T> onCreate, Predicate<T> onValid, Action<T> onReturn)
|
||||
{
|
||||
_pool = new UnityEngine.Pool.ObjectPool<T>(onCreate, null, onReturn);
|
||||
_onValid = onValid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rent an instance from the pool.
|
||||
/// When you no longer need it, return it with <see cref="Return" />.
|
||||
/// </summary>
|
||||
public T Rent()
|
||||
{
|
||||
while (0 < _pool.CountInactive)
|
||||
{
|
||||
var instance = _pool.Get();
|
||||
if (_onValid(instance))
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
// If there are no instances in the pool, create a new one.
|
||||
Logging.Log(this, $"A new instance is created (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
|
||||
return _pool.Get();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return an instance to the pool and assign null.
|
||||
/// Be sure to return the instance obtained with <see cref="Rent" /> with this method.
|
||||
/// </summary>
|
||||
public void Return(ref T instance)
|
||||
{
|
||||
if (instance == null) return; // Ignore if already pooled or null.
|
||||
|
||||
_pool.Release(instance);
|
||||
Logging.Log(this, $"An instance is released (pooled: {_pool.CountInactive}, created: {_pool.CountAll}).");
|
||||
instance = default; // Set the reference to null.
|
||||
}
|
||||
#else
|
||||
private readonly Func<T> _onCreate; // Delegate for creating instances
|
||||
private readonly Action<T> _onReturn; // Delegate for returning instances to the pool
|
||||
private readonly Predicate<T> _onValid; // Delegate for checking if instances are valid
|
||||
private readonly Stack<T> _pool = new Stack<T>(32); // Object pool
|
||||
private int _count; // Total count of created instances
|
||||
|
||||
public ObjectPool(Func<T> onCreate, Predicate<T> onValid, Action<T> onReturn)
|
||||
public InternalObjectPool(Func<T> onCreate, Predicate<T> onValid, Action<T> onReturn)
|
||||
{
|
||||
_onCreate = onCreate;
|
||||
_onValid = onValid;
|
||||
@@ -54,15 +97,40 @@ namespace Coffee.UIEffectInternal
|
||||
Logging.Log(this, $"An instance is released (pooled: {_pool.Count}, created: {_count}).");
|
||||
instance = default; // Set the reference to null.
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Object pool for <see cref="List{T}" />.
|
||||
/// </summary>
|
||||
internal static class ListPool<T>
|
||||
internal static class InternalListPool<T>
|
||||
{
|
||||
private static readonly ObjectPool<List<T>> s_ListPool =
|
||||
new ObjectPool<List<T>>(() => new List<T>(), _ => true, x => x.Clear());
|
||||
#if UNITY_2021_1_OR_NEWER
|
||||
/// <summary>
|
||||
/// Rent an instance from the pool.
|
||||
/// When you no longer need it, return it with <see cref="Return" />.
|
||||
/// </summary>
|
||||
public static List<T> Rent()
|
||||
{
|
||||
return UnityEngine.Pool.ListPool<T>.Get();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return an instance to the pool and assign null.
|
||||
/// Be sure to return the instance obtained with <see cref="Rent" /> with this method.
|
||||
/// </summary>
|
||||
public static void Return(ref List<T> toRelease)
|
||||
{
|
||||
if (toRelease != null)
|
||||
{
|
||||
UnityEngine.Pool.ListPool<T>.Release(toRelease);
|
||||
}
|
||||
|
||||
toRelease = null;
|
||||
}
|
||||
#else
|
||||
private static readonly InternalObjectPool<List<T>> s_ListPool =
|
||||
new InternalObjectPool<List<T>>(() => new List<T>(), _ => true, x => x.Clear());
|
||||
|
||||
/// <summary>
|
||||
/// Rent an instance from the pool.
|
||||
@@ -81,5 +149,6 @@ namespace Coffee.UIEffectInternal
|
||||
{
|
||||
s_ListPool.Return(ref toRelease);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIEffectInternal
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public sealed class PowerRangeAttribute : PropertyAttribute
|
||||
{
|
||||
public readonly float min;
|
||||
public readonly float max;
|
||||
public readonly float power;
|
||||
|
||||
public PowerRangeAttribute(float min, float max, float power)
|
||||
{
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.power = power;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[CustomPropertyDrawer(typeof(PowerRangeAttribute))]
|
||||
internal sealed class RangeDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var labelWidth = EditorGUIUtility.labelWidth;
|
||||
var attr = (PowerRangeAttribute)attribute;
|
||||
label = EditorGUI.BeginProperty(r, label, property);
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var rSlider = new Rect(r.x + labelWidth + 1, r.y, r.width - labelWidth - 57, r.height);
|
||||
var powValue = Mathf.Log(property.floatValue, attr.power);
|
||||
var powMin = Mathf.Log(attr.min, attr.power);
|
||||
var powMax = Mathf.Log(attr.max, attr.power);
|
||||
powValue = GUI.HorizontalSlider(rSlider, powValue, powMin, powMax);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
property.floatValue = Mathf.Clamp(Mathf.Pow(attr.power, powValue), attr.min, attr.max);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUIUtility.labelWidth = r.width - 53;
|
||||
var newValue = EditorGUI.FloatField(r, label, property.floatValue);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
property.floatValue = Mathf.Clamp(newValue, attr.min, attr.max);
|
||||
}
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
EditorGUIUtility.labelWidth = labelWidth;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c353a915a3dd4175bed99560cfc1aad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,474 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
#if UNITY_EDITOR
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEditor;
|
||||
using UnityEditor.PackageManager.UI;
|
||||
using UnityEditorInternal;
|
||||
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
|
||||
using Object = UnityEngine.Object;
|
||||
#endif
|
||||
|
||||
namespace Coffee.UIEffectInternal
|
||||
{
|
||||
[Serializable]
|
||||
public class ShaderVariantRegistry
|
||||
{
|
||||
[Serializable]
|
||||
internal class StringPair : IEquatable<StringPair>
|
||||
{
|
||||
public string key;
|
||||
public string value;
|
||||
|
||||
public bool Equals(StringPair other)
|
||||
{
|
||||
if (other == null) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return key == other.key && value == other.value;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is StringPair other && Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return ((key != null ? key.GetHashCode() : 0) * 397) ^ (value != null ? value.GetHashCode() : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<int, string> _cachedOptionalShaders = new Dictionary<int, string>();
|
||||
|
||||
[SerializeField]
|
||||
private List<StringPair> m_OptionalShaders = new List<StringPair>();
|
||||
|
||||
[SerializeField]
|
||||
internal ShaderVariantCollection m_Asset;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[SerializeField]
|
||||
private bool m_ErrorOnUnregisteredVariant = false;
|
||||
|
||||
[SerializeField]
|
||||
private List<StringPair> m_UnregisteredVariants = new List<StringPair>();
|
||||
#endif
|
||||
|
||||
public ShaderVariantCollection shaderVariantCollection => m_Asset;
|
||||
|
||||
public Shader FindOptionalShader(Shader shader,
|
||||
string requiredName,
|
||||
string format,
|
||||
string defaultOptionalShaderName)
|
||||
{
|
||||
if (!shader) return null;
|
||||
|
||||
// Already cached.
|
||||
var id = shader.GetInstanceID();
|
||||
if (_cachedOptionalShaders.TryGetValue(id, out var optionalShaderName))
|
||||
{
|
||||
return Shader.Find(optionalShaderName);
|
||||
}
|
||||
|
||||
// The shader has
|
||||
if (shader.name.Contains(requiredName))
|
||||
{
|
||||
_cachedOptionalShaders[id] = shader.name;
|
||||
return shader;
|
||||
}
|
||||
|
||||
// Find optional shader.
|
||||
Shader optionalShader;
|
||||
var shaderName = shader.name;
|
||||
foreach (var pair in m_OptionalShaders)
|
||||
{
|
||||
if (pair.key != shaderName) continue;
|
||||
optionalShader = Shader.Find(pair.value);
|
||||
if (optionalShader)
|
||||
{
|
||||
_cachedOptionalShaders[id] = pair.value;
|
||||
return optionalShader;
|
||||
}
|
||||
}
|
||||
|
||||
// Find optional shader by format.
|
||||
optionalShaderName = string.Format(format, shader.name);
|
||||
optionalShader = Shader.Find(optionalShaderName);
|
||||
if (optionalShader)
|
||||
{
|
||||
_cachedOptionalShaders[id] = optionalShaderName;
|
||||
return optionalShader;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
ImportFromSample(optionalShaderName);
|
||||
#endif
|
||||
|
||||
// Find default optional shader.
|
||||
_cachedOptionalShaders[id] = defaultOptionalShaderName;
|
||||
return Shader.Find(defaultOptionalShaderName);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private readonly HashSet<StringPair> _logVariants = new HashSet<StringPair>();
|
||||
private readonly Dictionary<string, string> _sampleNames = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Import the sample containing the requested shader.
|
||||
/// If choice 'Import' is selected, the sample is imported.
|
||||
/// If choice 'Skip in this session' is selected, the sample is skipped in this session.
|
||||
/// </summary>
|
||||
public void ImportFromSample(string shaderName)
|
||||
{
|
||||
if (Misc.isBatchOrBuilding) return;
|
||||
|
||||
// Find sample name.
|
||||
if (_sampleNames.TryGetValue(shaderName, out var sampleName))
|
||||
{
|
||||
// Find package info.
|
||||
var pInfo = PackageInfo.FindForAssembly(typeof(ShaderVariantRegistry).Assembly);
|
||||
if (pInfo == null) return;
|
||||
|
||||
// Find sample. If not found (resolvedPath == null), skip.
|
||||
var sample = Sample.FindByPackage(pInfo.name, pInfo.version)
|
||||
.FirstOrDefault(x => x.displayName == sampleName);
|
||||
if (sample.resolvedPath == null) return;
|
||||
|
||||
// Import the sample if selected.
|
||||
var importSelected = EditorUtility.DisplayDialog($"Import {sampleName}",
|
||||
$"Import '{sampleName}' to use the shader '{shaderName}'", "Import", "Cancel");
|
||||
if (importSelected)
|
||||
{
|
||||
EditorApplication.delayCall += () =>
|
||||
{
|
||||
sample.Import();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearCache()
|
||||
{
|
||||
_cachedOptionalShaders.Clear();
|
||||
}
|
||||
|
||||
public void RegisterSamples((string shaderName, string sampleName)[] samples)
|
||||
{
|
||||
foreach (var (shaderName, sampleName) in samples)
|
||||
{
|
||||
_sampleNames[shaderName] = sampleName;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeIfNeeded(Object owner, string optionalName)
|
||||
{
|
||||
Profiler.BeginSample("(EDITOR/COF)[ShaderVariantRegistry] InitializeIfNeeded");
|
||||
|
||||
// Register optional shader names by shader comment.
|
||||
if (!string.IsNullOrEmpty(optionalName))
|
||||
{
|
||||
var optionalShaders = ShaderUtil.GetAllShaderInfo()
|
||||
.Where(s => s.name.Contains(optionalName))
|
||||
.Select(s => (s.name, path: AssetDatabase.GetAssetPath(Shader.Find(s.name))))
|
||||
.Where(x => !string.IsNullOrEmpty(x.path))
|
||||
.SelectMany(x =>
|
||||
{
|
||||
return File.ReadLines(x.path)
|
||||
.Take(10)
|
||||
.Where(line => line.Contains($"OptionalShader@{optionalName}"))
|
||||
.Select(line => Regex.Match(line, @":\s*(.*)$"))
|
||||
.Where(match => match.Success)
|
||||
.Select(match => new StringPair() { key = match.Groups[1].Value, value = x.name });
|
||||
})
|
||||
.Where(pair => m_OptionalShaders.All(x => x.key != pair.key))
|
||||
.ToArray();
|
||||
if (0 < optionalShaders.Length)
|
||||
{
|
||||
m_OptionalShaders.AddRange(optionalShaders);
|
||||
EditorUtility.SetDirty(owner);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_Asset && AssetDatabase.IsMainAsset(owner))
|
||||
{
|
||||
// Find ShaderVariantCollection in owner.
|
||||
var path = AssetDatabase.GetAssetPath(owner);
|
||||
var collection = AssetDatabase.LoadAssetAtPath<ShaderVariantCollection>(path);
|
||||
if (collection)
|
||||
{
|
||||
m_Asset = collection;
|
||||
}
|
||||
// Create new ShaderVariantCollection.
|
||||
else
|
||||
{
|
||||
m_Asset = new ShaderVariantCollection() { name = "ShaderVariants" };
|
||||
AssetDatabase.AddObjectToAsset(m_Asset, owner);
|
||||
}
|
||||
|
||||
EditorUtility.SetDirty(owner);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
ClearCache();
|
||||
Profiler.EndSample();
|
||||
}
|
||||
|
||||
internal void RegisterVariant(Material material, string path)
|
||||
{
|
||||
if (!material || !material.shader || !m_Asset) return;
|
||||
|
||||
Profiler.BeginSample("(EDITOR/COF)[ShaderVariantRegistry] RegisterVariant");
|
||||
var shaderName = material.shader.name;
|
||||
var validKeywords = material.shaderKeywords
|
||||
.Where(x => !Regex.IsMatch(x, "(_EDITOR|EDITOR_)"))
|
||||
.ToArray();
|
||||
var keywords = string.Join(" ", validKeywords);
|
||||
var variant = new ShaderVariantCollection.ShaderVariant
|
||||
{
|
||||
shader = material.shader,
|
||||
keywords = validKeywords
|
||||
};
|
||||
|
||||
// Already registered.
|
||||
var pair = new StringPair() { key = shaderName, value = keywords };
|
||||
if (m_Asset.Contains(variant))
|
||||
{
|
||||
m_UnregisteredVariants.Remove(pair);
|
||||
Profiler.EndSample();
|
||||
return;
|
||||
}
|
||||
|
||||
// Error when unregistered variant.
|
||||
if (m_ErrorOnUnregisteredVariant)
|
||||
{
|
||||
if (!m_UnregisteredVariants.Contains(pair))
|
||||
{
|
||||
m_UnregisteredVariants.Add(pair);
|
||||
}
|
||||
|
||||
if (_logVariants.Add(pair))
|
||||
{
|
||||
keywords = string.IsNullOrEmpty(keywords) ? "no keywords" : keywords;
|
||||
Debug.LogError($"Shader variant '{shaderName} <{keywords}>' is not registered.\n" +
|
||||
$"Register it in 'ProjectSettings > {path}' to use it in player.", m_Asset);
|
||||
}
|
||||
|
||||
Profiler.EndSample();
|
||||
return;
|
||||
}
|
||||
|
||||
m_Asset.Add(variant);
|
||||
m_UnregisteredVariants.Remove(pair);
|
||||
Profiler.EndSample();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
internal class ShaderVariantRegistryEditor
|
||||
{
|
||||
private static readonly MethodInfo s_MiDrawShaderEntry =
|
||||
Type.GetType("UnityEditor.ShaderVariantCollectionInspector, UnityEditor")
|
||||
?.GetMethod("DrawShaderEntry", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
private readonly SerializedProperty _errorOnUnregisteredVariant;
|
||||
private readonly SerializedProperty _asset;
|
||||
private readonly ReorderableList _rlOptionalShaders;
|
||||
private readonly ReorderableList _rlUnregisteredVariants;
|
||||
private Editor _editor;
|
||||
private bool _expand;
|
||||
|
||||
public ShaderVariantRegistryEditor(SerializedProperty property, string optionName)
|
||||
{
|
||||
var so = property.serializedObject;
|
||||
var optionalShaders = property.FindPropertyRelative("m_OptionalShaders");
|
||||
var unregisteredVariants = property.FindPropertyRelative("m_UnregisteredVariants");
|
||||
_errorOnUnregisteredVariant = property.FindPropertyRelative("m_ErrorOnUnregisteredVariant");
|
||||
_asset = property.FindPropertyRelative("m_Asset");
|
||||
|
||||
_rlOptionalShaders = new ReorderableList(so, optionalShaders, false, true, true, true);
|
||||
_rlOptionalShaders.drawHeaderCallback = rect =>
|
||||
{
|
||||
var rLabel = new Rect(rect.x, rect.y, rect.width - 80, rect.height);
|
||||
EditorGUI.LabelField(rLabel,
|
||||
EditorGUIUtility.TrTextContent($"Optional Shaders {optionName}",
|
||||
"Specify optional shaders explicitly."));
|
||||
|
||||
var rButton = new Rect(rect.x + rect.width - 80, rect.y, 80, rect.height - 4);
|
||||
if (GUI.Button(rButton, "Clear All", EditorStyles.miniButton))
|
||||
{
|
||||
optionalShaders.ClearArray();
|
||||
}
|
||||
};
|
||||
_rlOptionalShaders.elementHeight = EditorGUIUtility.singleLineHeight * 2 + 4;
|
||||
_rlOptionalShaders.drawElementCallback = (r, index, isActive, isFocused) =>
|
||||
{
|
||||
if (optionalShaders.arraySize <= index) return;
|
||||
|
||||
var element = optionalShaders.GetArrayElementAtIndex(index);
|
||||
if (element == null) return;
|
||||
|
||||
var key = element.FindPropertyRelative("key");
|
||||
var value = element.FindPropertyRelative("value");
|
||||
var h = EditorGUIUtility.singleLineHeight;
|
||||
var rKey = new Rect(r.x, r.y + 2, r.width, h);
|
||||
if (GUI.Button(rKey, key.stringValue, EditorStyles.popup))
|
||||
{
|
||||
ShowShaderDropdown(key, optionName, false);
|
||||
}
|
||||
|
||||
var rArrow = new Rect(r.x, r.y + h + 4, 20, h);
|
||||
EditorGUI.LabelField(rArrow, "->");
|
||||
|
||||
var rValue = new Rect(r.x + 20, r.y + h + 4, r.width - 20, h);
|
||||
if (GUI.Button(rValue, value.stringValue, EditorStyles.popup))
|
||||
{
|
||||
ShowShaderDropdown(value, optionName, true);
|
||||
}
|
||||
};
|
||||
|
||||
_rlUnregisteredVariants = new ReorderableList(so, unregisteredVariants, false, true, false, true);
|
||||
_rlUnregisteredVariants.drawHeaderCallback = rect =>
|
||||
{
|
||||
var rWarning = new Rect(rect.x, rect.y, 20, rect.height);
|
||||
var icon = EditorGUIUtility.TrIconContent("warning",
|
||||
"These variants are not registered.\nRegister them to use in player.");
|
||||
EditorGUI.LabelField(rWarning, icon);
|
||||
|
||||
var rLabel = new Rect(rect.x + 20, rect.y, 200, rect.height);
|
||||
EditorGUI.LabelField(rLabel, "Unregistered Shader Variants");
|
||||
|
||||
var rButton = new Rect(rect.x + rect.width - 80, rect.y, 80, rect.height - 4);
|
||||
if (GUI.Button(rButton, "Clear All", EditorStyles.miniButton))
|
||||
{
|
||||
unregisteredVariants.ClearArray();
|
||||
}
|
||||
};
|
||||
_rlUnregisteredVariants.elementHeight = EditorGUIUtility.singleLineHeight * 2 + 4;
|
||||
_rlUnregisteredVariants.drawElementCallback = (r, index, isActive, isFocused) =>
|
||||
{
|
||||
if (unregisteredVariants.arraySize <= index) return;
|
||||
|
||||
var element = unregisteredVariants.GetArrayElementAtIndex(index);
|
||||
if (element == null) return;
|
||||
|
||||
var key = element.FindPropertyRelative("key");
|
||||
var value = element.FindPropertyRelative("value");
|
||||
|
||||
var h = EditorGUIUtility.singleLineHeight;
|
||||
var rKey = new Rect(r.x, r.y + 2, r.width, h);
|
||||
EditorGUI.LabelField(rKey, key.stringValue, EditorStyles.popup);
|
||||
|
||||
var rValue = new Rect(r.x + 20, r.y + h + 5, r.width - 40, 14);
|
||||
var keywords = string.IsNullOrEmpty(value.stringValue) ? "<no keywords>" : value.stringValue;
|
||||
EditorGUI.TextField(rValue, GUIContent.none, keywords, "LODRenderersText");
|
||||
|
||||
var rButton = new Rect(r.x + r.width - 20, r.y + h + 4, 20, h);
|
||||
if (GUI.Button(rButton, EditorGUIUtility.IconContent("icons/toolbar plus.png"), "iconbutton"))
|
||||
{
|
||||
var collection = _asset.objectReferenceValue as ShaderVariantCollection;
|
||||
AddVariant(collection, key.stringValue, value.stringValue);
|
||||
unregisteredVariants.DeleteArrayElementAtIndex(index);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
_rlOptionalShaders.DoLayoutList();
|
||||
_expand = DrawRegisteredShaderVariants(_expand, _asset, ref _editor);
|
||||
if (0 < _rlUnregisteredVariants.serializedProperty.arraySize)
|
||||
{
|
||||
EditorGUILayout.Space(4);
|
||||
_rlUnregisteredVariants.DoLayoutList();
|
||||
EditorGUILayout.Space(-20);
|
||||
}
|
||||
|
||||
var labelWidth = EditorGUIUtility.labelWidth;
|
||||
EditorGUIUtility.labelWidth = 180;
|
||||
EditorGUILayout.PropertyField(_errorOnUnregisteredVariant);
|
||||
EditorGUIUtility.labelWidth = labelWidth;
|
||||
}
|
||||
|
||||
private static void AddVariant(ShaderVariantCollection collection, string shaderName, string keywords)
|
||||
{
|
||||
if (collection == null) return;
|
||||
|
||||
var shader = Shader.Find(shaderName);
|
||||
if (!shader) return;
|
||||
|
||||
collection.Add(new ShaderVariantCollection.ShaderVariant
|
||||
{
|
||||
shader = shader,
|
||||
keywords = keywords.Split(' ')
|
||||
});
|
||||
EditorUtility.SetDirty(collection);
|
||||
}
|
||||
|
||||
private static bool DrawRegisteredShaderVariants(bool expand, SerializedProperty property, ref Editor editor)
|
||||
{
|
||||
var collection = property.objectReferenceValue as ShaderVariantCollection;
|
||||
if (collection == null) return expand;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
var r = EditorGUILayout.GetControlRect(false, 20);
|
||||
var rBg = new Rect(r.x - 3, r.y, r.width + 6, r.height);
|
||||
EditorGUI.LabelField(rBg, GUIContent.none, "RL Header");
|
||||
|
||||
var rLabel = new Rect(r.x + 5, r.y, 200, r.height);
|
||||
expand = EditorGUI.Foldout(rLabel, expand, "Registered Shader Variants");
|
||||
|
||||
var rButton = new Rect(r.x + r.width - 82, r.y + 1, 80, r.height - 4);
|
||||
if (GUI.Button(rButton, "Clear All", EditorStyles.miniButton))
|
||||
{
|
||||
collection.Clear();
|
||||
}
|
||||
|
||||
if (expand)
|
||||
{
|
||||
EditorGUILayout.BeginVertical("RL Background");
|
||||
Editor.CreateCachedEditor(collection, null, ref editor);
|
||||
editor.serializedObject.Update();
|
||||
var shaders = editor.serializedObject.FindProperty("m_Shaders");
|
||||
for (var i = 0; i < shaders.arraySize; i++)
|
||||
{
|
||||
s_MiDrawShaderEntry.Invoke(editor, new object[] { i });
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
editor.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
return expand;
|
||||
}
|
||||
|
||||
private static void ShowShaderDropdown(SerializedProperty property, string option, bool required)
|
||||
{
|
||||
var menu = new GenericMenu();
|
||||
var current = property.stringValue;
|
||||
var allShaderNames = ShaderUtil.GetAllShaderInfo()
|
||||
.Where(s => !required || s.name.Contains(option))
|
||||
.Select(s => s.name);
|
||||
|
||||
foreach (var shaderName in allShaderNames)
|
||||
{
|
||||
menu.AddItem(new GUIContent(shaderName), shaderName == current, () =>
|
||||
{
|
||||
property.stringValue = shaderName;
|
||||
property.serializedObject.ApplyModifiedProperties();
|
||||
});
|
||||
}
|
||||
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5bfa8bba9d0847069c9091cfa8dfb84
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,82 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIEffectInternal
|
||||
{
|
||||
public enum TransformSensitivity
|
||||
{
|
||||
Low,
|
||||
Medium,
|
||||
High
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for Transform class.
|
||||
/// </summary>
|
||||
internal static class TransformExtensionsForTransformSensitivity
|
||||
{
|
||||
private const float k_DefaultEpsilon = 1f / (2 ^ 8);
|
||||
|
||||
/// <summary>
|
||||
/// Check if a transform has changed.
|
||||
/// </summary>
|
||||
public static bool HasChanged(this Transform self, ref Matrix4x4 prev, TransformSensitivity sensitivity)
|
||||
{
|
||||
return self.HasChanged_Internal(null, ref prev, Convert(sensitivity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a transform has changed.
|
||||
/// </summary>
|
||||
public static bool HasChanged(this Transform self, Transform baseTransform, ref Matrix4x4 prev,
|
||||
TransformSensitivity sensitivity)
|
||||
{
|
||||
return self.HasChanged_Internal(baseTransform, ref prev, Convert(sensitivity));
|
||||
}
|
||||
|
||||
private static float Convert(TransformSensitivity self)
|
||||
{
|
||||
switch (self)
|
||||
{
|
||||
case TransformSensitivity.Low: return 1f / (1 << 4);
|
||||
case TransformSensitivity.Medium: return 1f / (1 << 8);
|
||||
case TransformSensitivity.High: return 1f / (1 << 12);
|
||||
default: return 1f / (1 << (int)self);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool HasChanged_Internal(this Transform self, Transform baseTransform, ref Matrix4x4 prev,
|
||||
float epsilon)
|
||||
{
|
||||
if (!self) return false;
|
||||
|
||||
var hash = baseTransform ? baseTransform.GetHashCode() : 0;
|
||||
if (FrameCache.TryGet(self, nameof(HasChanged), hash, out bool result)) return result;
|
||||
|
||||
var matrix = baseTransform
|
||||
? baseTransform.worldToLocalMatrix * self.localToWorldMatrix
|
||||
: self.localToWorldMatrix;
|
||||
var current = matrix * Matrix4x4.Scale(Vector3.one * 10000);
|
||||
result = !Approximately(current, prev, epsilon);
|
||||
FrameCache.Set(self, nameof(HasChanged), hash, result);
|
||||
if (result)
|
||||
{
|
||||
prev = current;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static bool Approximately(Matrix4x4 self, Matrix4x4 other, float epsilon = k_DefaultEpsilon)
|
||||
{
|
||||
for (var i = 0; i < 16; i++)
|
||||
{
|
||||
if (epsilon < Mathf.Abs(self[i] - other[i]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fd2b201d1fc94556b5bc7617788cd0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -53,7 +53,7 @@ namespace Coffee.UIEffectInternal
|
||||
/// <summary>
|
||||
/// Event that occurs when the screen size changes.
|
||||
/// </summary>
|
||||
public static event Action onScreenSizeChangedAction
|
||||
public static event Action onScreenSizeChanged
|
||||
{
|
||||
add => s_OnScreenSizeChangedAction.Add(value);
|
||||
remove => s_OnScreenSizeChangedAction.Remove(value);
|
||||
|
||||
@@ -26,10 +26,12 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
protected float m_ColorIntensity = 1;
|
||||
|
||||
[ColorUsage(false, true)]
|
||||
[SerializeField]
|
||||
protected Color m_Color = Color.white;
|
||||
|
||||
[SerializeField]
|
||||
protected bool m_ColorGlow = false;
|
||||
|
||||
[SerializeField]
|
||||
protected SamplingFilter m_SamplingFilter = SamplingFilter.None;
|
||||
|
||||
@@ -37,6 +39,10 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
protected float m_SamplingIntensity = 0.5f;
|
||||
|
||||
[PowerRange(0.01f, 100f, 10f)]
|
||||
[SerializeField]
|
||||
protected float m_SamplingScale = 1f;
|
||||
|
||||
[SerializeField]
|
||||
protected TransitionFilter m_TransitionFilter = TransitionFilter.None;
|
||||
|
||||
@@ -74,14 +80,15 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
protected ColorFilter m_TransitionColorFilter = ColorFilter.MultiplyAdditive;
|
||||
|
||||
[ColorUsage(true, true)]
|
||||
[SerializeField]
|
||||
protected Color m_TransitionColor = new Color(0f, 0.5f, 1.0f, 1.0f);
|
||||
|
||||
[SerializeField]
|
||||
protected bool m_TransitionColorGlow = false;
|
||||
|
||||
[SerializeField]
|
||||
protected TargetMode m_TargetMode = TargetMode.None;
|
||||
|
||||
[ColorUsage(false, false)]
|
||||
[SerializeField]
|
||||
protected Color m_TargetColor = Color.white;
|
||||
|
||||
@@ -116,13 +123,53 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
protected float m_ShadowFade = 0.9f;
|
||||
|
||||
[SerializeField]
|
||||
protected bool m_ShadowEffectOnOrigin = false;
|
||||
|
||||
[Range(0, 2)]
|
||||
[SerializeField]
|
||||
protected float m_ShadowMirrorScale = 0.5f;
|
||||
|
||||
[Range(0, 1)]
|
||||
[SerializeField]
|
||||
protected float m_ShadowBlurIntensity = 1;
|
||||
|
||||
[SerializeField]
|
||||
protected ColorFilter m_ShadowColorFilter = ColorFilter.Replace;
|
||||
|
||||
[SerializeField]
|
||||
protected Color m_ShadowColor = Color.white;
|
||||
|
||||
[SerializeField]
|
||||
protected bool m_ShadowColorGlow = false;
|
||||
|
||||
[SerializeField]
|
||||
protected GradationMode m_GradationMode = GradationMode.None;
|
||||
|
||||
[SerializeField]
|
||||
protected Color m_GradationColor1 = Color.white;
|
||||
|
||||
[SerializeField]
|
||||
protected Color m_GradationColor2 = Color.white;
|
||||
|
||||
[SerializeField]
|
||||
private Gradient m_GradationGradient = new Gradient();
|
||||
|
||||
[Range(-1, 1)]
|
||||
[SerializeField]
|
||||
protected float m_GradationOffset = 0;
|
||||
|
||||
[PowerRange(0.01f, 10, 10)]
|
||||
[SerializeField]
|
||||
protected float m_GradationScale = 1;
|
||||
|
||||
[SerializeField]
|
||||
[Range(0, 360)]
|
||||
private float m_GradationRotation = 0;
|
||||
|
||||
[SerializeField]
|
||||
protected bool m_AllowToModifyMeshShape = true;
|
||||
|
||||
/// <summary>
|
||||
/// Tone filter for rendering.
|
||||
/// </summary>
|
||||
public ToneFilter toneFilter
|
||||
{
|
||||
get => m_ToneFilter;
|
||||
@@ -134,6 +181,9 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 0.0 (no effect) - 1.0 (full effect).
|
||||
/// </summary>
|
||||
public float toneIntensity
|
||||
{
|
||||
get => m_ToneIntensity;
|
||||
@@ -146,6 +196,9 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color filter for rendering.
|
||||
/// </summary>
|
||||
public ColorFilter colorFilter
|
||||
{
|
||||
get => m_ColorFilter;
|
||||
@@ -157,6 +210,9 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 0.0 (no effect) - 1.0 (full effect).
|
||||
/// </summary>
|
||||
public float colorIntensity
|
||||
{
|
||||
get => m_ColorIntensity;
|
||||
@@ -181,6 +237,20 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public bool colorGlow
|
||||
{
|
||||
get => m_ColorGlow;
|
||||
set
|
||||
{
|
||||
if (m_ColorGlow == value) return;
|
||||
context.colorGlow = m_ColorGlow = value;
|
||||
ApplyContextToMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sampling filter for rendering.
|
||||
/// </summary>
|
||||
public SamplingFilter samplingFilter
|
||||
{
|
||||
get => m_SamplingFilter;
|
||||
@@ -193,6 +263,9 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 0.0 (no effect) - 1.0 (full effect).
|
||||
/// </summary>
|
||||
public float samplingIntensity
|
||||
{
|
||||
get => m_SamplingIntensity;
|
||||
@@ -205,6 +278,27 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public float samplingScale
|
||||
{
|
||||
get => m_SamplingScale;
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0.01f, 100);
|
||||
if (Mathf.Approximately(m_SamplingScale, value)) return;
|
||||
m_SamplingScale = value;
|
||||
ApplyContextToMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
public override float actualSamplingScale => samplingFilter != SamplingFilter.None
|
||||
? Mathf.Clamp(m_SamplingScale, 0.01f, 100)
|
||||
: 1;
|
||||
|
||||
public override bool canModifyShape => m_AllowToModifyMeshShape;
|
||||
|
||||
/// <summary>
|
||||
/// Transition filter for rendering.
|
||||
/// </summary>
|
||||
public TransitionFilter transitionFilter
|
||||
{
|
||||
get => m_TransitionFilter;
|
||||
@@ -217,6 +311,9 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 0.0 (no effect) - 1.0 (full effect).
|
||||
/// </summary>
|
||||
public float transitionRate
|
||||
{
|
||||
get => m_TransitionRate;
|
||||
@@ -341,6 +438,17 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public bool transitionColorGlow
|
||||
{
|
||||
get => m_TransitionColorGlow;
|
||||
set
|
||||
{
|
||||
if (m_TransitionColorGlow == value) return;
|
||||
context.transitionColorGlow = m_TransitionColorGlow = value;
|
||||
ApplyContextToMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
public TargetMode targetMode
|
||||
{
|
||||
get => m_TargetMode;
|
||||
@@ -478,17 +586,6 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public bool shadowEffectOnOrigin
|
||||
{
|
||||
get => m_ShadowEffectOnOrigin;
|
||||
set
|
||||
{
|
||||
if (m_ShadowEffectOnOrigin == value) return;
|
||||
m_ShadowEffectOnOrigin = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public float shadowMirrorScale
|
||||
{
|
||||
get => m_ShadowMirrorScale;
|
||||
@@ -496,12 +593,135 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
value = Mathf.Clamp(value, 0f, 2f);
|
||||
if (Mathf.Approximately(m_ShadowMirrorScale, value)) return;
|
||||
m_ShadowMirrorScale = value;
|
||||
context.shadowMirrorScale = m_ShadowMirrorScale = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public List<UIEffectReplica> replicas => _replicas ??= ListPool<UIEffectReplica>.Rent();
|
||||
public float shadowBlurIntensity
|
||||
{
|
||||
get => m_ShadowBlurIntensity;
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 1);
|
||||
if (Mathf.Approximately(m_ShadowBlurIntensity, value)) return;
|
||||
context.shadowBlurIntensity = m_ShadowBlurIntensity = value;
|
||||
ApplyContextToMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
public ColorFilter shadowColorFilter
|
||||
{
|
||||
get => m_ShadowColorFilter;
|
||||
set
|
||||
{
|
||||
if (m_ShadowColorFilter == value) return;
|
||||
context.shadowColorFilter = m_ShadowColorFilter = value;
|
||||
ApplyContextToMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
public Color shadowColor
|
||||
{
|
||||
get => m_ShadowColor;
|
||||
set
|
||||
{
|
||||
if (m_ShadowColor == value) return;
|
||||
context.shadowColor = m_ShadowColor = value;
|
||||
ApplyContextToMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
public bool shadowGlow
|
||||
{
|
||||
get => m_ShadowColorGlow;
|
||||
set
|
||||
{
|
||||
if (m_ShadowColorGlow == value) return;
|
||||
context.shadowColorGlow = m_ShadowColorGlow = value;
|
||||
ApplyContextToMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
public GradationMode gradationMode
|
||||
{
|
||||
get => m_GradationMode;
|
||||
set
|
||||
{
|
||||
if (m_GradationMode == value) return;
|
||||
context.gradationMode = m_GradationMode = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public Color gradationColor1
|
||||
{
|
||||
get => m_GradationColor1;
|
||||
set
|
||||
{
|
||||
if (m_GradationColor1 == value) return;
|
||||
context.gradationColor1 = m_GradationColor1 = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public Color gradationColor2
|
||||
{
|
||||
get => m_GradationColor2;
|
||||
set
|
||||
{
|
||||
if (m_GradationColor2 == value) return;
|
||||
context.gradationColor2 = m_GradationColor2 = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public float gradationOffset
|
||||
{
|
||||
get => m_GradationOffset;
|
||||
set
|
||||
{
|
||||
if (Mathf.Approximately(m_GradationOffset, value)) return;
|
||||
context.gradationOffset = m_GradationOffset = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public float gradationScale
|
||||
{
|
||||
get => m_GradationScale;
|
||||
set
|
||||
{
|
||||
if (Mathf.Approximately(m_GradationScale, value)) return;
|
||||
context.gradationScale = m_GradationScale = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public float gradationRotation
|
||||
{
|
||||
get => m_GradationRotation;
|
||||
set
|
||||
{
|
||||
value = Mathf.Repeat(value, 360);
|
||||
if (Mathf.Approximately(m_GradationRotation, value)) return;
|
||||
context.gradationRotation = m_GradationRotation = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public bool allowToModifyMeshShape
|
||||
{
|
||||
get => m_AllowToModifyMeshShape;
|
||||
set
|
||||
{
|
||||
if (m_AllowToModifyMeshShape == value) return;
|
||||
m_AllowToModifyMeshShape = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public List<UIEffectReplica> replicas => _replicas ??= InternalListPool<UIEffectReplica>.Rent();
|
||||
private List<UIEffectReplica> _replicas;
|
||||
|
||||
protected override void OnEnable()
|
||||
@@ -519,13 +739,14 @@ namespace Coffee.UIEffects
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
ListPool<UIEffectReplica>.Return(ref _replicas);
|
||||
InternalListPool<UIEffectReplica>.Return(ref _replicas);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate()
|
||||
{
|
||||
(m_SrcBlendMode, m_DstBlendMode) = (m_BlendType, m_SrcBlendMode, m_DstBlendMode).Convert();
|
||||
context?.SetGradationDirty();
|
||||
base.OnValidate();
|
||||
}
|
||||
#endif
|
||||
@@ -550,16 +771,30 @@ namespace Coffee.UIEffects
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set gradation gradient's keys.
|
||||
/// </summary>
|
||||
public void SetGradientKeys(GradientColorKey[] colorKeys, GradientAlphaKey[] alphaKeys)
|
||||
{
|
||||
m_GradationGradient ??= new Gradient();
|
||||
m_GradationGradient.SetKeys(colorKeys, alphaKeys);
|
||||
context?.SetGradationDirty();
|
||||
}
|
||||
|
||||
protected override void UpdateContext(UIEffectContext c)
|
||||
{
|
||||
c.toneFilter = m_ToneFilter;
|
||||
c.toneIntensity = m_ToneIntensity;
|
||||
c.toneParams = m_ToneParams;
|
||||
|
||||
c.colorFilter = m_ColorFilter;
|
||||
c.color = m_Color;
|
||||
c.colorIntensity = m_ColorIntensity;
|
||||
c.colorGlow = m_ColorGlow;
|
||||
|
||||
c.samplingFilter = m_SamplingFilter;
|
||||
c.samplingIntensity = m_SamplingIntensity;
|
||||
|
||||
c.transitionFilter = m_TransitionFilter;
|
||||
c.transitionRate = m_TransitionRate;
|
||||
c.transitionReverse = m_TransitionReverse;
|
||||
@@ -570,20 +805,35 @@ namespace Coffee.UIEffects
|
||||
c.transitionKeepAspectRatio = m_TransitionKeepAspectRatio;
|
||||
c.transitionWidth = m_TransitionWidth;
|
||||
c.transitionSoftness = m_TransitionSoftness;
|
||||
c.transitionColor = m_TransitionColor;
|
||||
c.transitionColorFilter = m_TransitionColorFilter;
|
||||
c.transitionColor = m_TransitionColor;
|
||||
c.transitionColorGlow = m_TransitionColorGlow;
|
||||
|
||||
c.targetMode = m_TargetMode;
|
||||
c.targetColor = m_TargetColor;
|
||||
c.targetRange = m_TargetRange;
|
||||
c.targetSoftness = m_TargetSoftness;
|
||||
|
||||
c.srcBlendMode = m_SrcBlendMode;
|
||||
c.dstBlendMode = m_DstBlendMode;
|
||||
|
||||
c.shadowMode = m_ShadowMode;
|
||||
c.shadowDistance = m_ShadowDistance;
|
||||
c.shadowIteration = m_ShadowIteration;
|
||||
c.shadowFade = m_ShadowFade;
|
||||
c.shadowEffectOnOrigin = m_ShadowEffectOnOrigin;
|
||||
c.shadowMirrorScale = m_ShadowMirrorScale;
|
||||
c.shadowBlurIntensity = m_ShadowBlurIntensity;
|
||||
c.shadowColorFilter = m_ShadowColorFilter;
|
||||
c.shadowColor = m_ShadowColor;
|
||||
c.shadowColorGlow = m_ShadowColorGlow;
|
||||
|
||||
c.gradationMode = m_GradationMode;
|
||||
c.gradationColor1 = m_GradationColor1;
|
||||
c.gradationColor2 = m_GradationColor2;
|
||||
c.gradationGradient = m_GradationGradient;
|
||||
c.gradationOffset = m_GradationOffset;
|
||||
c.gradationScale = m_GradationScale;
|
||||
c.gradationRotation = m_GradationRotation;
|
||||
}
|
||||
|
||||
public override void ApplyContextToMaterial()
|
||||
@@ -617,6 +867,17 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
transitionRate = rate;
|
||||
}
|
||||
|
||||
if (gradationMode != GradationMode.None && 0 < (mask & UIEffectTweener.CullingMask.GradiationOffset))
|
||||
{
|
||||
gradationOffset = Mathf.Lerp(-1f, 1f, rate);
|
||||
}
|
||||
|
||||
if ((gradationMode == GradationMode.Angle || gradationMode == GradationMode.AngleGradient)
|
||||
&& 0 < (mask & UIEffectTweener.CullingMask.GradiationRotation))
|
||||
{
|
||||
gradationRotation = Mathf.Lerp(0f, 360f, rate);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
|
||||
@@ -632,11 +893,17 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load preset settings.
|
||||
/// </summary>
|
||||
public void LoadPreset(string presetName)
|
||||
{
|
||||
LoadPreset(UIEffectProjectSettings.LoadRuntimePreset(presetName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load preset settings.
|
||||
/// </summary>
|
||||
public void LoadPreset(UIEffect preset)
|
||||
{
|
||||
if (!preset) return;
|
||||
@@ -648,6 +915,7 @@ namespace Coffee.UIEffects
|
||||
m_ColorFilter = preset.m_ColorFilter;
|
||||
m_Color = preset.m_Color;
|
||||
m_ColorIntensity = preset.m_ColorIntensity;
|
||||
m_ColorGlow = preset.m_ColorGlow;
|
||||
|
||||
m_SamplingFilter = preset.m_SamplingFilter;
|
||||
m_SamplingIntensity = preset.m_SamplingIntensity;
|
||||
@@ -662,8 +930,9 @@ namespace Coffee.UIEffects
|
||||
m_TransitionKeepAspectRatio = preset.m_TransitionKeepAspectRatio;
|
||||
m_TransitionWidth = preset.m_TransitionWidth;
|
||||
m_TransitionSoftness = preset.m_TransitionSoftness;
|
||||
m_TransitionColor = preset.m_TransitionColor;
|
||||
m_TransitionColorFilter = preset.m_TransitionColorFilter;
|
||||
m_TransitionColor = preset.m_TransitionColor;
|
||||
m_TransitionColorGlow = preset.m_TransitionColorGlow;
|
||||
|
||||
m_TargetMode = preset.m_TargetMode;
|
||||
m_TargetColor = preset.m_TargetColor;
|
||||
@@ -677,8 +946,20 @@ namespace Coffee.UIEffects
|
||||
m_ShadowDistance = preset.m_ShadowDistance;
|
||||
m_ShadowIteration = preset.m_ShadowIteration;
|
||||
m_ShadowFade = preset.m_ShadowFade;
|
||||
m_ShadowEffectOnOrigin = preset.m_ShadowEffectOnOrigin;
|
||||
m_ShadowMirrorScale = preset.m_ShadowMirrorScale;
|
||||
m_ShadowBlurIntensity = preset.m_ShadowBlurIntensity;
|
||||
m_ShadowColorFilter = preset.m_ShadowColorFilter;
|
||||
m_ShadowColor = preset.m_ShadowColor;
|
||||
m_ShadowColorGlow = preset.m_ShadowColorGlow;
|
||||
|
||||
m_GradationMode = preset.m_GradationMode;
|
||||
m_GradationColor1 = preset.m_GradationColor1;
|
||||
m_GradationColor2 = preset.m_GradationColor2;
|
||||
m_GradationGradient = new Gradient();
|
||||
m_GradationGradient.SetKeys(preset.m_GradationGradient.colorKeys, preset.m_GradationGradient.alphaKeys);
|
||||
m_GradationOffset = preset.m_GradationOffset;
|
||||
m_GradationScale = preset.m_GradationScale;
|
||||
m_GradationRotation = preset.m_GradationRotation;
|
||||
|
||||
UpdateContext(context);
|
||||
ApplyContextToMaterial();
|
||||
@@ -695,6 +976,7 @@ namespace Coffee.UIEffects
|
||||
m_ColorFilter = c.colorFilter;
|
||||
m_Color = c.color;
|
||||
m_ColorIntensity = c.colorIntensity;
|
||||
m_ColorGlow = c.colorGlow;
|
||||
|
||||
m_SamplingFilter = c.samplingFilter;
|
||||
m_SamplingIntensity = c.samplingIntensity;
|
||||
@@ -709,8 +991,9 @@ namespace Coffee.UIEffects
|
||||
m_TransitionKeepAspectRatio = c.transitionKeepAspectRatio;
|
||||
m_TransitionWidth = c.transitionWidth;
|
||||
m_TransitionSoftness = c.transitionSoftness;
|
||||
m_TransitionColor = c.transitionColor;
|
||||
m_TransitionColorFilter = c.transitionColorFilter;
|
||||
m_TransitionColor = c.transitionColor;
|
||||
m_TransitionColorGlow = c.transitionColorGlow;
|
||||
|
||||
m_TargetMode = c.targetMode;
|
||||
m_TargetColor = c.targetColor;
|
||||
@@ -725,8 +1008,20 @@ namespace Coffee.UIEffects
|
||||
m_ShadowDistance = c.shadowDistance;
|
||||
m_ShadowIteration = c.shadowIteration;
|
||||
m_ShadowFade = c.shadowFade;
|
||||
m_ShadowEffectOnOrigin = c.shadowEffectOnOrigin;
|
||||
m_ShadowMirrorScale = c.shadowMirrorScale;
|
||||
m_ShadowBlurIntensity = c.shadowBlurIntensity;
|
||||
m_ShadowColorFilter = c.shadowColorFilter;
|
||||
m_ShadowColor = c.shadowColor;
|
||||
m_ShadowColorGlow = c.shadowColorGlow;
|
||||
|
||||
m_GradationMode = c.gradationMode;
|
||||
m_GradationColor1 = c.gradationColor1;
|
||||
m_GradationColor2 = c.gradationColor2;
|
||||
m_GradationGradient = new Gradient();
|
||||
m_GradationGradient.SetKeys(c.gradationGradient.colorKeys, c.gradationGradient.alphaKeys);
|
||||
m_GradationOffset = c.gradationOffset;
|
||||
m_GradationScale = c.gradationScale;
|
||||
m_GradationRotation = c.gradationRotation;
|
||||
|
||||
UpdateContext(context);
|
||||
ApplyContextToMaterial();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Coffee.UIEffectInternal;
|
||||
using UnityEngine;
|
||||
@@ -22,10 +21,9 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
private static readonly VertexHelper s_VertexHelper = new VertexHelper();
|
||||
private static Mesh s_Mesh;
|
||||
private static readonly Dictionary<int, string> s_ShaderNameCache = new Dictionary<int, string>();
|
||||
|
||||
private static readonly ObjectPool<UIEffectContext> s_ContextPool =
|
||||
new ObjectPool<UIEffectContext>(() => new UIEffectContext(), x => true, x => x.Reset());
|
||||
private static readonly InternalObjectPool<UIEffectContext> s_ContextPool =
|
||||
new InternalObjectPool<UIEffectContext>(() => new UIEffectContext(), x => true, x => x.Reset());
|
||||
|
||||
private Graphic _graphic;
|
||||
private Material _material;
|
||||
@@ -33,6 +31,8 @@ namespace Coffee.UIEffects
|
||||
|
||||
public Graphic graphic => _graphic ? _graphic : _graphic = GetComponent<Graphic>();
|
||||
public virtual uint effectId => (uint)GetInstanceID();
|
||||
public virtual float actualSamplingScale => 1;
|
||||
public virtual bool canModifyShape => true;
|
||||
|
||||
public virtual UIEffectContext context
|
||||
{
|
||||
@@ -52,7 +52,15 @@ namespace Coffee.UIEffects
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
UIExtraCallbacks.onScreenSizeChangedAction += SetVerticesDirtyIfTextMeshPro;
|
||||
#if TMP_ENABLE
|
||||
if (graphic is TextMeshProUGUI)
|
||||
{
|
||||
_prevLossyScaleY = transform.lossyScale.y;
|
||||
UIExtraCallbacks.onAfterCanvasRebuild += CheckSDFScaleForTMP;
|
||||
UIExtraCallbacks.onScreenSizeChanged += SetVerticesDirtyForTMP;
|
||||
}
|
||||
#endif
|
||||
|
||||
UpdateContext(context);
|
||||
SetMaterialDirty();
|
||||
SetVerticesDirty();
|
||||
@@ -60,7 +68,11 @@ namespace Coffee.UIEffects
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
UIExtraCallbacks.onScreenSizeChangedAction -= SetVerticesDirtyIfTextMeshPro;
|
||||
#if TMP_ENABLE
|
||||
UIExtraCallbacks.onScreenSizeChanged -= SetVerticesDirtyForTMP;
|
||||
UIExtraCallbacks.onAfterCanvasRebuild -= CheckSDFScaleForTMP;
|
||||
#endif
|
||||
|
||||
MaterialRepository.Release(ref _material);
|
||||
SetMaterialDirty();
|
||||
SetVerticesDirty();
|
||||
@@ -79,7 +91,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (!isActiveAndEnabled || context == null) return;
|
||||
|
||||
context.ModifyMesh(graphic, transitionRoot, vh);
|
||||
context.ModifyMesh(graphic, transitionRoot, vh, canModifyShape);
|
||||
}
|
||||
|
||||
public virtual Material GetModifiedMaterial(Material baseMaterial)
|
||||
@@ -91,13 +103,17 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
|
||||
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial");
|
||||
var hash = new Hash128((uint)baseMaterial.GetInstanceID(), effectId, 0, 0);
|
||||
var samplingScaleId = (uint)(Mathf.InverseLerp(0.01f, 100, actualSamplingScale) * uint.MaxValue);
|
||||
var hash = new Hash128((uint)baseMaterial.GetInstanceID(), effectId, samplingScaleId, 0);
|
||||
if (!MaterialRepository.Valid(hash, _material))
|
||||
{
|
||||
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial > Get or create material");
|
||||
MaterialRepository.Get(hash, ref _material, x => new Material(x)
|
||||
{
|
||||
shader = FindShader(x),
|
||||
shader = UIEffectProjectSettings.shaderRegistry.FindOptionalShader(x.shader,
|
||||
"(UIEffect)",
|
||||
"Hidden/{0} (UIEffect)",
|
||||
"Hidden/UI/Default (UIEffect)"),
|
||||
hideFlags = HideFlags.HideAndDontSave
|
||||
}, baseMaterial);
|
||||
Profiler.EndSample();
|
||||
@@ -108,33 +124,6 @@ namespace Coffee.UIEffects
|
||||
return _material;
|
||||
}
|
||||
|
||||
|
||||
private static Shader FindShader(Material material)
|
||||
{
|
||||
var shader = material.shader;
|
||||
var hash = shader.GetInstanceID();
|
||||
if (!s_ShaderNameCache.TryGetValue(hash, out var shaderName))
|
||||
{
|
||||
shaderName = shader.name;
|
||||
if (!shaderName.Contains("(UIEffect)"))
|
||||
{
|
||||
shaderName = $"Hidden/{shaderName} (UIEffect)";
|
||||
}
|
||||
|
||||
var uiEffectShader = Shader.Find(shaderName);
|
||||
if (!uiEffectShader)
|
||||
{
|
||||
shaderName = "Hidden/UI/Default (UIEffect)";
|
||||
uiEffectShader = Shader.Find(shaderName);
|
||||
}
|
||||
|
||||
s_ShaderNameCache[hash] = shaderName;
|
||||
return uiEffectShader;
|
||||
}
|
||||
|
||||
return Shader.Find(shaderName);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate()
|
||||
{
|
||||
@@ -200,18 +189,6 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetVerticesDirtyIfTextMeshPro()
|
||||
{
|
||||
#if TMP_ENABLE
|
||||
if (graphic && graphic.isActiveAndEnabled
|
||||
&& (graphic is TextMeshProUGUI || graphic is TMP_SubMeshUI))
|
||||
{
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public virtual void SetMaterialDirty()
|
||||
{
|
||||
if (graphic)
|
||||
@@ -226,10 +203,10 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (!isActiveAndEnabled || context == null) return;
|
||||
|
||||
context.ApplyToMaterial(_material);
|
||||
context.ApplyToMaterial(_material, actualSamplingScale);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UIEffectProjectSettings.RegisterVariant(_material);
|
||||
UIEffectProjectSettings.shaderRegistry.RegisterVariant(_material, "UI > UIEffect");
|
||||
if (!EditorApplication.isPlaying)
|
||||
{
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
@@ -238,27 +215,6 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
|
||||
#if TMP_ENABLE
|
||||
#if UNITY_EDITOR
|
||||
private class MyAllPostprocessor : AssetPostprocessor
|
||||
{
|
||||
private static void OnPostprocessAllAssets(string[] _, string[] __, string[] ___, string[] ____)
|
||||
{
|
||||
if (Application.isBatchMode || BuildPipeline.isBuildingPlayer) return;
|
||||
|
||||
s_ShaderNameCache.Clear();
|
||||
foreach (var effect in Misc.FindObjectsOfType<UIEffectBase>()
|
||||
.Concat(Misc.GetAllComponentsInPrefabStage<UIEffectBase>()))
|
||||
{
|
||||
if (!effect.isActiveAndEnabled) continue;
|
||||
if (!(effect.graphic is TextMeshProUGUI tmp) || !tmp.isActiveAndEnabled) continue;
|
||||
effect.SetMaterialDirty();
|
||||
}
|
||||
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[InitializeOnLoadMethod]
|
||||
#else
|
||||
@@ -291,8 +247,8 @@ namespace Coffee.UIEffects
|
||||
: effect is UIEffectReplica parentReplica
|
||||
? parentReplica.target
|
||||
: null;
|
||||
var subMeshes = ListPool<TMP_SubMeshUI>.Rent();
|
||||
var modifiers = ListPool<IMeshModifier>.Rent();
|
||||
var subMeshes = InternalListPool<TMP_SubMeshUI>.Rent();
|
||||
var modifiers = InternalListPool<IMeshModifier>.Rent();
|
||||
textMeshProUGUI.GetComponentsInChildren(subMeshes, 1);
|
||||
for (var i = 0; i < textMeshProUGUI.textInfo.meshInfo.Length; i++)
|
||||
{
|
||||
@@ -334,8 +290,8 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
ListPool<IMeshModifier>.Return(ref modifiers);
|
||||
ListPool<TMP_SubMeshUI>.Return(ref subMeshes);
|
||||
InternalListPool<IMeshModifier>.Return(ref modifiers);
|
||||
InternalListPool<TMP_SubMeshUI>.Return(ref subMeshes);
|
||||
s_Mesh.Clear(false);
|
||||
}
|
||||
|
||||
@@ -348,6 +304,28 @@ namespace Coffee.UIEffects
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void SetVerticesDirtyForTMP()
|
||||
{
|
||||
if (graphic && graphic.isActiveAndEnabled)
|
||||
{
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckSDFScaleForTMP()
|
||||
{
|
||||
var lossyScaleY = transform.lossyScale.y;
|
||||
if (Mathf.Approximately(_prevLossyScaleY, lossyScaleY)) return;
|
||||
|
||||
_prevLossyScaleY = lossyScaleY;
|
||||
if (graphic is TextMeshProUGUI textMeshProUGUI && graphic.isActiveAndEnabled)
|
||||
{
|
||||
OnTMPChanged(textMeshProUGUI);
|
||||
}
|
||||
}
|
||||
|
||||
private float _prevLossyScaleY;
|
||||
#endif
|
||||
|
||||
public abstract void SetRate(float rate, UIEffectTweener.CullingMask cullingMask);
|
||||
|
||||
@@ -5,35 +5,37 @@ using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.UI;
|
||||
#if TMP_ENABLE
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
public class UIEffectContext
|
||||
{
|
||||
private const float k_MaxEffectDistance = 600f;
|
||||
private static readonly UIEffectContext s_DefaultContext = new UIEffectContext();
|
||||
private static readonly List<UIVertex> s_WorkingVertices = new List<UIVertex>();
|
||||
private static readonly List<UIVertex> s_WorkingVertices = new List<UIVertex>(1024 * 8);
|
||||
private static readonly int s_SrcBlend = Shader.PropertyToID("_SrcBlend");
|
||||
private static readonly int s_DstBlend = Shader.PropertyToID("_DstBlend");
|
||||
private static readonly int s_ToneIntensity = Shader.PropertyToID("_ToneIntensity");
|
||||
private static readonly int s_ToneParams = Shader.PropertyToID("_ToneParams");
|
||||
private static readonly int s_ColorValue = Shader.PropertyToID("_ColorValue");
|
||||
private static readonly int s_ColorIntensity = Shader.PropertyToID("_ColorIntensity");
|
||||
private static readonly int s_ColorGlow = Shader.PropertyToID("_ColorGlow");
|
||||
private static readonly int s_SamplingIntensity = Shader.PropertyToID("_SamplingIntensity");
|
||||
private static readonly int s_SamplingScale = Shader.PropertyToID("_SamplingScale");
|
||||
private static readonly int s_TransitionRate = Shader.PropertyToID("_TransitionRate");
|
||||
private static readonly int s_TransitionReverse = Shader.PropertyToID("_TransitionReverse");
|
||||
private static readonly int s_TransitionTex = Shader.PropertyToID("_TransitionTex");
|
||||
private static readonly int s_TransitionTex_ST = Shader.PropertyToID("_TransitionTex_ST");
|
||||
private static readonly int s_TransitionWidth = Shader.PropertyToID("_TransitionWidth");
|
||||
private static readonly int s_TransitionSoftness = Shader.PropertyToID("_TransitionSoftness");
|
||||
private static readonly int s_TransitionColor = Shader.PropertyToID("_TransitionColor");
|
||||
private static readonly int s_TransitionColorFilter = Shader.PropertyToID("_TransitionColorFilter");
|
||||
private static readonly int s_TransitionColor = Shader.PropertyToID("_TransitionColor");
|
||||
private static readonly int s_TransitionColorGlow = Shader.PropertyToID("_TransitionColorGlow");
|
||||
private static readonly int s_TargetColor = Shader.PropertyToID("_TargetColor");
|
||||
private static readonly int s_TargetRange = Shader.PropertyToID("_TargetRange");
|
||||
private static readonly int s_TargetSoftness = Shader.PropertyToID("_TargetSoftness");
|
||||
private static readonly int s_ShadowColor = Shader.PropertyToID("_ShadowColor");
|
||||
private static readonly int s_ShadowBlurIntensity = Shader.PropertyToID("_ShadowBlurIntensity");
|
||||
private static readonly int s_ShadowColorGlow = Shader.PropertyToID("_ShadowColorGlow");
|
||||
|
||||
private static readonly string[] s_ToneKeywords =
|
||||
{
|
||||
@@ -102,14 +104,45 @@ namespace Coffee.UIEffects
|
||||
"TARGET_LUMINANCE"
|
||||
};
|
||||
|
||||
private static readonly string[] s_ShadowColorKeywords =
|
||||
{
|
||||
"",
|
||||
"SHADOW_COLOR_MULTIPLY",
|
||||
"SHADOW_COLOR_ADDITIVE",
|
||||
"SHADOW_COLOR_SUBTRACTIVE",
|
||||
"SHADOW_COLOR_REPLACE",
|
||||
"SHADOW_COLOR_MULTIPLY_LUMINANCE",
|
||||
"SHADOW_COLOR_MULTIPLY_ADDITIVE",
|
||||
"SHADOW_COLOR_HSV_MODIFIER",
|
||||
"SHADOW_COLOR_CONTRAST"
|
||||
};
|
||||
|
||||
private static readonly Vector2[][] s_ShadowVectors = new[]
|
||||
{
|
||||
Array.Empty<Vector2>(), // None
|
||||
new[] { Vector2.one }, // Shadow
|
||||
new[] { Vector2.one, Vector2.right, Vector2.up }, // Shadow3
|
||||
new[] { Vector2.one, -Vector2.one, new Vector2(1, -1), new Vector2(-1, 1) }, // Outline
|
||||
new[]
|
||||
{
|
||||
Vector2.one, -Vector2.one, new Vector2(1, -1), new Vector2(-1, 1),
|
||||
Vector2.right, Vector2.up, Vector2.left, Vector2.down
|
||||
} // Outline8
|
||||
};
|
||||
|
||||
public static Func<UIVertex, Rect, float, float, UIVertex> onModifyVertex;
|
||||
public ToneFilter toneFilter = ToneFilter.None;
|
||||
public float toneIntensity = 1;
|
||||
public Vector4 toneParams = new Vector4(0, 0, 0, 0);
|
||||
|
||||
public ColorFilter colorFilter = ColorFilter.None;
|
||||
public float colorIntensity = 1;
|
||||
public Color color = Color.white;
|
||||
public bool colorGlow;
|
||||
|
||||
public SamplingFilter samplingFilter = SamplingFilter.None;
|
||||
public float samplingIntensity = 0.5f;
|
||||
|
||||
public TransitionFilter transitionFilter = TransitionFilter.None;
|
||||
public float transitionRate = 0.5f;
|
||||
public bool transitionReverse;
|
||||
@@ -122,29 +155,46 @@ namespace Coffee.UIEffects
|
||||
public float transitionSoftness = 0.2f;
|
||||
public ColorFilter transitionColorFilter = ColorFilter.MultiplyAdditive;
|
||||
public Color transitionColor = new Color(0f, 0.5f, 1.0f, 1.0f);
|
||||
public bool transitionColorGlow;
|
||||
|
||||
public TargetMode targetMode = TargetMode.None;
|
||||
public Color targetColor = Color.white;
|
||||
public float targetRange = 1;
|
||||
public float targetSoftness = 0.5f;
|
||||
|
||||
public BlendMode srcBlendMode = BlendMode.One;
|
||||
public BlendMode dstBlendMode = BlendMode.OneMinusSrcAlpha;
|
||||
|
||||
public ShadowMode shadowMode = ShadowMode.None;
|
||||
public Vector2 shadowDistance = new Vector2(1f, -1f);
|
||||
public int shadowIteration = 1;
|
||||
public float shadowFade = 0.9f;
|
||||
public bool shadowEffectOnOrigin = false;
|
||||
public float shadowMirrorScale = 0.5f;
|
||||
// public RectTransform transitionRoot;
|
||||
public float shadowBlurIntensity;
|
||||
public ColorFilter shadowColorFilter;
|
||||
public Color shadowColor;
|
||||
public bool shadowColorGlow;
|
||||
|
||||
public GradationMode gradationMode;
|
||||
public Color gradationColor1;
|
||||
public Color gradationColor2;
|
||||
public Gradient gradationGradient;
|
||||
public float gradationOffset;
|
||||
public float gradationScale;
|
||||
public float gradationRotation;
|
||||
private List<float> _keyTimes;
|
||||
|
||||
public bool willModifyMaterial => samplingFilter != SamplingFilter.None
|
||||
|| transitionFilter != TransitionFilter.None
|
||||
|| toneFilter != ToneFilter.None
|
||||
|| colorFilter != ColorFilter.None
|
||||
|| srcBlendMode != BlendMode.One
|
||||
|| dstBlendMode != BlendMode.OneMinusSrcAlpha;
|
||||
|| dstBlendMode != BlendMode.OneMinusSrcAlpha
|
||||
|| shadowMode != ShadowMode.None;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
InternalListPool<float>.Return(ref _keyTimes);
|
||||
CopyFrom(s_DefaultContext);
|
||||
}
|
||||
|
||||
@@ -157,6 +207,7 @@ namespace Coffee.UIEffects
|
||||
colorFilter = preset.colorFilter;
|
||||
color = preset.color;
|
||||
colorIntensity = preset.colorIntensity;
|
||||
colorGlow = preset.colorGlow;
|
||||
|
||||
samplingFilter = preset.samplingFilter;
|
||||
samplingIntensity = preset.samplingIntensity;
|
||||
@@ -173,6 +224,7 @@ namespace Coffee.UIEffects
|
||||
transitionSoftness = preset.transitionSoftness;
|
||||
transitionColor = preset.transitionColor;
|
||||
transitionColorFilter = preset.transitionColorFilter;
|
||||
transitionColorGlow = preset.transitionColorGlow;
|
||||
|
||||
targetMode = preset.targetMode;
|
||||
targetColor = preset.targetColor;
|
||||
@@ -186,10 +238,27 @@ namespace Coffee.UIEffects
|
||||
shadowDistance = preset.shadowDistance;
|
||||
shadowIteration = preset.shadowIteration;
|
||||
shadowFade = preset.shadowFade;
|
||||
shadowEffectOnOrigin = preset.shadowEffectOnOrigin;
|
||||
shadowMirrorScale = preset.shadowMirrorScale;
|
||||
shadowBlurIntensity = preset.shadowBlurIntensity;
|
||||
shadowColorFilter = preset.shadowColorFilter;
|
||||
shadowColor = preset.shadowColor;
|
||||
shadowColorGlow = preset.shadowColorGlow;
|
||||
|
||||
gradationMode = preset.gradationMode;
|
||||
gradationColor1 = preset.gradationColor1;
|
||||
gradationColor2 = preset.gradationColor2;
|
||||
gradationGradient = preset.gradationGradient;
|
||||
gradationOffset = preset.gradationOffset;
|
||||
gradationScale = preset.gradationScale;
|
||||
gradationRotation = preset.gradationRotation;
|
||||
}
|
||||
|
||||
public void ApplyToMaterial(Material material)
|
||||
public void SetGradationDirty()
|
||||
{
|
||||
InternalListPool<float>.Return(ref _keyTimes);
|
||||
}
|
||||
|
||||
public void ApplyToMaterial(Material material, float actualSamplingScale = 1f)
|
||||
{
|
||||
if (!material) return;
|
||||
|
||||
@@ -203,8 +272,10 @@ namespace Coffee.UIEffects
|
||||
|
||||
material.SetColor(s_ColorValue, color);
|
||||
material.SetFloat(s_ColorIntensity, Mathf.Clamp01(colorIntensity));
|
||||
material.SetInt(s_ColorGlow, colorGlow ? 1 : 0);
|
||||
|
||||
material.SetFloat(s_SamplingIntensity, Mathf.Clamp01(samplingIntensity));
|
||||
material.SetFloat(s_SamplingScale, actualSamplingScale);
|
||||
|
||||
material.SetFloat(s_TransitionRate, Mathf.Clamp01(transitionRate));
|
||||
material.SetInt(s_TransitionReverse, transitionReverse ? 1 : 0);
|
||||
@@ -214,13 +285,29 @@ namespace Coffee.UIEffects
|
||||
transitionTexOffset.x, transitionTexOffset.y));
|
||||
material.SetFloat(s_TransitionWidth, Mathf.Clamp01(transitionWidth));
|
||||
material.SetFloat(s_TransitionSoftness, Mathf.Clamp01(transitionSoftness));
|
||||
material.SetColor(s_TransitionColor, transitionColor);
|
||||
material.SetInt(s_TransitionColorFilter, (int)transitionColorFilter);
|
||||
material.SetColor(s_TransitionColor, transitionColor);
|
||||
material.SetInt(s_TransitionColorGlow, transitionColorGlow ? 1 : 0);
|
||||
|
||||
material.SetColor(s_TargetColor, targetColor);
|
||||
material.SetFloat(s_TargetRange, Mathf.Clamp01(targetRange));
|
||||
material.SetFloat(s_TargetSoftness, Mathf.Clamp01(targetSoftness));
|
||||
|
||||
switch (samplingFilter)
|
||||
{
|
||||
case SamplingFilter.BlurFast:
|
||||
case SamplingFilter.BlurMedium:
|
||||
case SamplingFilter.BlurDetail:
|
||||
material.SetFloat(s_ShadowBlurIntensity, Mathf.Clamp01(shadowBlurIntensity));
|
||||
break;
|
||||
default:
|
||||
material.SetFloat(s_ShadowBlurIntensity, Mathf.Clamp01(samplingIntensity));
|
||||
break;
|
||||
}
|
||||
|
||||
material.SetColor(s_ShadowColor, shadowColor);
|
||||
material.SetInt(s_ShadowColorGlow, shadowColorGlow ? 1 : 0);
|
||||
|
||||
SetKeyword(material, s_ToneKeywords, (int)toneFilter);
|
||||
SetKeyword(material, s_ColorKeywords, (int)colorFilter);
|
||||
SetKeyword(material, s_SamplingKeywords, (int)samplingFilter);
|
||||
@@ -241,6 +328,16 @@ namespace Coffee.UIEffects
|
||||
break;
|
||||
}
|
||||
|
||||
switch (shadowMode)
|
||||
{
|
||||
case ShadowMode.None:
|
||||
SetKeyword(material, s_ShadowColorKeywords, (int)ColorFilter.None);
|
||||
break;
|
||||
default:
|
||||
SetKeyword(material, s_ShadowColorKeywords, (int)shadowColorFilter);
|
||||
break;
|
||||
}
|
||||
|
||||
SetKeyword(material, s_TargetKeywords, (int)targetMode);
|
||||
|
||||
Profiler.EndSample();
|
||||
@@ -261,38 +358,20 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public void ModifyMesh(Graphic graphic, RectTransform transitionRoot, VertexHelper vh)
|
||||
public void ModifyMesh(Graphic graphic, RectTransform transitionRoot, VertexHelper vh, bool canModifyShape)
|
||||
{
|
||||
// var graphic = uiEffect.graphic;
|
||||
// var transitionRoot = uiEffect.transitionRoot;
|
||||
#if TMP_ENABLE
|
||||
var isTextMeshPro = graphic is TextMeshProUGUI || graphic is TMP_SubMeshUI;
|
||||
var isText = isTextMeshPro || graphic is Text;
|
||||
var processor = ContextProcessor.FindProcessor(graphic);
|
||||
var isText = processor.IsText(graphic);
|
||||
processor.OnPreModifyMesh(graphic);
|
||||
|
||||
// Sprite mode.
|
||||
if (graphic is TMP_SubMeshUI sub && sub.spriteAsset && sub.sharedMaterial == sub.spriteAsset.material)
|
||||
{
|
||||
isTextMeshPro = false;
|
||||
}
|
||||
#else
|
||||
var isTextMeshPro = false;
|
||||
var isText = graphic is Text;
|
||||
#endif
|
||||
|
||||
var expandSize = GetExpandSize();
|
||||
var useExpand = expandSize != Vector2.zero;
|
||||
|
||||
// Update capacity of workingVertices if needed.
|
||||
var verts = s_WorkingVertices;
|
||||
var expandSize = GetExpandSize(canModifyShape);
|
||||
var count = vh.currentIndexCount;
|
||||
var neededCapacity = Mathf.NextPowerOfTwo(count * GetVertexCountMultiply());
|
||||
if (s_WorkingVertices.Capacity < neededCapacity)
|
||||
{
|
||||
s_WorkingVertices.Capacity = neededCapacity;
|
||||
}
|
||||
|
||||
// Get the rectangle to calculate the normalized position.
|
||||
vh.GetUIVertexStream(s_WorkingVertices);
|
||||
vh.GetUIVertexStream(verts);
|
||||
var bundleSize = isText ? 6 : count;
|
||||
var rectMatrix = Matrix4x4.identity;
|
||||
var rot = Matrix4x4.Rotate(Quaternion.Euler(0, 0, transitionRotation));
|
||||
var v1 = rot.MultiplyPoint3x4(new Vector3(1, 1, 0));
|
||||
var multiplier = Mathf.Max(Mathf.Abs(v1.x), Mathf.Abs(v1.y));
|
||||
@@ -301,9 +380,10 @@ namespace Coffee.UIEffects
|
||||
if (transitionRoot)
|
||||
{
|
||||
rect = transitionRoot.rect;
|
||||
rectMatrix = transitionRoot.worldToLocalMatrix
|
||||
* graphic.transform.localToWorldMatrix;
|
||||
rot *= Matrix4x4.Scale(new Vector3(1 / multiplier, 1 / multiplier, 1))
|
||||
* transitionRoot.worldToLocalMatrix
|
||||
* graphic.rectTransform.localToWorldMatrix;
|
||||
* rectMatrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -331,133 +411,153 @@ namespace Coffee.UIEffects
|
||||
for (var i = 0; i < count; i += bundleSize)
|
||||
{
|
||||
// min/max for bundled-quad
|
||||
GetBounds(s_WorkingVertices, i, bundleSize, out var bounds, out var uvMask);
|
||||
|
||||
// Quad (6 vertices)
|
||||
for (var j = 0; j < bundleSize; j += 6)
|
||||
UIVertexUtil.GetBounds(verts, i, bundleSize, out var bounds, out var uvMask);
|
||||
UIVertexUtil.Expand(verts, i, bundleSize, expandSize, bounds);
|
||||
for (var j = 0; j < bundleSize; j++)
|
||||
{
|
||||
var size = default(Vector3);
|
||||
var extendPos = default(Vector3);
|
||||
var extendUV = default(Vector3);
|
||||
var posLB = s_WorkingVertices[i + j + 1].position;
|
||||
var posRT = s_WorkingVertices[i + j + 4].position;
|
||||
var willExpand = useExpand
|
||||
&& (bundleSize == 6 // Text or simple quad
|
||||
|| !bounds.Contains(posLB) ||
|
||||
!bounds.Contains(posRT)); // Outer 9-sliced quad
|
||||
if (willExpand)
|
||||
{
|
||||
var uvLB = s_WorkingVertices[i + j + 1].uv0;
|
||||
var uvRT = s_WorkingVertices[i + j + 4].uv0;
|
||||
var posCenter = (posLB + posRT) / 2;
|
||||
var uvCenter = (uvLB + uvRT) / 2;
|
||||
size = posLB - posRT;
|
||||
size.x = 1 + expandSize.x / Mathf.Abs(size.x);
|
||||
size.y = 1 + expandSize.y / Mathf.Abs(size.y);
|
||||
size.z = 1;
|
||||
extendPos = posCenter - Vector3.Scale(size, posCenter);
|
||||
extendUV = uvCenter - Vector4.Scale(size, uvCenter);
|
||||
}
|
||||
|
||||
// Set vertex position, uv, uvMask and local normalized position.
|
||||
for (var k = 0; k < 6; k++)
|
||||
{
|
||||
var vt = s_WorkingVertices[i + j + k];
|
||||
var pos = vt.position;
|
||||
var uv0 = vt.uv0;
|
||||
|
||||
// Expand edge vertex
|
||||
if (willExpand)
|
||||
{
|
||||
if (pos.x < bounds.xMin || bounds.xMax < pos.x)
|
||||
{
|
||||
pos.x = pos.x * size.x + extendPos.x;
|
||||
uv0.x = uv0.x * size.x + extendUV.x;
|
||||
}
|
||||
|
||||
if (pos.y < bounds.yMin || bounds.yMax < pos.y)
|
||||
{
|
||||
pos.y = pos.y * size.y + extendPos.y;
|
||||
uv0.y = uv0.y * size.y + extendUV.y;
|
||||
}
|
||||
}
|
||||
|
||||
ModifyVertex(isTextMeshPro, ref vt, pos, uv0, uvMask, rect, rot);
|
||||
s_WorkingVertices[i + j + k] = vt;
|
||||
}
|
||||
var vt = verts[i + j];
|
||||
ModifyVertex(ref vt, vt.position, vt.uv0, uvMask, rect, rot);
|
||||
verts[i + j] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
if (shadowMode != ShadowMode.None)
|
||||
{
|
||||
var start = 0;
|
||||
var end = count;
|
||||
if (shadowMode == ShadowMode.Mirror)
|
||||
{
|
||||
var rect2 = transitionRoot.rect;
|
||||
var pivot = transitionRoot.pivot.y;
|
||||
var height = rect2.height;
|
||||
var rate = shadowDistance.x;
|
||||
var scale = shadowMirrorScale;
|
||||
var offset = shadowDistance.y - (scale + 1) * pivot * height;
|
||||
var range = new Vector2(rect2.yMin, rect2.yMax);
|
||||
ApplyMirror(s_WorkingVertices, count, rate, range, scale, offset, shadowFade);
|
||||
}
|
||||
else
|
||||
{
|
||||
var d = Vector2.zero;
|
||||
var a = 1f;
|
||||
var distance = new Vector2(Mathf.Clamp(shadowDistance.x, -k_MaxEffectDistance, k_MaxEffectDistance),
|
||||
Mathf.Clamp(shadowDistance.y, -k_MaxEffectDistance, k_MaxEffectDistance));
|
||||
for (var i = 0; i < shadowIteration; i++)
|
||||
{
|
||||
d += distance / (i + 1);
|
||||
a *= shadowFade;
|
||||
ApplyShadow(s_WorkingVertices, ref start, ref end, d, shadowMode, a);
|
||||
}
|
||||
}
|
||||
// Apply gradation.
|
||||
ApplyGradation(verts, transitionRoot.rect, rectMatrix, canModifyShape);
|
||||
|
||||
// Mark as origin vertices.
|
||||
if (!shadowEffectOnOrigin)
|
||||
{
|
||||
for (var i = s_WorkingVertices.Count - count; i < s_WorkingVertices.Count; i++)
|
||||
{
|
||||
var vt = s_WorkingVertices[i];
|
||||
if (isTextMeshPro)
|
||||
{
|
||||
vt.uv1.z -= 8;
|
||||
vt.uv1.w -= 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
vt.uv0.z -= 8;
|
||||
vt.uv0.w -= 8;
|
||||
}
|
||||
|
||||
s_WorkingVertices[i] = vt;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Apply shadow.
|
||||
ApplyShadow(transitionRoot, verts);
|
||||
|
||||
vh.Clear();
|
||||
vh.AddUIVertexTriangleStream(s_WorkingVertices);
|
||||
vh.AddUIVertexTriangleStream(verts);
|
||||
}
|
||||
|
||||
private int GetVertexCountMultiply()
|
||||
private void ApplyGradation(List<UIVertex> verts, Rect rect, Matrix4x4 m, bool canModifyShape)
|
||||
{
|
||||
if (gradationMode == GradationMode.None) return;
|
||||
|
||||
var a = gradationColor1;
|
||||
var b = gradationColor2;
|
||||
var offset = gradationOffset;
|
||||
var scale = gradationScale;
|
||||
var grad = gradationGradient;
|
||||
var rot = gradationRotation;
|
||||
switch (gradationMode)
|
||||
{
|
||||
case GradationMode.Horizontal:
|
||||
GradientUtil.DoHorizontalGradient(verts, a, b, offset, scale, rect, m);
|
||||
break;
|
||||
case GradationMode.Vertical:
|
||||
GradientUtil.DoVerticalGradient(verts, a, b, offset, scale, rect, m);
|
||||
break;
|
||||
case GradationMode.DiagonalToRightBottom:
|
||||
GradientUtil.DoDiagonalGradientToRightBottom(verts, a, b, offset, scale, rect, m);
|
||||
break;
|
||||
case GradationMode.DiagonalToLeftBottom:
|
||||
GradientUtil.DoDiagonalGradientToLeftBottom(verts, a, b, offset, scale, rect, m);
|
||||
break;
|
||||
case GradationMode.RadialFast:
|
||||
GradientUtil.DoRadialGradient(verts, a, b, offset, scale, rect, m, 4);
|
||||
break;
|
||||
case GradationMode.RadialDetail:
|
||||
GradientUtil.DoRadialGradient(verts, a, b, offset, scale, rect, m, 12);
|
||||
break;
|
||||
case GradationMode.Angle:
|
||||
rect = GradientUtil.RotateRectAsNormalized(rect, rot);
|
||||
m = Matrix4x4.Rotate(Quaternion.Euler(0, 0, rot)) * m;
|
||||
GradientUtil.DoHorizontalGradient(verts, a, b, offset, scale, rect, m);
|
||||
break;
|
||||
case GradationMode.HorizontalGradient:
|
||||
{
|
||||
if (_keyTimes == null)
|
||||
{
|
||||
_keyTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.GetKeyTimes(grad, _keyTimes);
|
||||
}
|
||||
|
||||
if (canModifyShape)
|
||||
{
|
||||
var splitTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.SplitKeyTimes(_keyTimes, splitTimes, offset, scale);
|
||||
GradientUtil.DoHorizontalGradient(verts, grad, splitTimes, offset, scale, rect, m);
|
||||
InternalListPool<float>.Return(ref splitTimes);
|
||||
}
|
||||
else
|
||||
{
|
||||
GradientUtil.DoHorizontalGradient(verts, grad, offset, scale, rect, m);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case GradationMode.VerticalGradient:
|
||||
{
|
||||
if (_keyTimes == null)
|
||||
{
|
||||
_keyTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.GetKeyTimes(grad, _keyTimes);
|
||||
}
|
||||
|
||||
if (canModifyShape)
|
||||
{
|
||||
var splitTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.SplitKeyTimes(_keyTimes, splitTimes, offset, scale);
|
||||
GradientUtil.DoVerticalGradient(verts, grad, splitTimes, offset, scale, rect, m);
|
||||
InternalListPool<float>.Return(ref splitTimes);
|
||||
}
|
||||
else
|
||||
{
|
||||
GradientUtil.DoVerticalGradient(verts, grad, offset, scale, rect, m);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case GradationMode.AngleGradient:
|
||||
{
|
||||
if (_keyTimes == null)
|
||||
{
|
||||
_keyTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.GetKeyTimes(grad, _keyTimes);
|
||||
}
|
||||
|
||||
rect = GradientUtil.RotateRectAsNormalized(rect, rot);
|
||||
m = Matrix4x4.Rotate(Quaternion.Euler(0, 0, rot)) * m;
|
||||
if (canModifyShape)
|
||||
{
|
||||
var splitTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.SplitKeyTimes(_keyTimes, splitTimes, offset, scale);
|
||||
GradientUtil.DoAngleGradient(verts, grad, splitTimes, offset, scale, rect, m);
|
||||
InternalListPool<float>.Return(ref splitTimes);
|
||||
}
|
||||
else
|
||||
{
|
||||
GradientUtil.DoHorizontalGradient(verts, grad, offset, scale, rect, m);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyShadow(RectTransform transitionRoot, List<UIVertex> verts)
|
||||
{
|
||||
switch (shadowMode)
|
||||
{
|
||||
case ShadowMode.Shadow: return 1 + shadowIteration * 1;
|
||||
case ShadowMode.Shadow3: return 1 + shadowIteration * 3;
|
||||
case ShadowMode.Outline: return 1 + shadowIteration * 4;
|
||||
case ShadowMode.Outline8: return 1 + shadowIteration * 8;
|
||||
case ShadowMode.Mirror: return 1 + 1;
|
||||
default: return 1;
|
||||
case ShadowMode.Shadow:
|
||||
case ShadowMode.Shadow3:
|
||||
case ShadowMode.Outline:
|
||||
case ShadowMode.Outline8:
|
||||
ShadowUtil.DoShadow(verts, s_ShadowVectors[(int)shadowMode], shadowDistance, shadowIteration,
|
||||
shadowFade);
|
||||
break;
|
||||
case ShadowMode.Mirror:
|
||||
ShadowUtil.DoMirror(verts, shadowDistance, shadowMirrorScale, shadowFade, transitionRoot);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 GetExpandSize()
|
||||
private Vector2 GetExpandSize(bool canModifyShape)
|
||||
{
|
||||
if (!canModifyShape) return Vector2.zero;
|
||||
|
||||
var expandSize = Vector2.zero;
|
||||
switch (samplingFilter)
|
||||
{
|
||||
@@ -490,192 +590,23 @@ namespace Coffee.UIEffects
|
||||
return expandSize;
|
||||
}
|
||||
|
||||
private static void ModifyVertex(bool isTextMeshPro, ref UIVertex vt, Vector2 pos, Vector2 uv, Rect uvMask,
|
||||
private static void ModifyVertex(ref UIVertex vt, Vector2 pos, Vector2 uv, Rect uvMask,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
vt.position = pos;
|
||||
pos = m.MultiplyPoint3x4(pos);
|
||||
var normalizedX = Mathf.InverseLerp(rect.xMin, rect.xMax, pos.x);
|
||||
var normalizedY = Mathf.InverseLerp(rect.yMin, rect.yMax, pos.y);
|
||||
|
||||
if (isTextMeshPro)
|
||||
if (onModifyVertex != null)
|
||||
{
|
||||
vt.uv0.x = uv.x;
|
||||
vt.uv0.y = uv.y;
|
||||
vt.uv1.z = normalizedX;
|
||||
vt.uv1.w = normalizedY;
|
||||
vt.uv2 = new Vector4(uvMask.xMin, uvMask.yMin, uvMask.xMax, uvMask.yMax);
|
||||
vt = onModifyVertex(vt, uvMask, normalizedX, normalizedY);
|
||||
}
|
||||
else
|
||||
{
|
||||
vt.uv0 = new Vector4(uv.x, uv.y, normalizedX, normalizedY);
|
||||
vt.uv0.z = normalizedX;
|
||||
vt.uv0.w = normalizedY;
|
||||
vt.uv1 = new Vector4(uvMask.xMin, uvMask.yMin, uvMask.xMax, uvMask.yMax);
|
||||
}
|
||||
}
|
||||
|
||||
private static void GetBounds(List<UIVertex> verts, int start, int count, out Rect posBounds,
|
||||
out Rect uvBounds)
|
||||
{
|
||||
var minPos = new Vector2(float.MaxValue, float.MaxValue);
|
||||
var maxPos = new Vector2(float.MinValue, float.MinValue);
|
||||
var minUV = new Vector2(float.MaxValue, float.MaxValue);
|
||||
var maxUV = new Vector2(float.MinValue, float.MinValue);
|
||||
for (var i = start; i < start + count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
var uv = vt.uv0;
|
||||
var pos = vt.position;
|
||||
|
||||
// Left-Bottom
|
||||
if (minPos.x >= pos.x && minPos.y >= pos.y)
|
||||
{
|
||||
minPos = pos;
|
||||
}
|
||||
// Right-Top
|
||||
else if (maxPos.x <= pos.x && maxPos.y <= pos.y)
|
||||
{
|
||||
maxPos = pos;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
// Shrink coordinate to avoid uv edge
|
||||
posBounds = new Rect(minPos.x + 0.001f, minPos.y + 0.001f,
|
||||
maxPos.x - minPos.x - 0.002f, maxPos.y - minPos.y - 0.002f);
|
||||
uvBounds = new Rect(minUV.x, minUV.y, maxUV.x - minUV.x, maxUV.y - minUV.y);
|
||||
}
|
||||
|
||||
private static void ApplyMirror(List<UIVertex> verts, int count, float rate, Vector2 range, float scale,
|
||||
float offset, float alpha)
|
||||
{
|
||||
rate = Mathf.Clamp01(rate);
|
||||
var start = 0;
|
||||
var end = count;
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, 0, 0, alpha);
|
||||
|
||||
for (var i = 0; i < count; i += 6)
|
||||
{
|
||||
var lb = s_WorkingVertices[i];
|
||||
var lbRate = Mathf.InverseLerp(range.x, range.y, lb.position.y);
|
||||
var lt = s_WorkingVertices[i + 1];
|
||||
var ltRate = Mathf.InverseLerp(range.x, range.y, lt.position.y);
|
||||
var rt = s_WorkingVertices[i + 2];
|
||||
var rtRate = Mathf.InverseLerp(range.x, range.y, rt.position.y);
|
||||
var rb = s_WorkingVertices[i + 4];
|
||||
var rbRate = Mathf.InverseLerp(range.x, range.y, rb.position.y);
|
||||
|
||||
lb.color.a = (byte)(Mathf.InverseLerp(rate, 0, lbRate) * lb.color.a);
|
||||
lt.color.a = (byte)(Mathf.InverseLerp(rate, 0, ltRate) * lt.color.a);
|
||||
rt.color.a = (byte)(Mathf.InverseLerp(rate, 0, rtRate) * rt.color.a);
|
||||
rb.color.a = (byte)(Mathf.InverseLerp(rate, 0, rbRate) * rb.color.a);
|
||||
|
||||
if (lbRate < rate && rate < ltRate)
|
||||
{
|
||||
var t = (rate - lbRate) / (ltRate - lbRate);
|
||||
lt.position = Vector3.Lerp(lb.position, lt.position, t);
|
||||
lt.uv0 = Vector4.Lerp(lb.uv0, lt.uv0, t);
|
||||
lt.uv1 = Vector4.Lerp(lb.uv1, lt.uv1, t);
|
||||
lt.uv2 = Vector4.Lerp(lb.uv2, lt.uv2, t);
|
||||
lt.color = Color.Lerp(lb.color, lt.color, t);
|
||||
}
|
||||
|
||||
if (rbRate < rate && rate < rtRate)
|
||||
{
|
||||
var t = (rate - rbRate) / (rtRate - rbRate);
|
||||
rt.position = Vector3.Lerp(rb.position, rt.position, t);
|
||||
rt.uv0 = Vector4.Lerp(rb.uv0, rt.uv0, t);
|
||||
rt.uv1 = Vector4.Lerp(rb.uv1, rt.uv1, t);
|
||||
rt.uv2 = Vector4.Lerp(rb.uv2, rt.uv2, t);
|
||||
rt.color = Color.Lerp(rb.color, rt.color, t);
|
||||
}
|
||||
|
||||
|
||||
lb.position.y = -lb.position.y * scale + offset;
|
||||
lt.position.y = -lt.position.y * scale + offset;
|
||||
rt.position.y = -rt.position.y * scale + offset;
|
||||
rb.position.y = -rb.position.y * scale + offset;
|
||||
|
||||
s_WorkingVertices[i] = s_WorkingVertices[i + 5] = lb;
|
||||
s_WorkingVertices[i + 1] = lt;
|
||||
s_WorkingVertices[i + 2] = s_WorkingVertices[i + 3] = rt;
|
||||
s_WorkingVertices[i + 4] = rb;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append shadow vertices.
|
||||
/// * It is similar to Shadow component implementation.
|
||||
/// </summary>
|
||||
private static void ApplyShadow(List<UIVertex> verts, ref int start, ref int end, Vector2 distance,
|
||||
ShadowMode mode, float alpha)
|
||||
{
|
||||
if (mode == ShadowMode.None) return;
|
||||
|
||||
var x = distance.x;
|
||||
var y = distance.y;
|
||||
switch (mode)
|
||||
{
|
||||
case ShadowMode.Shadow:
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, x, y, alpha);
|
||||
break;
|
||||
case ShadowMode.Shadow3:
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, x, y, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, x, 0, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, 0, y, alpha);
|
||||
break;
|
||||
case ShadowMode.Outline:
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, x, y, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, x, -y, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, -x, y, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, -x, -y, alpha);
|
||||
break;
|
||||
case ShadowMode.Outline8:
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, x, y, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, x, -y, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, -x, y, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, -x, -y, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, x, 0, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, 0, y, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, -x, 0, alpha);
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, 0, -y, alpha);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append shadow vertices.
|
||||
/// * It is similar to Shadow component implementation.
|
||||
/// </summary>
|
||||
private static void ApplyShadowZeroAlloc(List<UIVertex> verts, ref int start, ref int end, float x, float y,
|
||||
float alpha)
|
||||
{
|
||||
var count = end - start;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
// The original vertices is pushed backward.
|
||||
verts.Add(verts[end - count + i]);
|
||||
|
||||
// Set shadow vertex.
|
||||
var vt = verts[start + i];
|
||||
vt.position.x += x;
|
||||
vt.position.y += y;
|
||||
vt.color.a = (byte)(alpha * vt.color.a);
|
||||
verts[start + i] = vt;
|
||||
}
|
||||
|
||||
// Update next shadow offset.
|
||||
start = end;
|
||||
end = verts.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Coffee.UIEffectInternal;
|
||||
using Coffee.UIEffects;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -11,19 +10,6 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
public class UIEffectProjectSettings : PreloadedProjectSettings<UIEffectProjectSettings>
|
||||
{
|
||||
public enum FallbackVariantBehaviour
|
||||
{
|
||||
RegisterShaderVariant,
|
||||
LogError
|
||||
}
|
||||
|
||||
public enum TransformSensitivity
|
||||
{
|
||||
Low,
|
||||
Medium,
|
||||
High
|
||||
}
|
||||
|
||||
[Tooltip(
|
||||
"The sensitivity of the transformation when `Use Target Transform` is enabled in the `UIEffectReplica` component.")]
|
||||
[Header("Setting")]
|
||||
@@ -33,37 +19,32 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
internal List<UIEffect> m_RuntimePresets = new List<UIEffect>();
|
||||
|
||||
[SerializeField]
|
||||
[Header("Editor")]
|
||||
internal FallbackVariantBehaviour m_FallbackVariantBehaviour = FallbackVariantBehaviour.RegisterShaderVariant;
|
||||
[Tooltip("Use HDR color pickers on color fields.")]
|
||||
[SerializeField] private bool m_UseHDRColorPicker = true;
|
||||
|
||||
[HideInInspector]
|
||||
[SerializeField]
|
||||
internal List<string> m_UnregisteredShaderVariants = new List<string>();
|
||||
|
||||
[SerializeField]
|
||||
[Header("Shader")]
|
||||
internal ShaderVariantCollection m_ShaderVariantCollection;
|
||||
|
||||
[HideInInspector]
|
||||
[SerializeField]
|
||||
private ShaderVariantRegistry m_ShaderVariantRegistry = new ShaderVariantRegistry();
|
||||
|
||||
public static ShaderVariantRegistry shaderRegistry => instance.m_ShaderVariantRegistry;
|
||||
|
||||
public static ShaderVariantCollection shaderVariantCollection => shaderRegistry.shaderVariantCollection;
|
||||
|
||||
public static TransformSensitivity transformSensitivity
|
||||
{
|
||||
get => instance.m_TransformSensitivity;
|
||||
set => instance.m_TransformSensitivity = value;
|
||||
}
|
||||
|
||||
public static ShaderVariantCollection shaderVariantCollection => instance.m_ShaderVariantCollection;
|
||||
|
||||
public static float sensitivity
|
||||
public static bool useHdrColorPicker
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (instance.m_TransformSensitivity)
|
||||
{
|
||||
case TransformSensitivity.Low: return 1f / (1 << 2);
|
||||
case TransformSensitivity.Medium: return 1f / (1 << 5);
|
||||
case TransformSensitivity.High: return 1f / (1 << 12);
|
||||
default: return 1f / (1 << (int)instance.m_TransformSensitivity);
|
||||
}
|
||||
}
|
||||
get => instance.m_UseHDRColorPicker;
|
||||
set => instance.m_UseHDRColorPicker = value;
|
||||
}
|
||||
|
||||
public static void RegisterRuntimePreset(UIEffect effect)
|
||||
@@ -91,6 +72,15 @@ namespace Coffee.UIEffects
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
#if UNITY_EDITOR
|
||||
SetupSamplesForShaderVariantRegistry();
|
||||
m_ShaderVariantRegistry.ClearCache();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private const string k_PresetDir = "UIEffectPresets";
|
||||
private const string k_PresetSaveDir = "Assets/ProjectSettings/" + k_PresetDir;
|
||||
@@ -98,13 +88,46 @@ namespace Coffee.UIEffects
|
||||
|
||||
protected override void OnCreateAsset()
|
||||
{
|
||||
m_ShaderVariantCollection = new ShaderVariantCollection()
|
||||
m_ShaderVariantRegistry.InitializeIfNeeded(this, "(UIEffect)");
|
||||
}
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
m_ShaderVariantRegistry.InitializeIfNeeded(this, "(UIEffect)");
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
m_ShaderVariantRegistry.InitializeIfNeeded(this, "(UIEffect)");
|
||||
}
|
||||
|
||||
private void SetupSamplesForShaderVariantRegistry()
|
||||
{
|
||||
#if UNITY_2023_2_OR_NEWER
|
||||
const string tmpSupport = "TextMeshPro Support (Unity 6)";
|
||||
#else
|
||||
const string tmpSupport = "TextMeshPro Support";
|
||||
#endif
|
||||
m_ShaderVariantRegistry.RegisterSamples(new[]
|
||||
{
|
||||
name = "UIEffectShaderVariants"
|
||||
};
|
||||
AssetDatabase.AddObjectToAsset(m_ShaderVariantCollection, this);
|
||||
EditorUtility.SetDirty(this);
|
||||
AssetDatabase.SaveAssets();
|
||||
("Hidden/TextMeshPro/Bitmap (UIEffect)", tmpSupport),
|
||||
("Hidden/TextMeshPro/Mobile/Bitmap (UIEffect)", tmpSupport),
|
||||
("Hidden/TextMeshPro/Distance Field (UIEffect)", tmpSupport),
|
||||
("Hidden/TextMeshPro/Mobile/Distance Field (UIEffect)", tmpSupport)
|
||||
});
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
m_ShaderVariantRegistry.ClearCache();
|
||||
MaterialRepository.Clear();
|
||||
foreach (var c in Misc.FindObjectsOfType<UIEffectBase>()
|
||||
.Concat(Misc.GetAllComponentsInPrefabStage<UIEffectBase>()))
|
||||
{
|
||||
c.SetMaterialDirty();
|
||||
}
|
||||
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
|
||||
internal static UIEffect[] LoadEditorPresets()
|
||||
@@ -154,57 +177,13 @@ namespace Coffee.UIEffects
|
||||
return m.Success ? m.Groups[1].Value : Path.GetFileNameWithoutExtension(assetPath);
|
||||
}
|
||||
|
||||
internal static void ClearUnregisteredShaderVariants()
|
||||
private class Postprocessor : AssetPostprocessor
|
||||
{
|
||||
instance.m_UnregisteredShaderVariants.Clear();
|
||||
}
|
||||
|
||||
internal static void RegisterVariant(string variant)
|
||||
{
|
||||
var values = variant.Split(';');
|
||||
instance.m_ShaderVariantCollection.Add(new ShaderVariantCollection.ShaderVariant()
|
||||
private static void OnPostprocessAllAssets(string[] _, string[] __, string[] ___, string[] ____)
|
||||
{
|
||||
shader = Shader.Find(values[0]),
|
||||
keywords = values[1].Split('|')
|
||||
});
|
||||
instance.m_UnregisteredShaderVariants.Remove(variant);
|
||||
}
|
||||
if (Misc.isBatchOrBuilding) return;
|
||||
|
||||
internal static void RegisterVariant(ShaderVariantCollection.ShaderVariant variant)
|
||||
{
|
||||
instance.m_ShaderVariantCollection.Add(variant);
|
||||
}
|
||||
|
||||
internal static void RegisterVariant(Material material)
|
||||
{
|
||||
if (!material || !material.shader || !instance.m_ShaderVariantCollection) return;
|
||||
|
||||
var variant = new ShaderVariantCollection.ShaderVariant
|
||||
{
|
||||
shader = material.shader,
|
||||
keywords = material.shaderKeywords
|
||||
};
|
||||
|
||||
// Already registered.
|
||||
if (instance.m_ShaderVariantCollection.Contains(variant)) return;
|
||||
|
||||
switch (instance.m_FallbackVariantBehaviour)
|
||||
{
|
||||
case FallbackVariantBehaviour.RegisterShaderVariant:
|
||||
RegisterVariant(variant);
|
||||
break;
|
||||
case FallbackVariantBehaviour.LogError:
|
||||
var shaderName = variant.shader.name;
|
||||
var keywords = string.Join("|", variant.keywords);
|
||||
var v = $"{shaderName};{keywords}";
|
||||
if (!instance.m_UnregisteredShaderVariants.Contains(v))
|
||||
{
|
||||
instance.m_UnregisteredShaderVariants.Add(v);
|
||||
}
|
||||
|
||||
Debug.LogError($"{shaderName} with keywords <{keywords}> is not registered.\n" +
|
||||
"Please register it in 'Project Settings > UI > UIEffect > Shader'.");
|
||||
return;
|
||||
instance.Refresh();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,13 @@ namespace Coffee.UIEffects
|
||||
[SerializeField] private UIEffect m_Target;
|
||||
[SerializeField] private bool m_UseTargetTransform = true;
|
||||
|
||||
[PowerRange(0.01f, 100, 10f)]
|
||||
[SerializeField]
|
||||
protected float m_SamplingScale = 1f;
|
||||
|
||||
[SerializeField]
|
||||
protected bool m_AllowToModifyMeshShape = true;
|
||||
|
||||
private UIEffect _currentTarget;
|
||||
private Matrix4x4 _prevTransformHash;
|
||||
|
||||
@@ -35,6 +42,24 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public float samplingScale
|
||||
{
|
||||
get => m_SamplingScale;
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0.01f, 100);
|
||||
if (Mathf.Approximately(m_SamplingScale, value)) return;
|
||||
m_SamplingScale = value;
|
||||
ApplyContextToMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
public override float actualSamplingScale => target && target.samplingFilter != SamplingFilter.None
|
||||
? Mathf.Clamp(m_SamplingScale, 0.01f, 100)
|
||||
: 1;
|
||||
|
||||
public override bool canModifyShape => m_AllowToModifyMeshShape;
|
||||
|
||||
public override uint effectId => target ? target.effectId : 0;
|
||||
public override UIEffectContext context => target && target.isActiveAndEnabled ? target.context : null;
|
||||
|
||||
@@ -105,7 +130,7 @@ namespace Coffee.UIEffects
|
||||
return useTargetTransform
|
||||
&& target
|
||||
&& transform.HasChanged(target.transform, ref _prevTransformHash,
|
||||
UIEffectProjectSettings.sensitivity);
|
||||
UIEffectProjectSettings.transformSensitivity);
|
||||
}
|
||||
|
||||
private void SetVerticesDirtyIfTransformChanged()
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
[ExecuteAlways]
|
||||
[RequireComponent(typeof(UIEffectBase))]
|
||||
public class UIEffectTweener : MonoBehaviour
|
||||
{
|
||||
@@ -12,7 +15,9 @@ namespace Coffee.UIEffects
|
||||
Tone = 1 << 0,
|
||||
Color = 1 << 1,
|
||||
Sampling = 1 << 2,
|
||||
Transition = 1 << 3
|
||||
Transition = 1 << 3,
|
||||
GradiationOffset = 1 << 5,
|
||||
GradiationRotation = 1 << 6
|
||||
}
|
||||
|
||||
public enum UpdateMode
|
||||
@@ -36,10 +41,17 @@ namespace Coffee.UIEffects
|
||||
Reverse
|
||||
}
|
||||
|
||||
public enum PlayOnEnable
|
||||
{
|
||||
None,
|
||||
Forward,
|
||||
Reverse,
|
||||
KeepDirection
|
||||
}
|
||||
|
||||
[Tooltip("The culling mask of the tween.")]
|
||||
[SerializeField]
|
||||
private CullingMask m_CullingMask =
|
||||
CullingMask.Tone | CullingMask.Color | CullingMask.Sampling | CullingMask.Transition;
|
||||
private CullingMask m_CullingMask = (CullingMask)(-1);
|
||||
|
||||
[Tooltip("The direction of the tween.")]
|
||||
[SerializeField]
|
||||
@@ -64,12 +76,13 @@ namespace Coffee.UIEffects
|
||||
[Range(0f, 10)]
|
||||
private float m_Interval;
|
||||
|
||||
[Tooltip("Whether to restart the tween when enabled.")]
|
||||
[FormerlySerializedAs("m_ResetTimeOnEnable")]
|
||||
[Tooltip("Play the tween when the component is enabled.")]
|
||||
[SerializeField]
|
||||
private bool m_RestartOnEnable = true;
|
||||
private PlayOnEnable m_PlayOnEnable = PlayOnEnable.Forward;
|
||||
|
||||
[Tooltip("The wrap mode of the tween.\n" +
|
||||
" Clamp: Clamp the tween value (not loop).\n" +
|
||||
" Once: Clamp the tween value (not loop).\n" +
|
||||
" Loop: Loop the tween value.\n" +
|
||||
" PingPongOnce: PingPong the tween value (not loop).\n" +
|
||||
" PingPong: PingPong the tween value.")]
|
||||
@@ -83,7 +96,12 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
private UpdateMode m_UpdateMode = UpdateMode.Normal;
|
||||
|
||||
private float _rate;
|
||||
[Tooltip("Event to invoke when the tween has completed.")]
|
||||
[SerializeField]
|
||||
private UnityEvent m_OnComplete = new UnityEvent();
|
||||
|
||||
private bool _isPaused;
|
||||
private float _rate = -1;
|
||||
private float _time;
|
||||
private UIEffectBase _target;
|
||||
|
||||
@@ -92,12 +110,18 @@ namespace Coffee.UIEffects
|
||||
/// </summary>
|
||||
private UIEffectBase target => _target ? _target : _target = GetComponent<UIEffectBase>();
|
||||
|
||||
/// <summary>
|
||||
/// The culling mask of the tween.
|
||||
/// </summary>
|
||||
public CullingMask cullingMask
|
||||
{
|
||||
get => m_CullingMask;
|
||||
set => m_CullingMask = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The direction of the tween.
|
||||
/// </summary>
|
||||
public Direction direction
|
||||
{
|
||||
get => m_Direction;
|
||||
@@ -110,7 +134,7 @@ namespace Coffee.UIEffects
|
||||
public float rate
|
||||
{
|
||||
get => _rate;
|
||||
set
|
||||
private set
|
||||
{
|
||||
value = Mathf.Clamp01(value);
|
||||
if (Mathf.Approximately(_rate, value)) return;
|
||||
@@ -158,22 +182,19 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_time < delay) return _time;
|
||||
var t = _time - delay;
|
||||
switch (wrapMode)
|
||||
if (wrapMode == WrapMode.Once || wrapMode == WrapMode.PingPongOnce)
|
||||
{
|
||||
case WrapMode.Once:
|
||||
case WrapMode.PingPongOnce:
|
||||
return Mathf.Clamp(t, 0, totalTime - delay) + delay;
|
||||
case WrapMode.Loop:
|
||||
case WrapMode.PingPongLoop:
|
||||
return Mathf.Repeat(t, totalTime - delay) + delay;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
return Mathf.Clamp(_time, 0, totalTime);
|
||||
}
|
||||
|
||||
return Mathf.Repeat(_time, totalTime);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The total time of the tween. (read only)
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||
public float totalTime
|
||||
{
|
||||
get
|
||||
@@ -190,56 +211,198 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public bool restartOnEnable
|
||||
/// <summary>
|
||||
/// Play the tween when the component is enabled.
|
||||
/// </summary>
|
||||
public PlayOnEnable playOnEnable
|
||||
{
|
||||
get => m_RestartOnEnable;
|
||||
set => m_RestartOnEnable = value;
|
||||
get => m_PlayOnEnable;
|
||||
set => m_PlayOnEnable = value;
|
||||
}
|
||||
|
||||
[Obsolete("UIEffectTweener.restartOnEnable has been deprecated. Use UIEffectTweener.playOnEnable instead")]
|
||||
public bool restartOnEnable
|
||||
{
|
||||
get => m_PlayOnEnable != PlayOnEnable.Forward;
|
||||
set => m_PlayOnEnable = value ? PlayOnEnable.None : PlayOnEnable.Forward;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The wrap mode of the tween.
|
||||
/// <p>Once: Clamp the tween value (not loop).</p>
|
||||
/// <p>Loop: Loop the tween value.</p>
|
||||
/// <p>PingPongOnce: PingPong the tween value (not loop).</p>
|
||||
/// <p>PingPong: PingPong the tween value.</p>
|
||||
/// </summary>
|
||||
public WrapMode wrapMode
|
||||
{
|
||||
get => m_WrapMode;
|
||||
set => m_WrapMode = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies how to get delta time.
|
||||
/// <p>Normal: Use `Time.deltaTime`.</p>
|
||||
/// <p>Unscaled: Use `Time.unscaledDeltaTime`.</p>
|
||||
/// <p>Manual: Not updated automatically and update manually with `UpdateTime` or `SetTime` method.</p>
|
||||
/// </summary>
|
||||
public UpdateMode updateMode
|
||||
{
|
||||
get => m_UpdateMode;
|
||||
set => m_UpdateMode = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The curve to tween the properties.
|
||||
/// </summary>
|
||||
public AnimationCurve curve
|
||||
{
|
||||
get => m_Curve;
|
||||
set => m_Curve = value;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
/// <summary>
|
||||
/// Event to invoke when the tween has completed.
|
||||
/// </summary>
|
||||
public UnityEvent onComplete => m_OnComplete;
|
||||
|
||||
/// <summary>
|
||||
/// Is the tween playing?
|
||||
/// </summary>
|
||||
public bool isTweening
|
||||
{
|
||||
switch (m_UpdateMode)
|
||||
get
|
||||
{
|
||||
case UpdateMode.Normal:
|
||||
UpdateTime(Time.deltaTime);
|
||||
break;
|
||||
case UpdateMode.Unscaled:
|
||||
UpdateTime(Time.unscaledDeltaTime);
|
||||
break;
|
||||
if (_isPaused) return false;
|
||||
if (wrapMode == WrapMode.Loop || wrapMode == WrapMode.PingPongLoop) return true;
|
||||
|
||||
return direction == Direction.Forward
|
||||
? _time < totalTime
|
||||
: 0 < _time;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the tween paused?
|
||||
/// </summary>
|
||||
public bool isPaused => _isPaused;
|
||||
|
||||
/// <summary>
|
||||
/// Is the tween delaying?
|
||||
/// </summary>
|
||||
public bool isDelaying => _time < delay;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (m_RestartOnEnable)
|
||||
_isPaused = true;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) return;
|
||||
#endif
|
||||
|
||||
switch (playOnEnable)
|
||||
{
|
||||
Restart();
|
||||
case PlayOnEnable.KeepDirection:
|
||||
Play();
|
||||
break;
|
||||
case PlayOnEnable.Forward:
|
||||
PlayForward();
|
||||
break;
|
||||
case PlayOnEnable.Reverse:
|
||||
PlayReverse();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
private void OnDisable()
|
||||
{
|
||||
_isPaused = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) return;
|
||||
#endif
|
||||
if (!isTweening) return;
|
||||
|
||||
var deltaTime = m_UpdateMode == UpdateMode.Unscaled
|
||||
? Time.unscaledDeltaTime
|
||||
: Time.deltaTime;
|
||||
UpdateTime(direction == Direction.Forward ? deltaTime : -deltaTime);
|
||||
}
|
||||
|
||||
public void Play(bool resetTime)
|
||||
{
|
||||
if (resetTime)
|
||||
{
|
||||
ResetTime();
|
||||
}
|
||||
|
||||
_isPaused = false;
|
||||
|
||||
if (!isTweening)
|
||||
{
|
||||
m_OnComplete.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
ResetTime();
|
||||
_isPaused = false;
|
||||
|
||||
if (!isTweening)
|
||||
{
|
||||
m_OnComplete.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayForward()
|
||||
{
|
||||
direction = Direction.Forward;
|
||||
_isPaused = false;
|
||||
|
||||
if (!isTweening)
|
||||
{
|
||||
m_OnComplete.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayReverse()
|
||||
{
|
||||
direction = Direction.Reverse;
|
||||
_isPaused = false;
|
||||
|
||||
if (!isTweening)
|
||||
{
|
||||
m_OnComplete.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_isPaused = true;
|
||||
ResetTime();
|
||||
}
|
||||
|
||||
public void SetPause(bool pause)
|
||||
{
|
||||
_isPaused = pause;
|
||||
}
|
||||
|
||||
public void ResetTime()
|
||||
{
|
||||
SetTime(0);
|
||||
}
|
||||
|
||||
[Obsolete(
|
||||
"UIEffectTweener.Restart has been deprecated. Use UIEffectTweener.ResetTime instead (UnityUpgradable) -> ResetTime")]
|
||||
public void Restart()
|
||||
{
|
||||
ResetTime();
|
||||
}
|
||||
|
||||
public void SetTime(float sec)
|
||||
{
|
||||
_time = 0;
|
||||
@@ -248,33 +411,72 @@ namespace Coffee.UIEffects
|
||||
|
||||
public void UpdateTime(float deltaSec)
|
||||
{
|
||||
rate = UpdateTime_Internal(Mathf.Max(0, deltaSec)) / duration;
|
||||
}
|
||||
|
||||
private float UpdateTime_Internal(float delta)
|
||||
{
|
||||
_time += direction == Direction.Forward ? delta : -delta;
|
||||
if (_time < delay) return 0;
|
||||
var prevTweening = isTweening;
|
||||
var isLoop = wrapMode == WrapMode.Loop || wrapMode == WrapMode.PingPongLoop;
|
||||
_time += deltaSec;
|
||||
if (isLoop)
|
||||
{
|
||||
if (_time < 0)
|
||||
{
|
||||
_time = Mathf.Repeat(_time, totalTime);
|
||||
}
|
||||
else if (delay < _time)
|
||||
{
|
||||
_time = Mathf.Repeat(_time - delay, totalTime - delay) + delay;
|
||||
}
|
||||
else if (deltaSec < 0 && delay <= _time - deltaSec)
|
||||
{
|
||||
_time = Mathf.Repeat(_time - delay, totalTime - delay) + delay;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_time = Mathf.Clamp(_time, 0, totalTime);
|
||||
}
|
||||
|
||||
var t = _time - delay;
|
||||
if (t <= 0 && 0 <= _time)
|
||||
{
|
||||
rate = 0;
|
||||
|
||||
if (prevTweening && !isTweening)
|
||||
{
|
||||
m_OnComplete.Invoke();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (wrapMode)
|
||||
{
|
||||
case WrapMode.Once:
|
||||
t = Mathf.Clamp(t, 0, duration);
|
||||
_time = t + delay;
|
||||
break;
|
||||
case WrapMode.Loop:
|
||||
t = Mathf.Repeat(t, duration + interval);
|
||||
_time = t + delay;
|
||||
break;
|
||||
case WrapMode.PingPongOnce:
|
||||
t = Mathf.Clamp(t, 0, duration * 2 + interval);
|
||||
_time = t + delay;
|
||||
t = Mathf.PingPong(t, duration + interval * 0.5f);
|
||||
break;
|
||||
case WrapMode.PingPongLoop:
|
||||
t = Mathf.Repeat(t, (duration + interval) * 2);
|
||||
_time = t + delay;
|
||||
t = t < duration * 2 + interval
|
||||
? Mathf.PingPong(t, duration + interval * 0.5f)
|
||||
: 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return Mathf.Clamp(t, 0, duration);
|
||||
rate = Mathf.Clamp(t, 0, duration) / duration;
|
||||
|
||||
if (prevTweening && !isTweening)
|
||||
{
|
||||
m_OnComplete.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fe15d023b85046ceb6202a0d5a9d16f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
#if TMP_ENABLE
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
public class ContextProcessor
|
||||
{
|
||||
private static readonly List<ContextProcessor> s_Processors = new List<ContextProcessor>()
|
||||
{
|
||||
new ContextProcessor(),
|
||||
#if TMP_ENABLE
|
||||
new TmpContextProcessor(),
|
||||
#endif
|
||||
};
|
||||
|
||||
public static void RegisterProcessor(ContextProcessor processor)
|
||||
{
|
||||
// Register only once.
|
||||
foreach (var p in s_Processors)
|
||||
{
|
||||
if (p.GetType() == processor.GetType()) return;
|
||||
}
|
||||
|
||||
s_Processors.Add(processor);
|
||||
}
|
||||
|
||||
public static ContextProcessor FindProcessor(Graphic graphic)
|
||||
{
|
||||
for (var i = s_Processors.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var p = s_Processors[i];
|
||||
if (p.IsValid(graphic)) return p;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the graphic is valid for this processor.
|
||||
/// </summary>
|
||||
protected virtual bool IsValid(Graphic graphic)
|
||||
{
|
||||
return graphic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the graphic is a text.
|
||||
/// </summary>
|
||||
public virtual bool IsText(Graphic graphic)
|
||||
{
|
||||
return graphic is Text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before modifying the mesh.
|
||||
/// </summary>
|
||||
public virtual void OnPreModifyMesh(Graphic graphic)
|
||||
{
|
||||
UIVertexUtil.onLerpVertex = s_OnLerpVertex;
|
||||
ShadowUtil.onMarkAsShadow = s_OnMarkAsShadow;
|
||||
UIEffectContext.onModifyVertex = s_OnModifyVertex;
|
||||
}
|
||||
|
||||
private static readonly Func<UIVertex, UIVertex, UIVertex, float, UIVertex> s_OnLerpVertex =
|
||||
null;
|
||||
|
||||
private static readonly Func<UIVertex, UIVertex> s_OnMarkAsShadow =
|
||||
vt =>
|
||||
{
|
||||
vt.uv0.z -= 8;
|
||||
vt.uv0.w -= 8;
|
||||
return vt;
|
||||
};
|
||||
|
||||
private static readonly Func<UIVertex, Rect, float, float, UIVertex> s_OnModifyVertex =
|
||||
(vt, uvMask, normalizedX, normalizedY) =>
|
||||
{
|
||||
vt.uv0.z = normalizedX;
|
||||
vt.uv0.w = normalizedY;
|
||||
vt.uv1 = new Vector4(uvMask.xMin, uvMask.yMin, uvMask.xMax, uvMask.yMax);
|
||||
return vt;
|
||||
};
|
||||
}
|
||||
|
||||
#if TMP_ENABLE
|
||||
internal class TmpContextProcessor : ContextProcessor
|
||||
{
|
||||
protected override bool IsValid(Graphic graphic)
|
||||
{
|
||||
if (!graphic) return false;
|
||||
if (graphic is TextMeshProUGUI) return true;
|
||||
if (graphic is TMP_SubMeshUI sub)
|
||||
{
|
||||
// If TMP_SubMeshUI is used for text
|
||||
return !sub.spriteAsset
|
||||
|| sub.sharedMaterial != sub.spriteAsset.material;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the graphic is a text.
|
||||
/// </summary>
|
||||
public override bool IsText(Graphic graphic)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called before modifying the mesh.
|
||||
/// </summary>
|
||||
public override void OnPreModifyMesh(Graphic graphic)
|
||||
{
|
||||
UIVertexUtil.onLerpVertex = s_OnLerpVertex;
|
||||
ShadowUtil.onMarkAsShadow = s_OnMarkAsShadow;
|
||||
UIEffectContext.onModifyVertex = s_OnModifyVertex;
|
||||
}
|
||||
|
||||
private static readonly Func<UIVertex, UIVertex, UIVertex, float, UIVertex> s_OnLerpVertex =
|
||||
#if UNITY_2023_2_OR_NEWER
|
||||
null;
|
||||
#else
|
||||
(vt, a, b, t) =>
|
||||
{
|
||||
// TMP 3.x uses packed UV
|
||||
vt.uv1.x = PackUV(Vector2.Lerp(UnpackUV(a.uv1.x), UnpackUV(b.uv1.x), t));
|
||||
return vt;
|
||||
|
||||
static float PackUV(Vector2 input)
|
||||
{
|
||||
return (int)(input.x * 511) * 4096 + (int)(input.y * 511);
|
||||
}
|
||||
|
||||
static Vector2 UnpackUV(float input)
|
||||
{
|
||||
return new Vector2(input / 4096 / 511, input % 4096 / 511);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
private static readonly Func<UIVertex, UIVertex> s_OnMarkAsShadow =
|
||||
vt =>
|
||||
{
|
||||
vt.uv1.z -= 8;
|
||||
vt.uv1.w -= 8;
|
||||
return vt;
|
||||
};
|
||||
|
||||
private static readonly Func<UIVertex, Rect, float, float, UIVertex> s_OnModifyVertex =
|
||||
(vt, uvMask, normalizedX, normalizedY) =>
|
||||
{
|
||||
vt.uv1.z = normalizedX;
|
||||
vt.uv1.w = normalizedY;
|
||||
vt.uv2 = new Vector4(uvMask.xMin, uvMask.yMin, uvMask.xMax, uvMask.yMax);
|
||||
return vt;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 402a2dd4d098a4d708b9f6e7ce0557cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,379 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
internal static class GradientUtil
|
||||
{
|
||||
public static void DoHorizontalGradient(List<UIVertex> verts, Color a, Color b, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
for (var i = 0; i < verts.Count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x);
|
||||
var t = Mathf.Clamp01(offset + (x - 0.5f) * scale + 0.5f);
|
||||
vt.color *= Color.Lerp(a, b, t);
|
||||
verts[i] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoHorizontalGradient(List<UIVertex> verts, Gradient gradient, List<float> splitTimes,
|
||||
float offset, float scale, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < verts.Count; i += 6)
|
||||
{
|
||||
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);
|
||||
if (i + 5 < count)
|
||||
{
|
||||
UIVertexUtil.SplitHorizontalFast(verts, splitTimes, lb, lt, ref rb, ref rt, rect, m);
|
||||
}
|
||||
|
||||
lb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lb.position).x + 0.0005f, offset, scale);
|
||||
lt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lt.position).x + 0.0005f, offset, scale);
|
||||
rt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rt.position).x - 0.0005f, offset, scale);
|
||||
rb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rb.position).x - 0.0005f, offset, scale);
|
||||
UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
|
||||
{
|
||||
t = Mathf.InverseLerp(rect.xMin, rect.xMax, t); // 0-1
|
||||
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
|
||||
return gradient.Evaluate(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoHorizontalGradientFixed(List<UIVertex> verts, Gradient gradient, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < count; i += 3)
|
||||
{
|
||||
var vt0 = verts[i + 0];
|
||||
var vt1 = verts[i + 1];
|
||||
var vt2 = verts[i + 2];
|
||||
var center = m.MultiplyPoint3x4((vt0.position + vt1.position + vt2.position) / 3).x;
|
||||
vt0.color *= Evaluate(gradient, rect, center, offset, scale);
|
||||
vt1.color *= Evaluate(gradient, rect, center, offset, scale);
|
||||
vt2.color *= Evaluate(gradient, rect, center, offset, scale);
|
||||
verts[i + 0] = vt0;
|
||||
verts[i + 1] = vt1;
|
||||
verts[i + 2] = vt2;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
|
||||
{
|
||||
t = Mathf.InverseLerp(rect.xMin, rect.xMax, t); // 0-1
|
||||
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
|
||||
return gradient.Evaluate(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoHorizontalGradient(List<UIVertex> verts, Gradient gradient, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
vt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(vt.position).x, offset, scale);
|
||||
verts[i] = vt;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
|
||||
{
|
||||
t = Mathf.InverseLerp(rect.xMin, rect.xMax, t); // 0-1
|
||||
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
|
||||
return gradient.Evaluate(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoVerticalGradient(List<UIVertex> verts, Color a, Color b, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
for (var i = 0; i < verts.Count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y);
|
||||
var t = Mathf.Clamp01(offset + (0.5f - y) * scale + 0.5f);
|
||||
vt.color *= Color.Lerp(a, b, t);
|
||||
verts[i] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoVerticalGradient(List<UIVertex> verts, Gradient gradient, List<float> splitTimes,
|
||||
float offset, float scale, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < verts.Count; i += 6)
|
||||
{
|
||||
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);
|
||||
if (i + 5 < count)
|
||||
{
|
||||
UIVertexUtil.SplitVerticalFast(verts, splitTimes, lb, ref lt, rb, ref rt, rect, m);
|
||||
}
|
||||
|
||||
lb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lb.position).y + 0.0005f, offset, scale);
|
||||
lt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lt.position).y - 0.0005f, offset, scale);
|
||||
rt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rt.position).y - 0.0005f, offset, scale);
|
||||
rb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rb.position).y + 0.0005f, offset, scale);
|
||||
UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
|
||||
{
|
||||
t = Mathf.InverseLerp(rect.yMin, rect.yMax, t); // 0-1
|
||||
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
|
||||
return gradient.Evaluate(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoVerticalGradient(List<UIVertex> verts, Gradient gradient, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
vt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(vt.position).y, offset, scale);
|
||||
verts[i] = vt;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
|
||||
{
|
||||
t = Mathf.InverseLerp(rect.yMin, rect.yMax, t); // 0-1
|
||||
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
|
||||
return gradient.Evaluate(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoDiagonalGradientToRightBottom(List<UIVertex> verts, Color a, Color b, float offset,
|
||||
float scale, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
for (var i = 0; i < verts.Count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x);
|
||||
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y);
|
||||
var t = Mathf.Clamp01(0.5f * scale + 0.5f + offset - (1 - x + y) * scale / 2);
|
||||
vt.color *= Color.Lerp(a, b, t);
|
||||
verts[i] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoDiagonalGradientToLeftBottom(List<UIVertex> verts, Color a, Color b, float offset,
|
||||
float scale, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
for (var i = 0; i < verts.Count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x);
|
||||
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y);
|
||||
var t = Mathf.Clamp01(0.5f * scale + 0.5f + offset - (x + y) * scale / 2);
|
||||
vt.color *= Color.Lerp(a, b, t);
|
||||
verts[i] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoRadialGradient(List<UIVertex> verts, Color a, Color b, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m, int divide)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < count; i += 6)
|
||||
{
|
||||
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);
|
||||
for (var j = 1; j < divide; j++)
|
||||
{
|
||||
var min = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(lb.position).x);
|
||||
var max = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(rt.position).x);
|
||||
var time = 1f - (float)j / divide;
|
||||
if (time <= min || max <= time) continue;
|
||||
|
||||
UIVertexUtil.SplitHorizontal(verts, lb, lt, ref rb, ref rt, Mathf.InverseLerp(min, max, time));
|
||||
}
|
||||
|
||||
UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
|
||||
}
|
||||
|
||||
count = verts.Count;
|
||||
for (var i = 0; i < verts.Count; i += 6)
|
||||
{
|
||||
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);
|
||||
|
||||
if (i + 5 < count)
|
||||
{
|
||||
for (var j = 1; j < divide; j++)
|
||||
{
|
||||
var min = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(lb.position).y);
|
||||
var max = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(rt.position).y);
|
||||
var time = 1f - (float)j / divide;
|
||||
if (time <= min || max <= time) continue;
|
||||
|
||||
UIVertexUtil.SplitVertical(verts, lb, ref lt, rb, ref rt, Mathf.InverseLerp(min, max, time));
|
||||
}
|
||||
}
|
||||
|
||||
lb.color *= DoGradient(lb, a, b, rect, m, offset, scale);
|
||||
lt.color *= DoGradient(lt, a, b, rect, m, offset, scale);
|
||||
rt.color *= DoGradient(rt, a, b, rect, m, offset, scale);
|
||||
rb.color *= DoGradient(rb, a, b, rect, m, offset, scale);
|
||||
UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color DoGradient(UIVertex vt, Color a, Color b, Rect rect, Matrix4x4 m, float offset, float scale)
|
||||
{
|
||||
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x) - 0.5f;
|
||||
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y) - 0.5f;
|
||||
var t = Mathf.Clamp01(offset + Mathf.Sqrt(x * x + y * y) * 2 * scale);
|
||||
return Color.Lerp(a, b, t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoAngleGradient(List<UIVertex> verts, Gradient gradient, List<float> splitTimes,
|
||||
float offset, float scale, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
UIVertexUtil.SplitAngle(verts, splitTimes, rect, m);
|
||||
if (gradient.mode == GradientMode.Fixed)
|
||||
{
|
||||
DoHorizontalGradientFixed(verts, gradient, offset, scale, rect, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoHorizontalGradient(verts, gradient, offset, scale, rect, m);
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetKeyTimes(Gradient gradient, List<float> results)
|
||||
{
|
||||
results.Clear();
|
||||
var colors = gradient.colorKeys;
|
||||
for (var i = 0; i < colors.Length; i++)
|
||||
{
|
||||
AddKeyTime(results, colors[i].time);
|
||||
}
|
||||
|
||||
var alphas = gradient.alphaKeys;
|
||||
for (var i = 0; i < alphas.Length; i++)
|
||||
{
|
||||
AddKeyTime(results, alphas[i].time);
|
||||
}
|
||||
|
||||
AddKeyTime(results, 0);
|
||||
AddKeyTime(results, 1);
|
||||
results.Sort((a, b) => b.CompareTo(a));
|
||||
|
||||
return;
|
||||
|
||||
static void AddKeyTime(List<float> results, float time)
|
||||
{
|
||||
if (!Contains(results, time))
|
||||
{
|
||||
results.Add(time);
|
||||
}
|
||||
}
|
||||
|
||||
static bool Contains(List<float> list, float v)
|
||||
{
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (Mathf.Abs(list[i] - v) < 0.001f) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SplitKeyTimes(List<float> keyTimes, List<float> results, float offset, float scale)
|
||||
{
|
||||
results.Clear();
|
||||
for (var i = 0; i < keyTimes.Count; i++)
|
||||
{
|
||||
AddSplitTime(results, keyTimes[i], offset, scale);
|
||||
}
|
||||
|
||||
results.Sort((a, b) => b.CompareTo(a));
|
||||
|
||||
return;
|
||||
|
||||
static void AddSplitTime(List<float> results, float time, float offset, float scale)
|
||||
{
|
||||
time = time * scale + offset * scale + (1 - scale) / 2;
|
||||
|
||||
while (0 < time)
|
||||
{
|
||||
time -= scale;
|
||||
}
|
||||
|
||||
while (time <= 1f)
|
||||
{
|
||||
if (0 <= time && !Contains(results, time))
|
||||
{
|
||||
results.Add(time);
|
||||
}
|
||||
|
||||
time += scale;
|
||||
}
|
||||
}
|
||||
|
||||
static bool Contains(List<float> list, float v)
|
||||
{
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (Mathf.Abs(list[i] - v) < 0.001f) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Rect RotateRectAsNormalized(Rect rect, float rot)
|
||||
{
|
||||
var rad = -rot * Mathf.Deg2Rad;
|
||||
var cos = Mathf.Cos(rad);
|
||||
var sin = Mathf.Sin(rad);
|
||||
var dir = new Vector2(cos, sin);
|
||||
var center = rect.center;
|
||||
|
||||
if (Mathf.Abs(dir.x) < 0.0001f)
|
||||
{
|
||||
rect.width = rect.height;
|
||||
}
|
||||
else if (Mathf.Abs(dir.y) < 0.0001f)
|
||||
{
|
||||
rect.height = rect.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
var d0 = GetPointToLineDistance(new Vector2(rect.xMin, rect.yMax), center, dir, out var p0);
|
||||
var d1 = GetPointToLineDistance(new Vector2(rect.xMin, rect.yMin), center, dir, out var p1);
|
||||
var closest = d0 < d1 ? p0 : p1;
|
||||
rect.width = rect.height = Vector2.Distance(center, closest) * 2;
|
||||
}
|
||||
|
||||
rect.center = new Vector2(Vector2.Dot(center, dir), 0);
|
||||
return rect;
|
||||
}
|
||||
|
||||
private static float GetPointToLineDistance(Vector2 point, Vector2 origin, Vector2 dir, out Vector2 closest)
|
||||
{
|
||||
var dirNormalized = dir.normalized;
|
||||
var time = Vector2.Dot(point - origin, dirNormalized);
|
||||
closest = origin + time * dirNormalized;
|
||||
return Vector2.Distance(point, closest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23cc1f211cd264050a641c01c4a6d77a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
public static class ShadowUtil
|
||||
{
|
||||
public static Func<UIVertex, UIVertex> onMarkAsShadow;
|
||||
|
||||
public static void DoShadow(List<UIVertex> verts, Vector2[] vectors, Vector2 distance, int iteration,
|
||||
float fade)
|
||||
{
|
||||
UIVertexUtil.ExpandCapacity(verts, 1 + vectors.Length);
|
||||
distance = new Vector2(Mathf.Clamp(distance.x, -600, 600), Mathf.Clamp(distance.y, -600, 600));
|
||||
var count = verts.Count;
|
||||
var start = 0;
|
||||
var end = count;
|
||||
var d = Vector2.zero;
|
||||
var a = fade;
|
||||
for (var i = 0; i < iteration; i++)
|
||||
{
|
||||
d += distance / (i + 1);
|
||||
a *= 0.75f;
|
||||
ApplyShadow(verts, vectors, ref start, ref end, d, a);
|
||||
}
|
||||
|
||||
// Mark as shadow vertices.
|
||||
for (var i = 0; i < verts.Count - count; i++)
|
||||
{
|
||||
if (onMarkAsShadow != null)
|
||||
{
|
||||
verts[i] = onMarkAsShadow(verts[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
var vt = verts[i];
|
||||
vt.uv0.z -= 8;
|
||||
vt.uv0.w -= 8;
|
||||
verts[i] = vt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoMirror(List<UIVertex> verts, Vector2 distance, float scale, float fade, RectTransform root)
|
||||
{
|
||||
UIVertexUtil.ExpandCapacity(verts, 2);
|
||||
distance = new Vector2(Mathf.Clamp(distance.x, -600, 600), Mathf.Clamp(distance.y, -600, 600));
|
||||
var count = verts.Count;
|
||||
var rect2 = root.rect;
|
||||
var pivot = root.pivot.y;
|
||||
var height = rect2.height;
|
||||
var rate = distance.x;
|
||||
var offset = distance.y - (scale + 1) * pivot * height;
|
||||
var range = new Vector2(rect2.yMin, rect2.yMax);
|
||||
ApplyMirror(verts, count, rate, range, scale, offset, fade);
|
||||
}
|
||||
|
||||
private static void ApplyMirror(List<UIVertex> verts, int count, float rate, Vector2 range, float scale,
|
||||
float offset, float alpha)
|
||||
{
|
||||
rate = Mathf.Clamp01(rate);
|
||||
var start = 0;
|
||||
var end = count;
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, 0, 0, alpha);
|
||||
|
||||
for (var i = 0; i < count; i += 6)
|
||||
{
|
||||
var lb = verts[i];
|
||||
var lbRate = Mathf.InverseLerp(range.x, range.y, lb.position.y);
|
||||
var lt = verts[i + 1];
|
||||
var ltRate = Mathf.InverseLerp(range.x, range.y, lt.position.y);
|
||||
var rt = verts[i + 2];
|
||||
var rtRate = Mathf.InverseLerp(range.x, range.y, rt.position.y);
|
||||
var rb = verts[i + 4];
|
||||
var rbRate = Mathf.InverseLerp(range.x, range.y, rb.position.y);
|
||||
|
||||
lb.color.a = (byte)(Mathf.InverseLerp(rate, 0, lbRate) * lb.color.a);
|
||||
lt.color.a = (byte)(Mathf.InverseLerp(rate, 0, ltRate) * lt.color.a);
|
||||
rt.color.a = (byte)(Mathf.InverseLerp(rate, 0, rtRate) * rt.color.a);
|
||||
rb.color.a = (byte)(Mathf.InverseLerp(rate, 0, rbRate) * rb.color.a);
|
||||
|
||||
if (lbRate < rate && rate < ltRate)
|
||||
{
|
||||
var t = (rate - lbRate) / (ltRate - lbRate);
|
||||
lt = UIVertexUtil.VertexLerp(lb, lt, t);
|
||||
}
|
||||
|
||||
if (rbRate < rate && rate < rtRate)
|
||||
{
|
||||
var t = (rate - rbRate) / (rtRate - rbRate);
|
||||
rt = UIVertexUtil.VertexLerp(rb, rt, t);
|
||||
}
|
||||
|
||||
lb.position.y = -lb.position.y * scale + offset;
|
||||
lt.position.y = -lt.position.y * scale + offset;
|
||||
rt.position.y = -rt.position.y * scale + offset;
|
||||
rb.position.y = -rb.position.y * scale + offset;
|
||||
|
||||
verts[i] = verts[i + 5] = lb;
|
||||
verts[i + 1] = lt;
|
||||
verts[i + 2] = verts[i + 3] = rt;
|
||||
verts[i + 4] = rb;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append shadow vertices.
|
||||
/// * It is similar to Shadow component implementation.
|
||||
/// </summary>
|
||||
private static void ApplyShadow(List<UIVertex> verts, Vector2[] vectors, ref int start, ref int end,
|
||||
Vector2 distance, float alpha)
|
||||
{
|
||||
var x = distance.x;
|
||||
var y = distance.y;
|
||||
for (var i = 0; i < vectors.Length; i++)
|
||||
{
|
||||
var dx = x * vectors[i].x;
|
||||
var dy = y * vectors[i].y;
|
||||
ApplyShadowZeroAlloc(verts, ref start, ref end, dx, dy, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Append shadow vertices.
|
||||
/// * It is similar to Shadow component implementation.
|
||||
/// </summary>
|
||||
private static void ApplyShadowZeroAlloc(List<UIVertex> verts, ref int start, ref int end, float x, float y,
|
||||
float alpha)
|
||||
{
|
||||
var count = end - start;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
// The original vertices is pushed backward.
|
||||
verts.Add(verts[end - count + i]);
|
||||
|
||||
// Set shadow vertex.
|
||||
var vt = verts[start + i];
|
||||
vt.position.x += x;
|
||||
vt.position.y += y;
|
||||
vt.color.a = (byte)(alpha * vt.color.a);
|
||||
verts[start + i] = vt;
|
||||
}
|
||||
|
||||
// Update next shadow offset.
|
||||
start = end;
|
||||
end = verts.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65df2c9dff42a4ddb8bada9fb153b562
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,302 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Coffee.UIEffectInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
internal static class UIVertexUtil
|
||||
{
|
||||
public static Func<UIVertex, UIVertex, UIVertex, float, UIVertex> onLerpVertex;
|
||||
|
||||
public static void ExpandCapacity(List<UIVertex> verts, int multiplier)
|
||||
{
|
||||
var capacity = Mathf.NextPowerOfTwo(verts.Count * multiplier);
|
||||
if (verts.Capacity < capacity)
|
||||
{
|
||||
verts.Capacity = capacity;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Expand(List<UIVertex> verts, int start, int bundleSize, Vector2 expandSize, Rect bounds)
|
||||
{
|
||||
if (expandSize == Vector2.zero) return;
|
||||
|
||||
// Quad (6 vertices)
|
||||
for (var j = 0; j < bundleSize; j += 6)
|
||||
{
|
||||
var size = default(Vector3);
|
||||
var extendPos = default(Vector3);
|
||||
var extendUV = default(Vector3);
|
||||
var posLB = verts[start + j + 1].position;
|
||||
var posRT = verts[start + j + 4].position;
|
||||
var willExpand = bundleSize == 6 // Text or simple quad
|
||||
|| !bounds.Contains(posLB)
|
||||
|| !bounds.Contains(posRT); // Outer 9-sliced quad
|
||||
if (willExpand)
|
||||
{
|
||||
var uvLB = verts[start + j + 1].uv0;
|
||||
var uvRT = verts[start + j + 4].uv0;
|
||||
var posCenter = (posLB + posRT) / 2;
|
||||
var uvCenter = (uvLB + uvRT) / 2;
|
||||
size = posLB - posRT;
|
||||
size.x = 1 + expandSize.x / Mathf.Abs(size.x);
|
||||
size.y = 1 + expandSize.y / Mathf.Abs(size.y);
|
||||
size.z = 1;
|
||||
extendPos = posCenter - Vector3.Scale(size, posCenter);
|
||||
extendUV = uvCenter - Vector4.Scale(size, uvCenter);
|
||||
}
|
||||
|
||||
// Set vertex position, uv, uvMask and local normalized position.
|
||||
for (var k = 0; k < 6; k++)
|
||||
{
|
||||
var vt = verts[start + j + k];
|
||||
var pos = vt.position;
|
||||
var uv0 = vt.uv0;
|
||||
|
||||
// Expand edge vertex
|
||||
if (willExpand)
|
||||
{
|
||||
if (pos.x < bounds.xMin || bounds.xMax < pos.x)
|
||||
{
|
||||
pos.x = pos.x * size.x + extendPos.x;
|
||||
uv0.x = uv0.x * size.x + extendUV.x;
|
||||
}
|
||||
|
||||
if (pos.y < bounds.yMin || bounds.yMax < pos.y)
|
||||
{
|
||||
pos.y = pos.y * size.y + extendPos.y;
|
||||
uv0.y = uv0.y * size.y + extendUV.y;
|
||||
}
|
||||
}
|
||||
|
||||
vt.position = pos;
|
||||
vt.uv0.x = uv0.x;
|
||||
vt.uv0.y = uv0.y;
|
||||
verts[start + j + k] = vt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static UIVertex VertexLerp(UIVertex a, UIVertex b, float t)
|
||||
{
|
||||
var vt = new UIVertex
|
||||
{
|
||||
position = Vector3.Lerp(a.position, b.position, t),
|
||||
normal = Vector3.Lerp(a.normal, b.normal, t),
|
||||
tangent = Vector4.Lerp(a.tangent, b.tangent, t),
|
||||
color = Color.Lerp(a.color, b.color, t),
|
||||
uv0 = Vector4.Lerp(a.uv0, b.uv0, t),
|
||||
uv1 = Vector4.Lerp(a.uv1, b.uv1, t),
|
||||
uv2 = Vector4.Lerp(a.uv2, b.uv2, t)
|
||||
};
|
||||
|
||||
if (onLerpVertex != null)
|
||||
{
|
||||
vt = onLerpVertex(vt, a, b, t);
|
||||
}
|
||||
|
||||
return vt;
|
||||
}
|
||||
|
||||
public static void GetBounds(List<UIVertex> verts, int start, int bundleSize, out Rect posBounds,
|
||||
out Rect uvBounds)
|
||||
{
|
||||
var minPos = new Vector2(float.MaxValue, float.MaxValue);
|
||||
var maxPos = new Vector2(float.MinValue, float.MinValue);
|
||||
var minUV = new Vector2(float.MaxValue, float.MaxValue);
|
||||
var maxUV = new Vector2(float.MinValue, float.MinValue);
|
||||
for (var i = start; i < start + bundleSize; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
UpdateMinMax(ref minPos, ref maxPos, vt.position);
|
||||
UpdateMinMax(ref minUV, ref maxUV, vt.uv0);
|
||||
}
|
||||
|
||||
// Shrink coordinate to avoid uv edge
|
||||
posBounds = new Rect(minPos.x + 0.001f, minPos.y + 0.001f,
|
||||
maxPos.x - minPos.x - 0.002f, maxPos.y - minPos.y - 0.002f);
|
||||
uvBounds = new Rect(minUV.x, minUV.y, maxUV.x - minUV.x, maxUV.y - minUV.y);
|
||||
|
||||
return;
|
||||
|
||||
static void UpdateMinMax(ref Vector2 min, ref Vector2 max, Vector2 value)
|
||||
{
|
||||
if (value.x < min.x) min.x = value.x; // Left
|
||||
if (max.x < value.x) max.x = value.x; // Right
|
||||
if (value.y < min.y) min.y = value.y; // Bottom
|
||||
if (max.y < value.y) max.y = value.y; // Top
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetQuad(List<UIVertex> verts, int i, out UIVertex lb, out UIVertex lt, out UIVertex rt,
|
||||
out UIVertex rb)
|
||||
{
|
||||
lb = verts[i];
|
||||
lt = verts[i + 1];
|
||||
rt = verts[i + 2];
|
||||
rb = verts[i + 4];
|
||||
}
|
||||
|
||||
public static void SetQuad(List<UIVertex> verts, int i, UIVertex lb, UIVertex lt, UIVertex rt, UIVertex rb)
|
||||
{
|
||||
verts[i] = verts[i + 5] = lb;
|
||||
verts[i + 1] = lt;
|
||||
verts[i + 2] = verts[i + 3] = rt;
|
||||
verts[i + 4] = rb;
|
||||
}
|
||||
|
||||
public static void SplitHorizontalFast(List<UIVertex> verts, List<float> times, UIVertex lb, UIVertex lt,
|
||||
ref UIVertex rb, ref UIVertex rt, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
if (times == null || times.Count == 0) return;
|
||||
|
||||
var min = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(lb.position).x);
|
||||
for (var i = 0; i < times.Count; i++)
|
||||
{
|
||||
var time = times[i];
|
||||
if (time <= 0 || 1 <= time) continue;
|
||||
|
||||
var max = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(rt.position).x);
|
||||
if (time <= min || max <= time) continue;
|
||||
|
||||
SplitHorizontal(verts, lb, lt, ref rb, ref rt, Mathf.InverseLerp(min, max, time));
|
||||
}
|
||||
}
|
||||
|
||||
public static void SplitHorizontal(List<UIVertex> verts, UIVertex lb, UIVertex lt, ref UIVertex rb,
|
||||
ref UIVertex rt, float time)
|
||||
{
|
||||
var mb = VertexLerp(lb, rb, time);
|
||||
var mt = VertexLerp(lt, rt, time);
|
||||
verts.Add(mb);
|
||||
verts.Add(mt);
|
||||
verts.Add(rt);
|
||||
verts.Add(rt);
|
||||
verts.Add(rb);
|
||||
verts.Add(mb);
|
||||
rt = mt;
|
||||
rb = mb;
|
||||
}
|
||||
|
||||
public static void SplitVerticalFast(List<UIVertex> verts, List<float> times, UIVertex lb, ref UIVertex lt,
|
||||
UIVertex rb, ref UIVertex rt, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
if (times == null || times.Count == 0) return;
|
||||
|
||||
var min = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(lb.position).y);
|
||||
for (var i = 0; i < times.Count; i++)
|
||||
{
|
||||
var time = times[i];
|
||||
var max = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(rt.position).y);
|
||||
if (time <= min || max <= time) continue;
|
||||
|
||||
SplitVertical(verts, lb, ref lt, rb, ref rt, Mathf.InverseLerp(min, max, time));
|
||||
}
|
||||
}
|
||||
|
||||
public static void SplitVertical(List<UIVertex> verts, UIVertex lb, ref UIVertex lt, UIVertex rb,
|
||||
ref UIVertex rt, float time)
|
||||
{
|
||||
var lm = VertexLerp(lb, lt, time);
|
||||
var rm = VertexLerp(rb, rt, time);
|
||||
verts.Add(lm);
|
||||
verts.Add(lt);
|
||||
verts.Add(rt);
|
||||
verts.Add(rt);
|
||||
verts.Add(rm);
|
||||
verts.Add(lm);
|
||||
lt = lm;
|
||||
rt = rm;
|
||||
}
|
||||
|
||||
public static void SplitAngle(List<UIVertex> verts, List<float> times, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
if (times == null || times.Count == 0) return;
|
||||
|
||||
for (var i = 0; i < times.Count; i++)
|
||||
{
|
||||
var x = Mathf.Lerp(rect.xMin, rect.xMax, times[i]);
|
||||
Split(verts, new Vector2(x, 0), new Vector2(0, 1), m);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static void Split(List<UIVertex> verts, Vector2 p, Vector2 dir, Matrix4x4 m)
|
||||
{
|
||||
// Each triangle
|
||||
var intersections = InternalListPool<UIVertex>.Rent();
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < count; i += 3)
|
||||
{
|
||||
intersections.Clear();
|
||||
var n = -1;
|
||||
// Each edge
|
||||
for (var j = 0; j < 3; j++)
|
||||
{
|
||||
var start = verts[i + j];
|
||||
var end = verts[i + (j + 1) % 3];
|
||||
|
||||
if (DoesIntersect(start, end, p, dir, m, out var intersection))
|
||||
{
|
||||
intersections.Add(intersection);
|
||||
}
|
||||
else
|
||||
{
|
||||
n = j;
|
||||
}
|
||||
}
|
||||
|
||||
if (intersections.Count == 2)
|
||||
{
|
||||
var vt0 = verts[i + (n + 2) % 3];
|
||||
var vt1 = verts[i + (n + 0) % 3];
|
||||
var vt2 = verts[i + (n + 1) % 3];
|
||||
var it0 = intersections[0];
|
||||
var it1 = intersections[1];
|
||||
var it2 = intersections[(n + 1) % 2];
|
||||
verts[i + 0] = vt0;
|
||||
verts[i + 1] = it0;
|
||||
verts[i + 2] = it1;
|
||||
verts.Add(it2);
|
||||
verts.Add(vt1);
|
||||
verts.Add(vt2);
|
||||
verts.Add(vt2);
|
||||
verts.Add(it0);
|
||||
verts.Add(it1);
|
||||
}
|
||||
}
|
||||
|
||||
InternalListPool<UIVertex>.Return(ref intersections);
|
||||
}
|
||||
|
||||
static bool DoesIntersect(UIVertex start, UIVertex end, Vector2 p, Vector2 dir, Matrix4x4 m,
|
||||
out UIVertex intersection)
|
||||
{
|
||||
intersection = default;
|
||||
var startPosition = (Vector2)m.MultiplyPoint3x4(start.position);
|
||||
var endPosition = (Vector2)m.MultiplyPoint3x4(end.position);
|
||||
var segDir = endPosition - startPosition;
|
||||
var cross = Vector3.Cross(segDir, dir);
|
||||
|
||||
// Parallel.
|
||||
if (cross.magnitude < Mathf.Epsilon)
|
||||
{
|
||||
return false; // 線と線分が平行
|
||||
}
|
||||
|
||||
var diff = p - startPosition;
|
||||
var determinant = Vector3.Dot(cross, cross);
|
||||
var t = Vector3.Dot(Vector3.Cross(diff, dir), cross) / determinant;
|
||||
|
||||
if (0 <= t && t <= 1)
|
||||
{
|
||||
intersection = VertexLerp(start, end, t);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c1b302b92b3d4460b4e61e5b0135668
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
@@ -7,6 +8,9 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
private Canvas m_Canvas;
|
||||
|
||||
[SerializeField]
|
||||
private RectMask2D m_Mask;
|
||||
|
||||
private UIEffectTweener[] _tweeners;
|
||||
private UIEffect[] _uiEffects;
|
||||
|
||||
@@ -14,6 +18,8 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
_tweeners = m_Canvas.GetComponentsInChildren<UIEffectTweener>(false);
|
||||
_uiEffects = m_Canvas.GetComponentsInChildren<UIEffect>(false);
|
||||
|
||||
m_Mask.enabled = true;
|
||||
}
|
||||
|
||||
public void SetEnableTweeners(bool flag)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Packages/src/Samples~/TextMeshPro Support (Unity 6)~/Hidden-TMP_Bitmap-Mobile-UIEffect-Unity6.shader
Executable
+192
@@ -0,0 +1,192 @@
|
||||
Shader "Hidden/TextMeshPro/Mobile/Bitmap (UIEffect)" {
|
||||
|
||||
Properties {
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_Color ("Text Color", Color) = (1,1,1,1)
|
||||
_DiffusePower ("Diffuse Power", Range(1.0,4.0)) = 1.0
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
|
||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
|
||||
_StencilComp ("Stencil Comparison", Float) = 8
|
||||
_Stencil ("Stencil ID", Float) = 0
|
||||
_StencilOp ("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
_CullMode ("Cull Mode", Float) = 0
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader {
|
||||
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
|
||||
Lighting Off
|
||||
Cull [_CullMode]
|
||||
ZTest [unity_GUIZTestMode]
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
// ==== UIEFFECT START ====
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
// ==== UIEFFECT END ====
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
#pragma shader_feature_local_fragment _ TONE_GRAYSCALE TONE_SEPIA TONE_NEGATIVE TONE_RETRO TONE_POSTERIZE
|
||||
#pragma shader_feature_local_fragment _ COLOR_MULTIPLY COLOR_ADDITIVE COLOR_SUBTRACTIVE COLOR_REPLACE COLOR_MULTIPLY_LUMINANCE COLOR_MULTIPLY_ADDITIVE COLOR_HSV_MODIFIER COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ SAMPLING_BLUR_FAST SAMPLING_BLUR_MEDIUM SAMPLING_BLUR_DETAIL SAMPLING_PIXELATION SAMPLING_RGB_SHIFT SAMPLING_EDGE_LUMINANCE SAMPLING_EDGE_ALPHA
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_COLOR_MULTIPLY TRANSITION_COLOR_ADDITIVE TRANSITION_COLOR_SUBTRACTIVE TRANSITION_COLOR_REPLACE TRANSITION_COLOR_MULTIPLY_LUMINANCE TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_COLOR_HSV_MODIFIER TRANSITION_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 mask : TEXCOORD2;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD3;
|
||||
float2 uvLocal : TEXCOORD4;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _Color;
|
||||
float _DiffusePower;
|
||||
|
||||
uniform float _VertexOffsetX;
|
||||
uniform float _VertexOffsetY;
|
||||
uniform float4 _ClipRect;
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
uniform float _UIMaskSoftnessX;
|
||||
uniform float _UIMaskSoftnessY;
|
||||
uniform int _UIVertexColorAlwaysGammaSpace;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f OUT;
|
||||
float4 vert = v.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
|
||||
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
|
||||
{
|
||||
v.color.rgb = UIGammaToLinear(v.color.rgb);
|
||||
}
|
||||
OUT.vertex = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
OUT.color = v.color;
|
||||
OUT.color *= _Color;
|
||||
OUT.color.rgb *= _DiffusePower;
|
||||
OUT.texcoord0 = v.texcoord0;
|
||||
|
||||
float2 pixelSize = OUT.vertex.w;
|
||||
//pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
|
||||
|
||||
// Clamp _ClipRect to 16bit.
|
||||
const float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
OUT.uvLocal = v.texcoord1.zw;
|
||||
OUT.uvMask = v.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// ==== UIEFFECT ====
|
||||
v2f _fragInput;
|
||||
fixed4 uieffect_frag(float2 uv)
|
||||
{
|
||||
v2f IN = _fragInput;
|
||||
float2 uvMove = uv - IN.texcoord0;
|
||||
fixed4 color = fixed4(IN.color.rgb, IN.color.a * tex2D(_MainTex, IN.texcoord0 + uvMove).a);
|
||||
return color;
|
||||
}
|
||||
#define UIEFFECT_TEXTMESHPRO 1
|
||||
#include "Packages/com.coffee.ui-effect/Shaders/UIEffect.cginc"
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
fixed4 frag (v2f IN) : COLOR
|
||||
{
|
||||
_fragInput = IN;
|
||||
half4 color = uieffect(_fragInput.texcoord0, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
|
||||
color *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
BindChannels {
|
||||
Bind "Color", color
|
||||
Bind "Vertex", vertex
|
||||
Bind "TexCoord", texcoord0
|
||||
}
|
||||
Pass {
|
||||
SetTexture [_MainTex] {
|
||||
constantColor [_Color] combine constant * primary, constant * texture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_BitmapShaderGUI"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 367310b4ca95c4b00a2215568f1af735
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Executable
+182
@@ -0,0 +1,182 @@
|
||||
Shader "Hidden/TextMeshPro/Bitmap (UIEffect)" {
|
||||
|
||||
Properties {
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_FaceTex ("Font Texture", 2D) = "white" {}
|
||||
_FaceColor ("Text Color", Color) = (1,1,1,1)
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
|
||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
|
||||
_StencilComp ("Stencil Comparison", Float) = 8
|
||||
_Stencil ("Stencil ID", Float) = 0
|
||||
_StencilOp ("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
_CullMode ("Cull Mode", Float) = 0
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader{
|
||||
|
||||
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
|
||||
Lighting Off
|
||||
Cull [_CullMode]
|
||||
ZTest [unity_GUIZTestMode]
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
// ==== UIEFFECT START ====
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
// ==== UIEFFECT END ====
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
#pragma shader_feature_local_fragment _ TONE_GRAYSCALE TONE_SEPIA TONE_NEGATIVE TONE_RETRO TONE_POSTERIZE
|
||||
#pragma shader_feature_local_fragment _ COLOR_MULTIPLY COLOR_ADDITIVE COLOR_SUBTRACTIVE COLOR_REPLACE COLOR_MULTIPLY_LUMINANCE COLOR_MULTIPLY_ADDITIVE COLOR_HSV_MODIFIER COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ SAMPLING_BLUR_FAST SAMPLING_BLUR_MEDIUM SAMPLING_BLUR_DETAIL SAMPLING_PIXELATION SAMPLING_RGB_SHIFT SAMPLING_EDGE_LUMINANCE SAMPLING_EDGE_ALPHA
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_COLOR_MULTIPLY TRANSITION_COLOR_ADDITIVE TRANSITION_COLOR_SUBTRACTIVE TRANSITION_COLOR_REPLACE TRANSITION_COLOR_MULTIPLY_LUMINANCE TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_COLOR_HSV_MODIFIER TRANSITION_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 mask : TEXCOORD2;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD3;
|
||||
float2 uvLocal : TEXCOORD4;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform sampler2D _FaceTex;
|
||||
uniform float4 _FaceTex_ST;
|
||||
uniform fixed4 _FaceColor;
|
||||
|
||||
uniform float _VertexOffsetX;
|
||||
uniform float _VertexOffsetY;
|
||||
uniform float4 _ClipRect;
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
uniform float _UIMaskSoftnessX;
|
||||
uniform float _UIMaskSoftnessY;
|
||||
uniform int _UIVertexColorAlwaysGammaSpace;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
float4 vert = v.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
|
||||
|
||||
float4 vPosition = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
|
||||
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
|
||||
{
|
||||
v.color.rgb = UIGammaToLinear(v.color.rgb);
|
||||
}
|
||||
fixed4 faceColor = v.color;
|
||||
faceColor *= _FaceColor;
|
||||
|
||||
v2f OUT;
|
||||
OUT.vertex = vPosition;
|
||||
OUT.color = faceColor;
|
||||
OUT.texcoord0 = v.texcoord0;
|
||||
OUT.texcoord1 = TRANSFORM_TEX(v.texcoord1, _FaceTex);
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
|
||||
|
||||
// Clamp _ClipRect to 16bit.
|
||||
const float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
OUT.uvLocal = v.texcoord1.zw;
|
||||
OUT.uvMask = v.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// ==== UIEFFECT ====
|
||||
v2f _fragInput;
|
||||
fixed4 uieffect_frag(float2 uv)
|
||||
{
|
||||
v2f IN = _fragInput;
|
||||
float2 uvMove = uv - IN.texcoord0;
|
||||
fixed4 color = tex2D(_MainTex, IN.texcoord0 + uvMove);
|
||||
color = fixed4 (tex2D(_FaceTex, IN.texcoord1).rgb * IN.color.rgb, IN.color.a * color.a);
|
||||
return color;
|
||||
}
|
||||
#define UIEFFECT_TEXTMESHPRO 1
|
||||
#include "Packages/com.coffee.ui-effect/Shaders/UIEffect.cginc"
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
fixed4 frag (v2f IN) : SV_Target
|
||||
{
|
||||
_fragInput = IN;
|
||||
half4 color = uieffect(_fragInput.texcoord0, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
|
||||
color *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_BitmapShaderGUI"
|
||||
}
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 490fe6c46146140cca8766a31c9dfc0c
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
Shader "Hidden/TextMeshPro/Mobile/Bitmap (UIEffect)" {
|
||||
|
||||
Properties {
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
[HDR]_Color ("Text Color", Color) = (1,1,1,1)
|
||||
_DiffusePower ("Diffuse Power", Range(1.0,4.0)) = 1.0
|
||||
|
||||
_VertexOffsetX("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY("Vertex OffsetY", float) = 0
|
||||
_MaskSoftnessX("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY("Mask SoftnessY", float) = 0
|
||||
|
||||
_ClipRect("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
|
||||
_StencilComp("Stencil Comparison", Float) = 8
|
||||
_Stencil("Stencil ID", Float) = 0
|
||||
_StencilOp("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask("Stencil Read Mask", Float) = 255
|
||||
|
||||
_CullMode("Cull Mode", Float) = 0
|
||||
_ColorMask("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader {
|
||||
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
|
||||
Lighting Off
|
||||
Cull [_CullMode]
|
||||
ZTest [unity_GUIZTestMode]
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
// ==== UIEFFECT START ====
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
// ==== UIEFFECT END ====
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
#pragma shader_feature_local_fragment _ TONE_GRAYSCALE TONE_SEPIA TONE_NEGATIVE TONE_RETRO TONE_POSTERIZE
|
||||
#pragma shader_feature_local_fragment _ COLOR_MULTIPLY COLOR_ADDITIVE COLOR_SUBTRACTIVE COLOR_REPLACE COLOR_MULTIPLY_LUMINANCE COLOR_MULTIPLY_ADDITIVE COLOR_HSV_MODIFIER COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ SAMPLING_BLUR_FAST SAMPLING_BLUR_MEDIUM SAMPLING_BLUR_DETAIL SAMPLING_PIXELATION SAMPLING_RGB_SHIFT SAMPLING_EDGE_LUMINANCE SAMPLING_EDGE_ALPHA
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_COLOR_MULTIPLY TRANSITION_COLOR_ADDITIVE TRANSITION_COLOR_SUBTRACTIVE TRANSITION_COLOR_REPLACE TRANSITION_COLOR_MULTIPLY_LUMINANCE TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_COLOR_HSV_MODIFIER TRANSITION_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ SHADOW_COLOR_MULTIPLY SHADOW_COLOR_ADDITIVE SHADOW_COLOR_SUBTRACTIVE SHADOW_COLOR_REPLACE SHADOW_COLOR_MULTIPLY_LUMINANCE SHADOW_COLOR_MULTIPLY_ADDITIVE SHADOW_COLOR_HSV_MODIFIER SHADOW_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 mask : TEXCOORD2;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD3;
|
||||
float2 uvLocal : TEXCOORD4;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _Color;
|
||||
float _DiffusePower;
|
||||
|
||||
uniform float _VertexOffsetX;
|
||||
uniform float _VertexOffsetY;
|
||||
uniform float4 _ClipRect;
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
v2f OUT;
|
||||
float4 vert = v.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
|
||||
|
||||
OUT.vertex = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
OUT.color = v.color;
|
||||
OUT.color *= _Color;
|
||||
OUT.color.rgb *= _DiffusePower;
|
||||
OUT.texcoord0 = v.texcoord0;
|
||||
|
||||
float2 pixelSize = OUT.vertex.w;
|
||||
//pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
|
||||
|
||||
// Clamp _ClipRect to 16bit.
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
OUT.uvLocal = v.texcoord1.zw;
|
||||
OUT.uvMask = v.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
|
||||
// ==== UIEFFECT ====
|
||||
v2f _fragInput;
|
||||
fixed4 uieffect_frag(float2 uv)
|
||||
{
|
||||
v2f IN = _fragInput;
|
||||
float2 uvMove = uv - IN.texcoord0;
|
||||
fixed4 color = fixed4(IN.color.rgb, IN.color.a * tex2D(_MainTex, IN.texcoord0 + uvMove).a);
|
||||
return color * color.a;
|
||||
}
|
||||
|
||||
#define UIEFFECT_TEXTMESHPRO 1
|
||||
#include "Packages/com.coffee.ui-effect/Shaders/UIEffect.cginc"
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
fixed4 frag (v2f IN) : COLOR
|
||||
{
|
||||
_fragInput = IN;
|
||||
fixed4 color = uieffect(_fragInput.texcoord0, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
|
||||
color *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
BindChannels {
|
||||
Bind "Color", color
|
||||
Bind "Vertex", vertex
|
||||
Bind "TexCoord", texcoord0
|
||||
}
|
||||
Pass {
|
||||
SetTexture [_MainTex] {
|
||||
constantColor [_Color] combine constant * primary, constant * texture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_BitmapShaderGUI"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63a1dba10bff94661a909d63808a9a3b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
Shader "Hidden/TextMeshPro/Bitmap (UIEffect)" {
|
||||
|
||||
Properties {
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_FaceTex ("Font Texture", 2D) = "white" {}
|
||||
[HDR]_FaceColor ("Text Color", Color) = (1,1,1,1)
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
|
||||
_ClipRect("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
|
||||
_StencilComp("Stencil Comparison", Float) = 8
|
||||
_Stencil("Stencil ID", Float) = 0
|
||||
_StencilOp("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask("Stencil Read Mask", Float) = 255
|
||||
|
||||
_CullMode("Cull Mode", Float) = 0
|
||||
_ColorMask("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader{
|
||||
|
||||
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
|
||||
Lighting Off
|
||||
Cull [_CullMode]
|
||||
ZTest [unity_GUIZTestMode]
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
// ==== UIEFFECT START ====
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
// ==== UIEFFECT END ====
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
#pragma shader_feature_local_fragment _ TONE_GRAYSCALE TONE_SEPIA TONE_NEGATIVE TONE_RETRO TONE_POSTERIZE
|
||||
#pragma shader_feature_local_fragment _ COLOR_MULTIPLY COLOR_ADDITIVE COLOR_SUBTRACTIVE COLOR_REPLACE COLOR_MULTIPLY_LUMINANCE COLOR_MULTIPLY_ADDITIVE COLOR_HSV_MODIFIER COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ SAMPLING_BLUR_FAST SAMPLING_BLUR_MEDIUM SAMPLING_BLUR_DETAIL SAMPLING_PIXELATION SAMPLING_RGB_SHIFT SAMPLING_EDGE_LUMINANCE SAMPLING_EDGE_ALPHA
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_COLOR_MULTIPLY TRANSITION_COLOR_ADDITIVE TRANSITION_COLOR_SUBTRACTIVE TRANSITION_COLOR_REPLACE TRANSITION_COLOR_MULTIPLY_LUMINANCE TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_COLOR_HSV_MODIFIER TRANSITION_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ SHADOW_COLOR_MULTIPLY SHADOW_COLOR_ADDITIVE SHADOW_COLOR_SUBTRACTIVE SHADOW_COLOR_REPLACE SHADOW_COLOR_MULTIPLY_LUMINANCE SHADOW_COLOR_MULTIPLY_ADDITIVE SHADOW_COLOR_HSV_MODIFIER SHADOW_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 mask : TEXCOORD2;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD3;
|
||||
float2 uvLocal : TEXCOORD4;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform sampler2D _FaceTex;
|
||||
uniform float4 _FaceTex_ST;
|
||||
uniform fixed4 _FaceColor;
|
||||
|
||||
uniform float _VertexOffsetX;
|
||||
uniform float _VertexOffsetY;
|
||||
uniform float4 _ClipRect;
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
|
||||
float2 UnpackUV(float uv)
|
||||
{
|
||||
float2 output;
|
||||
output.x = floor(uv / 4096);
|
||||
output.y = uv - 4096 * output.x;
|
||||
|
||||
return output * 0.001953125;
|
||||
}
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
float4 vert = v.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
|
||||
|
||||
float4 vPosition = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
|
||||
fixed4 faceColor = v.color;
|
||||
faceColor *= _FaceColor;
|
||||
|
||||
v2f OUT;
|
||||
OUT.vertex = vPosition;
|
||||
OUT.color = faceColor;
|
||||
OUT.texcoord0 = v.texcoord0;
|
||||
OUT.texcoord1 = TRANSFORM_TEX(UnpackUV(v.texcoord1.xy), _FaceTex);
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
|
||||
|
||||
// Clamp _ClipRect to 16bit.
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
OUT.uvLocal = v.texcoord1.zw;
|
||||
OUT.uvMask = v.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// ==== UIEFFECT ====
|
||||
v2f _fragInput;
|
||||
fixed4 uieffect_frag(float2 uv)
|
||||
{
|
||||
v2f IN = _fragInput;
|
||||
float2 uvMove = uv - IN.texcoord0;
|
||||
fixed4 color = tex2D(_MainTex, IN.texcoord0 + uvMove);
|
||||
color = fixed4 (tex2D(_FaceTex, IN.texcoord1).rgb * IN.color.rgb, IN.color.a * color.a);
|
||||
return color * color.a;
|
||||
}
|
||||
|
||||
#define UIEFFECT_TEXTMESHPRO 1
|
||||
#include "Packages/com.coffee.ui-effect/Shaders/UIEffect.cginc"
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
fixed4 frag (v2f IN) : SV_Target
|
||||
{
|
||||
_fragInput = IN;
|
||||
fixed4 color = uieffect(_fragInput.texcoord0, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
|
||||
color *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_BitmapShaderGUI"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1cb940e3804b4adcaf9b22083fadfad
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -102,6 +102,7 @@ SubShader {
|
||||
#pragma shader_feature_local_fragment _ SAMPLING_BLUR_FAST SAMPLING_BLUR_MEDIUM SAMPLING_BLUR_DETAIL SAMPLING_PIXELATION SAMPLING_RGB_SHIFT SAMPLING_EDGE_LUMINANCE SAMPLING_EDGE_ALPHA
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_COLOR_MULTIPLY TRANSITION_COLOR_ADDITIVE TRANSITION_COLOR_SUBTRACTIVE TRANSITION_COLOR_REPLACE TRANSITION_COLOR_MULTIPLY_LUMINANCE TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_COLOR_HSV_MODIFIER TRANSITION_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ SHADOW_COLOR_MULTIPLY SHADOW_COLOR_ADDITIVE SHADOW_COLOR_SUBTRACTIVE SHADOW_COLOR_REPLACE SHADOW_COLOR_MULTIPLY_LUMINANCE SHADOW_COLOR_MULTIPLY_ADDITIVE SHADOW_COLOR_HSV_MODIFIER SHADOW_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
|
||||
@@ -135,6 +135,7 @@ SubShader {
|
||||
#pragma shader_feature_local_fragment _ SAMPLING_BLUR_FAST SAMPLING_BLUR_MEDIUM SAMPLING_BLUR_DETAIL SAMPLING_PIXELATION SAMPLING_RGB_SHIFT SAMPLING_EDGE_LUMINANCE SAMPLING_EDGE_ALPHA
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_COLOR_MULTIPLY TRANSITION_COLOR_ADDITIVE TRANSITION_COLOR_SUBTRACTIVE TRANSITION_COLOR_REPLACE TRANSITION_COLOR_MULTIPLY_LUMINANCE TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_COLOR_HSV_MODIFIER TRANSITION_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ SHADOW_COLOR_MULTIPLY SHADOW_COLOR_ADDITIVE SHADOW_COLOR_SUBTRACTIVE SHADOW_COLOR_REPLACE SHADOW_COLOR_MULTIPLY_LUMINANCE SHADOW_COLOR_MULTIPLY_ADDITIVE SHADOW_COLOR_HSV_MODIFIER SHADOW_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
{
|
||||
RectTransform,
|
||||
Fit,
|
||||
Character,
|
||||
Character
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,14 @@ namespace Coffee.UIEffects
|
||||
Horizontal,
|
||||
Vertical,
|
||||
Angle,
|
||||
Diagonal,
|
||||
Diagonal
|
||||
}
|
||||
|
||||
public enum GradientStyle
|
||||
{
|
||||
Rect,
|
||||
Fit,
|
||||
Split,
|
||||
Split
|
||||
}
|
||||
|
||||
[Tooltip("Gradient Direction.")]
|
||||
|
||||
@@ -45,14 +45,24 @@ namespace Coffee.UIEffects
|
||||
set
|
||||
{
|
||||
if (value.x > k_KMaxEffectDistance)
|
||||
{
|
||||
value.x = k_KMaxEffectDistance;
|
||||
}
|
||||
|
||||
if (value.x < -k_KMaxEffectDistance)
|
||||
{
|
||||
value.x = -k_KMaxEffectDistance;
|
||||
}
|
||||
|
||||
if (value.y > k_KMaxEffectDistance)
|
||||
{
|
||||
value.y = k_KMaxEffectDistance;
|
||||
}
|
||||
|
||||
if (value.y < -k_KMaxEffectDistance)
|
||||
{
|
||||
value.y = -k_KMaxEffectDistance;
|
||||
}
|
||||
|
||||
if (m_EffectDistance == value) return;
|
||||
m_EffectDistance = value;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Coffee.UIEffects
|
||||
[FormerlySerializedAs("m_NoiseTexture")]
|
||||
private Texture m_TransitionTexture;
|
||||
|
||||
[SerializeField]
|
||||
[SerializeField]
|
||||
private EffectArea m_EffectArea = EffectArea.RectTransform;
|
||||
|
||||
[Tooltip("Keep effect aspect ratio.")]
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace Coffee.UIEffects
|
||||
effectFactor = rate;
|
||||
}
|
||||
|
||||
if (colorMode != ColorMode.Multiply && 0 < (mask & UIEffectTweener.CullingMask.Color))
|
||||
if (colorMode != ColorMode.Multiply && 0 < (mask & UIEffectTweener.CullingMask.Color))
|
||||
{
|
||||
colorFactor = rate;
|
||||
}
|
||||
|
||||
@@ -5,17 +5,23 @@ uniform float4 _MainTex_TexelSize;
|
||||
uniform float _ToneIntensity;
|
||||
uniform half4 _ColorValue;
|
||||
uniform float _ColorIntensity;
|
||||
uniform int _ColorGlow;
|
||||
uniform float _SamplingIntensity;
|
||||
uniform float _SamplingScale;
|
||||
uniform sampler2D _TransitionTex;
|
||||
uniform float4 _TransitionTex_ST;
|
||||
uniform float _TransitionRate;
|
||||
uniform int _TransitionReverse;
|
||||
uniform half4 _TransitionColor;
|
||||
uniform int _TransitionColorGlow;
|
||||
uniform float _TransitionSoftness;
|
||||
uniform float _TransitionWidth;
|
||||
uniform fixed4 _TargetColor;
|
||||
uniform float _TargetRange;
|
||||
uniform float _TargetSoftness;
|
||||
uniform float _ShadowBlurIntensity;
|
||||
uniform half4 _ShadowColor;
|
||||
uniform int _ShadowColorGlow;
|
||||
|
||||
// For performance reasons, limit the sampling of blur in TextMeshPro.
|
||||
#ifdef UIEFFECT_TEXTMESHPRO
|
||||
@@ -30,10 +36,8 @@ uniform float _TargetSoftness;
|
||||
#endif
|
||||
|
||||
#define TONE_NONE (!TONE_GRAYSCALE && !TONE_SEPIA && !TONE_NEGATIVE && !TONE_RETRO && !TONE_POSTERIZE)
|
||||
#define COLOR_NONE (!COLOR_MULTIPLY && !COLOR_ADDITIVE && !COLOR_SUBTRACTIVE && !COLOR_REPLACE && !COLOR_MULTIPLY_LUMINANCE && !COLOR_MULTIPLY_ADDITIVE && !COLOR_HSV_MODIFIER && !COLOR_CONTRAST)
|
||||
#define SAMPLING_NONE (!SAMPLING_BLUR_FAST && !SAMPLING_BLUR_MEDIUM && !SAMPLING_BLUR_DETAIL && !SAMPLING_PIXELATION && !SAMPLING_RGB_SHIFT && !SAMPLING_EDGE)
|
||||
#define TRANSITION_NONE (!TRANSITION_FADE && !TRANSITION_CUTOFF && !TRANSITION_DISSOLVE && !TRANSITION_SHINY && !TRANSITION_MASK && !TRANSITION_MELT && !TRANSITION_BURN)
|
||||
#define TRANSITION_COLOR_NONE (!TRANSITION_COLOR_MULTIPLY && !TRANSITION_COLOR_ADDITIVE && !TRANSITION_COLOR_SUBTRACTIVE && !TRANSITION_COLOR_REPLACE && !TRANSITION_COLOR_MULTIPLY_LUMINANCE && !TRANSITION_COLOR_MULTIPLY_ADDITIVE && !TRANSITION_COLOR_HSV_MODIFIER && !TRANSITION_COLOR_CONTRAST)
|
||||
#define TARGET_NONE (!TARGET_HUE && !TARGET_LUMINANCE)
|
||||
|
||||
#define UIEFFECT_SAMPLE(uv) uieffect_frag(uv)
|
||||
@@ -41,6 +45,11 @@ uniform float _TargetSoftness;
|
||||
* step(uvMask.x, uv.x) * step(uv.x, uvMask.z) \
|
||||
* step(uvMask.y, uv.y) * step(uv.y, uvMask.w)
|
||||
|
||||
float2 texel_size()
|
||||
{
|
||||
return _MainTex_TexelSize.xy * _SamplingScale;
|
||||
}
|
||||
|
||||
float3 rgb_to_hsv(float3 c)
|
||||
{
|
||||
const float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
@@ -133,11 +142,7 @@ half4 apply_tone_filter(half4 color)
|
||||
half4 apply_color_filter(half4 color, const half4 factor, const float intensity)
|
||||
{
|
||||
const half4 inColor = color;
|
||||
#if COLOR_NONE // Color.None
|
||||
{
|
||||
return color;
|
||||
}
|
||||
#elif COLOR_MULTIPLY // Color.Multiply
|
||||
#if COLOR_MULTIPLY // Color.Multiply
|
||||
{
|
||||
color.rgb = color.rgb * factor.rgb;
|
||||
}
|
||||
@@ -172,19 +177,20 @@ half4 apply_color_filter(half4 color, const half4 factor, const float intensity)
|
||||
color.rgb = ((color.rgb - 0.5) * (factor.r + 1) + 0.5 + factor.g * 1.5) * color.a * factor.a;
|
||||
color.a = color.a * factor.a;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return color;
|
||||
}
|
||||
#endif
|
||||
return lerp(inColor, color, intensity);
|
||||
color = lerp(inColor, color, intensity);
|
||||
color.a *= 1 - _ColorGlow;
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
half4 apply_transition_color_filter(half4 color, const half4 factor, const float intensity)
|
||||
{
|
||||
const half4 inColor = color;
|
||||
#if TRANSITION_COLOR_NONE // Color.None
|
||||
{
|
||||
return color;
|
||||
}
|
||||
#elif TRANSITION_COLOR_MULTIPLY // Color.Multiply
|
||||
#if TRANSITION_COLOR_MULTIPLY // Color.Multiply
|
||||
{
|
||||
color.rgb = color.rgb * factor.rgb;
|
||||
}
|
||||
@@ -219,15 +225,74 @@ half4 apply_transition_color_filter(half4 color, const half4 factor, const float
|
||||
color.rgb = ((color.rgb - 0.5) * (factor.r + 1) + 0.5 + factor.g * 1.5) * color.a * factor.a;
|
||||
color.a = color.a * factor.a;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return color;
|
||||
}
|
||||
#endif
|
||||
return lerp(inColor, color, intensity);
|
||||
color = lerp(inColor, color, intensity);
|
||||
color.a *= 1 - _TransitionColorGlow;
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_shadow_color_filter(half4 color, const half4 factor, const float intensity)
|
||||
{
|
||||
const half4 inColor = color;
|
||||
#if SHADOW_COLOR_NONE // Color.None
|
||||
{
|
||||
return color;
|
||||
}
|
||||
#elif SHADOW_COLOR_MULTIPLY // Color.Multiply
|
||||
{
|
||||
color.rgb = color.rgb * factor.rgb;
|
||||
}
|
||||
#elif SHADOW_COLOR_ADDITIVE // Color.Additive
|
||||
{
|
||||
color.rgb = color.rgb + factor.rgb * color.a;
|
||||
}
|
||||
#elif SHADOW_COLOR_SUBTRACTIVE // Color.Subtractive
|
||||
{
|
||||
color.rgb = color.rgb - factor.rgb * color.a;
|
||||
}
|
||||
#elif SHADOW_COLOR_REPLACE // Color.Replace
|
||||
{
|
||||
color.rgb = factor.rgb * color.a;
|
||||
}
|
||||
#elif SHADOW_COLOR_MULTIPLY_LUMINANCE // Color.MultiplyLuminance
|
||||
{
|
||||
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
|
||||
}
|
||||
#elif SHADOW_COLOR_MULTIPLY_ADDITIVE // Color.MultiplyAdditive
|
||||
{
|
||||
color.rgb = color.rgb * (1 + factor.rgb);
|
||||
}
|
||||
#elif SHADOW_COLOR_HSV_MODIFIER // Color.HsvModifier
|
||||
{
|
||||
const float3 hsv = rgb_to_hsv(color.rgb);
|
||||
color.rgb = hsv_to_rgb(hsv + factor.rgb) * color.a * factor.a;
|
||||
color.a = color.a * factor.a;
|
||||
}
|
||||
#elif SHADOW_COLOR_CONTRAST // Color.Contrast
|
||||
{
|
||||
color.rgb = ((color.rgb - 0.5) * (factor.r + 1) + 0.5 + factor.g * 1.5) * color.a * factor.a;
|
||||
color.a = color.a * factor.a;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return color;
|
||||
}
|
||||
#endif
|
||||
color = lerp(inColor, color, intensity);
|
||||
color.a *= 1 - _ShadowColorGlow;
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_sampling_filter(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
{
|
||||
#if SAMPLING_BLUR_FAST || SAMPLING_BLUR_MEDIUM || SAMPLING_BLUR_DETAIL
|
||||
{
|
||||
if (0 < _SamplingIntensity && -4 < uvLocal.x + uvLocal.y)
|
||||
float intensity = -4 < uvLocal.x + uvLocal.y ? _SamplingIntensity : _ShadowBlurIntensity;
|
||||
if (0 < intensity)
|
||||
{
|
||||
#if SAMPLING_BLUR_FAST
|
||||
const int KERNEL_SIZE = 5;
|
||||
@@ -243,7 +308,7 @@ half4 apply_sampling_filter(float2 uv, const float4 uvMask, const float2 uvLocal
|
||||
float4 o = 0;
|
||||
float sum = 0;
|
||||
float2 shift = 0;
|
||||
const half2 blur = _MainTex_TexelSize.xy * _SamplingIntensity * 2;
|
||||
const half2 blur = texel_size() * intensity * 2;
|
||||
for (int x = 0; x < KERNEL_SIZE; x++)
|
||||
{
|
||||
shift.x = blur.x * (float(x) - KERNEL_SIZE / 2);
|
||||
@@ -307,18 +372,15 @@ half4 apply_transition_filter(half4 color, const float alpha)
|
||||
{
|
||||
const float factor = alpha - _TransitionRate * (1 + _TransitionWidth) + _TransitionWidth;
|
||||
const float softness = max(0.0001, _TransitionWidth * _TransitionSoftness);
|
||||
// const fixed bandLerp = step(factor, color.a) * saturate((_TransitionWidth - factor) * 1 / softness);
|
||||
const fixed bandLerp = saturate((_TransitionWidth - factor) * 1 / softness);
|
||||
const fixed softLerp = saturate(factor * 2 / softness);
|
||||
half4 bandColor = apply_transition_color_filter(half4(color.rgb, 1), half4(_TransitionColor.rgb, 1),
|
||||
_TransitionColor.a);
|
||||
// bandColor.a *= color.a;
|
||||
bandColor *= color.a;
|
||||
|
||||
#if TRANSITION_MELT
|
||||
{
|
||||
color = lerp(color, bandColor, bandLerp);
|
||||
// return color * color.a;
|
||||
return color;
|
||||
}
|
||||
#elif TRANSITION_BURN
|
||||
@@ -328,9 +390,13 @@ half4 apply_transition_filter(half4 color, const float alpha)
|
||||
color.rgb *= (1 - inv_lerp(0.85, 1.0, bandLerp * 1.3)) * color.a;
|
||||
return color;
|
||||
}
|
||||
#elif TRANSITION_SHINY && UIEFFECT_TEXTMESHPRO
|
||||
{
|
||||
color.rgb *= color.a;
|
||||
}
|
||||
#endif
|
||||
|
||||
color.rgb = lerp(color.rgb, bandColor, bandLerp * softLerp);
|
||||
color = lerp(color, bandColor, bandLerp * softLerp);
|
||||
|
||||
#if TRANSITION_DISSOLVE
|
||||
{
|
||||
@@ -369,6 +435,10 @@ half4 uieffect_internal(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
{
|
||||
color = apply_color_filter(color, _ColorValue, _ColorIntensity);
|
||||
}
|
||||
else
|
||||
{
|
||||
color = apply_shadow_color_filter(color, _ShadowColor, 1);
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
@@ -381,13 +451,13 @@ half4 uieffect(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
// Sampling.Pixelation
|
||||
#if SAMPLING_PIXELATION
|
||||
{
|
||||
const half2 pixelSize = max(2, (1 - lerp(0.5, 0.95, _SamplingIntensity)) * _MainTex_TexelSize.zw);
|
||||
const half2 pixelSize = max(2, (1 - lerp(0.5, 0.95, _SamplingIntensity)) / texel_size());
|
||||
uv = round(uv * pixelSize) / pixelSize;
|
||||
}
|
||||
// Sampling.RgbShift
|
||||
#elif SAMPLING_RGB_SHIFT
|
||||
{
|
||||
const half2 offset = half2(_SamplingIntensity * _MainTex_TexelSize.x * 20, 0);
|
||||
const half2 offset = half2(_SamplingIntensity * texel_size().x * 20, 0);
|
||||
const half2 r = uieffect_internal(uv + offset, uvMask, uvLocal).ra;
|
||||
const half2 g = uieffect_internal(uv, uvMask, uvLocal).ga;
|
||||
const half2 b = uieffect_internal(uv - offset, uvMask, uvLocal).ba;
|
||||
@@ -397,8 +467,8 @@ half4 uieffect(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
#elif SAMPLING_EDGE_LUMINANCE || SAMPLING_EDGE_ALPHA
|
||||
{
|
||||
// Pixel size
|
||||
const float dx = _MainTex_TexelSize.x;
|
||||
const float dy = _MainTex_TexelSize.y;
|
||||
const float dx = texel_size().x;
|
||||
const float dy = texel_size().y;
|
||||
|
||||
// Pixel values around the current pixel (3x3, 8 neighbors)
|
||||
const float2 uv00 = uv + half2(-dx, -dy);
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#pragma shader_feature_local_fragment _ SAMPLING_BLUR_FAST SAMPLING_BLUR_MEDIUM SAMPLING_BLUR_DETAIL SAMPLING_PIXELATION SAMPLING_RGB_SHIFT SAMPLING_EDGE_LUMINANCE SAMPLING_EDGE_ALPHA
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_COLOR_MULTIPLY TRANSITION_COLOR_ADDITIVE TRANSITION_COLOR_SUBTRACTIVE TRANSITION_COLOR_REPLACE TRANSITION_COLOR_MULTIPLY_LUMINANCE TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_COLOR_HSV_MODIFIER TRANSITION_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ SHADOW_COLOR_MULTIPLY SHADOW_COLOR_ADDITIVE SHADOW_COLOR_SUBTRACTIVE SHADOW_COLOR_REPLACE SHADOW_COLOR_MULTIPLY_LUMINANCE SHADOW_COLOR_MULTIPLY_ADDITIVE SHADOW_COLOR_HSV_MODIFIER SHADOW_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
@@ -126,8 +127,12 @@
|
||||
}
|
||||
|
||||
OUT.color = v.color * _Color;
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
OUT.uvMask = v.uvMask;
|
||||
OUT.uvLocal = v.texcoord.zw;
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "com.coffee.ui-effect",
|
||||
"displayName": "UI Effect",
|
||||
"description": "UIEffect is an open-source package that allows you to intuitively apply rich UI effects directly from the Inspector or via code.\nCombine various filters, such as grayscale, blur, and dissolve, to decorate your UI with a unique visual style!",
|
||||
"version": "5.0.1",
|
||||
"version": "5.2.0",
|
||||
"unity": "2020.3",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
|
||||
@@ -11,6 +11,9 @@ EditorBuildSettings:
|
||||
- enabled: 1
|
||||
path: Assets/Samples/Demo/UIEffect_Showcase.unity
|
||||
guid: 96317674ad83b4b38b0b7c9e3402bfd3
|
||||
- enabled: 1
|
||||
path: Assets/Demos/UIEffectTweenerControl/UIEffectTweenerControl.unity
|
||||
guid: dda1700a67f894a5cafc5d16748cf4fb
|
||||
- enabled: 1
|
||||
path: Assets/Demos/TextMeshPro Support/TextMeshProSupport.unity
|
||||
guid: b29fc66cd80684c2d903f2d65255b59b
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"MonoBehaviour": {
|
||||
"m_Enabled": true,
|
||||
"m_EditorHideFlags": 0,
|
||||
"m_Name": "",
|
||||
"m_EditorClassIdentifier": "",
|
||||
"m_OutputDllPaths": [
|
||||
"Packages/com.coffee.ui-effect/Runtime/Coffee.UIEffect.R.dll"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user