mirror of
https://github.com/FriendshipIsEpic/FiE-Game.git
synced 2024-11-21 21:37:59 +01:00
Added TextMesh Pro library.
This commit is contained in:
parent
cdcb4f1781
commit
bba5df547d
160 changed files with 41142 additions and 0 deletions
8
Assets/TextMesh Pro/Documentation.meta
Normal file
8
Assets/TextMesh Pro/Documentation.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8e7e8f5a82a3a134e91c54efd2274ea9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/TextMesh Pro/Plugins/32 Bit Plugins.meta
Normal file
9
Assets/TextMesh Pro/Plugins/32 Bit Plugins.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 127501ed38d9403f99fe6899c4781082
|
||||
folderAsset: yes
|
||||
timeCreated: 1436068007
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/TextMesh Pro/Plugins/32 Bit Plugins/TMPro_Plugin.bundle
Normal file
BIN
Assets/TextMesh Pro/Plugins/32 Bit Plugins/TMPro_Plugin.bundle
Normal file
Binary file not shown.
|
@ -0,0 +1,59 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9a48e6486f534537a288ea36be1739ed
|
||||
folderAsset: yes
|
||||
timeCreated: 1451123182
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
platformData:
|
||||
Android:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
DefaultValueInitialized: true
|
||||
OS: OSX
|
||||
Linux:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
Linux64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
OSXIntel:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OSXIntel64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Win:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Win64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
WindowsStoreApps:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/TextMesh Pro/Plugins/32 Bit Plugins/TMPro_Plugin.dll
Normal file
BIN
Assets/TextMesh Pro/Plugins/32 Bit Plugins/TMPro_Plugin.dll
Normal file
Binary file not shown.
|
@ -0,0 +1,58 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8b4cc49ebfc64897a7e5c979f19d1cc4
|
||||
timeCreated: 1450988627
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
platformData:
|
||||
Android:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86
|
||||
DefaultValueInitialized: true
|
||||
OS: Windows
|
||||
Linux:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
Linux64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
OSXIntel:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OSXIntel64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Win:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Win64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
WindowsStoreApps:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/TextMesh Pro/Plugins/64 Bit Plugins.meta
Normal file
9
Assets/TextMesh Pro/Plugins/64 Bit Plugins.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f0fec68172b84dae8d5407bc0702a509
|
||||
folderAsset: yes
|
||||
timeCreated: 1436068007
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/TextMesh Pro/Plugins/64 Bit Plugins/TMPro_Plugin.bundle
Normal file
BIN
Assets/TextMesh Pro/Plugins/64 Bit Plugins/TMPro_Plugin.bundle
Normal file
Binary file not shown.
|
@ -0,0 +1,59 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7e59c7317e51470a833219e69cdeec75
|
||||
folderAsset: yes
|
||||
timeCreated: 1451123209
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
platformData:
|
||||
Android:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
DefaultValueInitialized: true
|
||||
OS: OSX
|
||||
Linux:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
Linux64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
OSXIntel:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OSXIntel64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Win:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Win64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
WindowsStoreApps:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/TextMesh Pro/Plugins/64 Bit Plugins/TMPro_Plugin.dll
Normal file
BIN
Assets/TextMesh Pro/Plugins/64 Bit Plugins/TMPro_Plugin.dll
Normal file
Binary file not shown.
|
@ -0,0 +1,58 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7c20856617c24cf99a5212838cacc239
|
||||
timeCreated: 1450987494
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
platformData:
|
||||
Android:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: x86_64
|
||||
DefaultValueInitialized: true
|
||||
OS: Windows
|
||||
Linux:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
Linux64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
OSXIntel:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OSXIntel64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Win:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Win64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
WindowsStoreApps:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
ScriptingBackend: AnyScriptingBackend
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/TextMesh Pro/Plugins/vcomp120.dll
Normal file
BIN
Assets/TextMesh Pro/Plugins/vcomp120.dll
Normal file
Binary file not shown.
66
Assets/TextMesh Pro/Plugins/vcomp120.dll.meta
Normal file
66
Assets/TextMesh Pro/Plugins/vcomp120.dll.meta
Normal file
|
@ -0,0 +1,66 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d40e85137bc74864a47f42ceddfec228
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
platformData:
|
||||
Android:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
Linux:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86
|
||||
Linux64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: x86_64
|
||||
OSXIntel:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
OSXIntel64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
WP8:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
Win:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
Win64:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
WindowsStoreApps:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DontProcess: False
|
||||
PlaceholderPath:
|
||||
SDK: AnySDK
|
||||
iOS:
|
||||
enabled: 0
|
||||
settings:
|
||||
CompileFlags:
|
||||
FrameworkDependencies:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/TextMesh Pro/Resources.meta
Normal file
8
Assets/TextMesh Pro/Resources.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 243e06394e614e5d99fab26083b707fa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/TextMesh Pro/Resources/Fonts & Materials.meta
Normal file
9
Assets/TextMesh Pro/Resources/Fonts & Materials.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 731f1baa9d144a9897cb1d341c2092b8
|
||||
folderAsset: yes
|
||||
timeCreated: 1442040525
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,103 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: LiberationSans SDF - Drop Shadow
|
||||
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
|
||||
m_ShaderKeywords: OUTLINE_ON UNDERLAY_ON
|
||||
m_LightmapFlags: 5
|
||||
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: 2846298, guid: 8f586378b4e144a9851e7b34d9b748ee, 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_Floats:
|
||||
- _Ambient: 0.5
|
||||
- _Bevel: 0.5
|
||||
- _BevelClamp: 0
|
||||
- _BevelOffset: 0
|
||||
- _BevelRoundness: 0
|
||||
- _BevelWidth: 0
|
||||
- _BumpFace: 0
|
||||
- _BumpOutline: 0
|
||||
- _ColorMask: 15
|
||||
- _Diffuse: 0.5
|
||||
- _DiffusePower: 1
|
||||
- _FaceDilate: 0.1
|
||||
- _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.1
|
||||
- _PerspectiveFilter: 0.875
|
||||
- _Reflectivity: 10
|
||||
- _ScaleRatioA: 0.9
|
||||
- _ScaleRatioB: 0.73125
|
||||
- _ScaleRatioC: 0.64125
|
||||
- _ScaleX: 1
|
||||
- _ScaleY: 1
|
||||
- _ShaderFlags: 0
|
||||
- _SpecularPower: 2
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _TextureHeight: 1024
|
||||
- _TextureWidth: 1024
|
||||
- _UnderlayDilate: 0
|
||||
- _UnderlayOffsetX: 0.5
|
||||
- _UnderlayOffsetY: -0.5
|
||||
- _UnderlaySoftness: 0.05
|
||||
- _VertexOffsetX: 0
|
||||
- _VertexOffsetY: 0
|
||||
- _WeightBold: 0.75
|
||||
- _WeightNormal: 0
|
||||
m_Colors:
|
||||
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _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}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e73a58f6e2794ae7b1b7e50b7fb811b0
|
||||
timeCreated: 1484172806
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,101 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: LiberationSans SDF - Outline
|
||||
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
|
||||
m_ShaderKeywords: OUTLINE_ON
|
||||
m_LightmapFlags: 5
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
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: 2846298, guid: 8f586378b4e144a9851e7b34d9b748ee, 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_Floats:
|
||||
- _Ambient: 0.5
|
||||
- _Bevel: 0.5
|
||||
- _BevelClamp: 0
|
||||
- _BevelOffset: 0
|
||||
- _BevelRoundness: 0
|
||||
- _BevelWidth: 0
|
||||
- _BumpFace: 0
|
||||
- _BumpOutline: 0
|
||||
- _ColorMask: 15
|
||||
- _Diffuse: 0.5
|
||||
- _FaceDilate: 0.1
|
||||
- _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.1
|
||||
- _PerspectiveFilter: 0.875
|
||||
- _Reflectivity: 10
|
||||
- _ScaleRatioA: 0.9
|
||||
- _ScaleRatioB: 0.73125
|
||||
- _ScaleRatioC: 0.64125
|
||||
- _ScaleX: 1
|
||||
- _ScaleY: 1
|
||||
- _ShaderFlags: 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}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 79459efec17a4d00a321bdcc27bbc385
|
||||
timeCreated: 1484172856
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8f586378b4e144a9851e7b34d9b748ee
|
||||
timeCreated: 1484171803
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1 @@
|
|||
)]}〕〉》」』】〙〗〟’”⦆»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻‐゠–〜?!‼⁇⁈⁉・、%,.:;。!?]):;=}¢°"†‡℃〆%,.
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fade42e8bc714b018fac513c043d323b
|
||||
timeCreated: 1425440388
|
||||
licenseType: Store
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1 @@
|
|||
([{〔〈《「『【〘〖〝‘“⦅«$—…‥〳〴〵\[({£¥"々〇〉》」$⦆¥₩ #
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d82c1b31c7e74239bff1220585707d2b
|
||||
timeCreated: 1425440388
|
||||
licenseType: Store
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/TextMesh Pro/Resources/Shaders.meta
Normal file
9
Assets/TextMesh Pro/Resources/Shaders.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 99f836c9cb9345dba2e72c4a1f2d0695
|
||||
folderAsset: yes
|
||||
timeCreated: 1436068007
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
143
Assets/TextMesh Pro/Resources/Shaders/TMP_Bitmap-Mobile.shader
Normal file
143
Assets/TextMesh Pro/Resources/Shaders/TMP_Bitmap-Mobile.shader
Normal file
|
@ -0,0 +1,143 @@
|
|||
Shader "TextMeshPro/Mobile/Bitmap" {
|
||||
|
||||
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
|
||||
|
||||
_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 Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
ZWrite Off
|
||||
Fog { Mode Off }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
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"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 mask : TEXCOORD2;
|
||||
};
|
||||
|
||||
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 o;
|
||||
float4 vert = v.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
|
||||
|
||||
o.vertex = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
o.color = v.color;
|
||||
o.color *= _Color;
|
||||
o.color.rgb *= _DiffusePower;
|
||||
o.texcoord0 = v.texcoord0;
|
||||
|
||||
float2 pixelSize = o.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);
|
||||
o.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : COLOR
|
||||
{
|
||||
fixed4 c = fixed4(i.color.rgb, i.color.a * tex2D(_MainTex, i.texcoord0).a);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(i.mask.xy)) * i.mask.zw);
|
||||
c *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(c.a - 0.001);
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
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"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1e3b057af24249748ff873be7fafee47
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
143
Assets/TextMesh Pro/Resources/Shaders/TMP_Bitmap.shader
Normal file
143
Assets/TextMesh Pro/Resources/Shaders/TMP_Bitmap.shader
Normal file
|
@ -0,0 +1,143 @@
|
|||
Shader "TextMeshPro/Bitmap" {
|
||||
|
||||
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
|
||||
|
||||
_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 }
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
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"
|
||||
|
||||
struct appdata_t {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 mask : TEXCOORD2;
|
||||
};
|
||||
|
||||
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 i)
|
||||
{
|
||||
float4 vert = i.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
|
||||
|
||||
float4 vPosition = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
|
||||
fixed4 faceColor = i.color;
|
||||
faceColor *= _FaceColor;
|
||||
|
||||
v2f o;
|
||||
o.vertex = vPosition;
|
||||
o.color = faceColor;
|
||||
o.texcoord0 = i.texcoord0;
|
||||
o.texcoord1 = TRANSFORM_TEX(UnpackUV(i.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.
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
o.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : COLOR
|
||||
{
|
||||
//fixed4 c = tex2D(_MainTex, i.texcoord0) * tex2D(_FaceTex, i.texcoord1) * i.color;
|
||||
|
||||
fixed4 c = tex2D(_MainTex, i.texcoord0);
|
||||
c = fixed4 (tex2D(_FaceTex, i.texcoord1).rgb * i.color.rgb, i.color.a * c.a);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(i.mask.xy)) * i.mask.zw);
|
||||
c *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(c.a - 0.001);
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_BitmapShaderGUI"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 128e987d567d4e2c824d754223b3f3b0
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
305
Assets/TextMesh Pro/Resources/Shaders/TMP_SDF Overlay.shader
Normal file
305
Assets/TextMesh Pro/Resources/Shaders/TMP_SDF Overlay.shader
Normal file
|
@ -0,0 +1,305 @@
|
|||
Shader "TextMeshPro/Distance Field Overlay" {
|
||||
|
||||
Properties {
|
||||
_FaceTex ("Face Texture", 2D) = "white" {}
|
||||
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
|
||||
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineTex ("Outline Texture", 2D) = "white" {}
|
||||
_OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0
|
||||
_OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0
|
||||
_OutlineWidth ("Outline Thickness", Range(0, 1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
_Bevel ("Bevel", Range(0,1)) = 0.5
|
||||
_BevelOffset ("Bevel Offset", Range(-0.5,0.5)) = 0
|
||||
_BevelWidth ("Bevel Width", Range(-.5,0.5)) = 0
|
||||
_BevelClamp ("Bevel Clamp", Range(0,1)) = 0
|
||||
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
|
||||
|
||||
_LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416
|
||||
_SpecularColor ("Specular", Color) = (1,1,1,1)
|
||||
_SpecularPower ("Specular", Range(0,4)) = 2.0
|
||||
_Reflectivity ("Reflectivity", Range(5.0,15.0)) = 10
|
||||
_Diffuse ("Diffuse", Range(0,1)) = 0.5
|
||||
_Ambient ("Ambient", Range(1,0)) = 0.5
|
||||
|
||||
_BumpMap ("Normal map", 2D) = "bump" {}
|
||||
_BumpOutline ("Bump Outline", Range(0,1)) = 0
|
||||
_BumpFace ("Bump Face", Range(0,1)) = 0
|
||||
|
||||
_ReflectFaceColor ("Reflection Color", Color) = (0,0,0,1)
|
||||
_ReflectOutlineColor("Reflection Color", Color) = (0,0,0,1)
|
||||
_Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ }
|
||||
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
|
||||
|
||||
|
||||
_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||
|
||||
_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_GlowOffset ("Offset", Range(-1,1)) = 0
|
||||
_GlowInner ("Inner", Range(0,1)) = 0.05
|
||||
_GlowOuter ("Outer", Range(0,1)) = 0.05
|
||||
_GlowPower ("Falloff", Range(1, 0)) = 0.75
|
||||
|
||||
_WeightNormal ("Weight Normal", float) = 0
|
||||
_WeightBold ("Weight Bold", float) = 0.5
|
||||
|
||||
_ShaderFlags ("Flags", float) = 0
|
||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
||||
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_TextureWidth ("Texture Width", float) = 512
|
||||
_TextureHeight ("Texture Height", float) = 512
|
||||
_GradientScale ("Gradient Scale", float) = 5.0
|
||||
_ScaleX ("Scale X", float) = 1.0
|
||||
_ScaleY ("Scale Y", float) = 1.0
|
||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
|
||||
_MaskCoord ("Mask Coordinates", vector) = (0, 0, 32767, 32767)
|
||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
|
||||
_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
|
||||
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader {
|
||||
|
||||
Tags
|
||||
{
|
||||
"Queue"="Overlay"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull [_CullMode]
|
||||
ZWrite Off
|
||||
Lighting Off
|
||||
Fog { Mode Off }
|
||||
ZTest Always
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex VertShader
|
||||
#pragma fragment PixShader
|
||||
#pragma shader_feature __ BEVEL_ON
|
||||
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
||||
#pragma shader_feature __ GLOW_ON
|
||||
#pragma shader_feature __ MASK_OFF
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "TMPro_Properties.cginc"
|
||||
#include "TMPro.cginc"
|
||||
|
||||
struct vertex_t {
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
|
||||
struct pixel_t {
|
||||
float4 position : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 atlas : TEXCOORD0; // Atlas
|
||||
float4 param : TEXCOORD1; // alphaClip, scale, bias, weight
|
||||
float4 mask : TEXCOORD2; // Position in object space(xy), pixel Size(zw)
|
||||
float3 viewDir : TEXCOORD3;
|
||||
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 texcoord2 : TEXCOORD4; // u,v, scale, bias
|
||||
fixed4 underlayColor : COLOR1;
|
||||
#endif
|
||||
float4 textures : TEXCOORD5;
|
||||
};
|
||||
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
float4 _FaceTex_ST;
|
||||
float4 _OutlineTex_ST;
|
||||
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize));
|
||||
scale *= abs(input.texcoord1.y) * _GradientScale * 1.5;
|
||||
if (UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
|
||||
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
||||
|
||||
float bias =(.5 - weight) + (.5 / scale);
|
||||
|
||||
float alphaClip = (1.0 - _OutlineWidth*_ScaleRatioA - _OutlineSoftness*_ScaleRatioA);
|
||||
|
||||
#if GLOW_ON
|
||||
alphaClip = min(alphaClip, 1.0 - _GlowOffset * _ScaleRatioB - _GlowOuter * _ScaleRatioB);
|
||||
#endif
|
||||
|
||||
alphaClip = alphaClip / 2.0 - ( .5 / scale) - weight;
|
||||
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 underlayColor = _UnderlayColor;
|
||||
underlayColor.rgb *= underlayColor.a;
|
||||
|
||||
float bScale = scale;
|
||||
bScale /= 1 + ((_UnderlaySoftness*_ScaleRatioC) * bScale);
|
||||
float bBias = (0.5 - weight) * bScale - 0.5 - ((_UnderlayDilate * _ScaleRatioC) * 0.5 * bScale);
|
||||
|
||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
||||
float2 bOffset = float2(x, y);
|
||||
#endif
|
||||
|
||||
// Generate UV for the Masking Texture
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
||||
|
||||
// Support for texture tiling and offset
|
||||
float2 textureUV = UnpackUV(input.texcoord1.x);
|
||||
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
|
||||
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
|
||||
|
||||
pixel_t output = {
|
||||
vPosition,
|
||||
input.color,
|
||||
input.texcoord0,
|
||||
float4(alphaClip, scale, bias, weight),
|
||||
half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)),
|
||||
mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz),
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4(input.texcoord0 + bOffset, bScale, bBias),
|
||||
underlayColor,
|
||||
#endif
|
||||
float4(faceUV, outlineUV),
|
||||
};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
fixed4 PixShader(pixel_t input) : SV_Target
|
||||
{
|
||||
float c = tex2D(_MainTex, input.atlas).a;
|
||||
|
||||
#ifndef UNDERLAY_ON
|
||||
clip(c - input.param.x);
|
||||
#endif
|
||||
|
||||
float scale = input.param.y;
|
||||
float bias = input.param.z;
|
||||
float weight = input.param.w;
|
||||
float sd = (bias - c) * scale;
|
||||
|
||||
float outline = (_OutlineWidth * _ScaleRatioA) * scale;
|
||||
float softness = (_OutlineSoftness * _ScaleRatioA) * scale;
|
||||
|
||||
half4 faceColor = _FaceColor;
|
||||
half4 outlineColor = _OutlineColor;
|
||||
|
||||
faceColor.rgb *= input.color.rgb;
|
||||
|
||||
faceColor *= tex2D(_FaceTex, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y);
|
||||
outlineColor *= tex2D(_OutlineTex, input.textures.zw + float2(_OutlineUVSpeedX, _OutlineUVSpeedY) * _Time.y);
|
||||
|
||||
faceColor = GetColor(sd, faceColor, outlineColor, outline, softness);
|
||||
|
||||
#if BEVEL_ON
|
||||
float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0);
|
||||
float3 n = GetSurfaceNormal(input.atlas, weight, dxy);
|
||||
|
||||
float3 bump = UnpackNormal(tex2D(_BumpMap, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y)).xyz;
|
||||
bump *= lerp(_BumpFace, _BumpOutline, saturate(sd + outline * 0.5));
|
||||
n = normalize(n- bump);
|
||||
|
||||
float3 light = normalize(float3(sin(_LightAngle), cos(_LightAngle), -1.0));
|
||||
|
||||
float3 col = GetSpecular(n, light);
|
||||
faceColor.rgb += col*faceColor.a;
|
||||
faceColor.rgb *= 1-(dot(n, light)*_Diffuse);
|
||||
faceColor.rgb *= lerp(_Ambient, 1, n.z*n.z);
|
||||
|
||||
fixed4 reflcol = texCUBE(_Cube, reflect(input.viewDir, -n));
|
||||
faceColor.rgb += reflcol.rgb * lerp(_ReflectFaceColor.rgb, _ReflectOutlineColor.rgb, saturate(sd + outline * 0.5)) * faceColor.a;
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_ON
|
||||
float d = tex2D(_MainTex, input.texcoord2.xy).a * input.texcoord2.z;
|
||||
faceColor += input.underlayColor * saturate(d - input.texcoord2.w) * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_INNER
|
||||
float d = tex2D(_MainTex, input.texcoord2.xy).a * input.texcoord2.z;
|
||||
faceColor += input.underlayColor * (1 - saturate(d - input.texcoord2.w)) * saturate(1 - sd) * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#if GLOW_ON
|
||||
float4 glowColor = GetGlowColor(sd, scale);
|
||||
faceColor.rgb += glowColor.rgb * glowColor.a;
|
||||
#endif
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
||||
faceColor *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(faceColor.a - 0.001);
|
||||
#endif
|
||||
|
||||
return faceColor * input.color.a;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "TextMeshPro/Mobile/Distance Field"
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dd89cf5b9246416f84610a006f916af7
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,243 @@
|
|||
// Simplified SDF shader:
|
||||
// - No Shading Option (bevel / bump / env map)
|
||||
// - No Glow Option
|
||||
// - Softness is applied on both side of the outline
|
||||
|
||||
Shader "TextMeshPro/Mobile/Distance Field - Masking" {
|
||||
|
||||
Properties {
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
|
||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||
|
||||
_WeightNormal ("Weight Normal", float) = 0
|
||||
_WeightBold ("Weight Bold", float) = .5
|
||||
|
||||
_ShaderFlags ("Flags", float) = 0
|
||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
||||
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_TextureWidth ("Texture Width", float) = 512
|
||||
_TextureHeight ("Texture Height", float) = 512
|
||||
_GradientScale ("Gradient Scale", float) = 5
|
||||
_ScaleX ("Scale X", float) = 1
|
||||
_ScaleY ("Scale Y", float) = 1
|
||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
|
||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
_MaskTex ("Mask Texture", 2D) = "white" {}
|
||||
_MaskInverse ("Inverse", float) = 0
|
||||
_MaskEdgeColor ("Edge Color", Color) = (1,1,1,1)
|
||||
_MaskEdgeSoftness ("Edge Softness", Range(0, 1)) = 0.01
|
||||
_MaskWipeControl ("Wipe Position", Range(0, 1)) = 0.5
|
||||
|
||||
_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
|
||||
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
}
|
||||
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull [_CullMode]
|
||||
ZWrite Off
|
||||
Lighting Off
|
||||
Fog { Mode Off }
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex VertShader
|
||||
#pragma fragment PixShader
|
||||
#pragma shader_feature __ OUTLINE_ON
|
||||
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
||||
//#pragma shader_feature __ ALPHA_MASK_ON
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "TMPro_Properties.cginc"
|
||||
|
||||
struct vertex_t {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct pixel_t {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 faceColor : COLOR;
|
||||
fixed4 outlineColor : COLOR1;
|
||||
float4 texcoord0 : TEXCOORD0; // Texture UV, Mask UV
|
||||
half4 param : TEXCOORD1; // Scale(x), BiasIn(y), BiasOut(z), Bias(w)
|
||||
half4 mask : TEXCOORD2; // Position in clip space(xy), Softness(zw)
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved
|
||||
half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y)
|
||||
#endif
|
||||
};
|
||||
|
||||
float _MaskWipeControl;
|
||||
float _MaskEdgeSoftness;
|
||||
fixed4 _MaskEdgeColor;
|
||||
bool _MaskInverse;
|
||||
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
|
||||
float4 vert = input.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
||||
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize));
|
||||
scale *= abs(input.texcoord1.y) * _GradientScale * 1.5;
|
||||
if(UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
|
||||
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
||||
|
||||
float layerScale = scale;
|
||||
|
||||
scale /= 1 + (_OutlineSoftness * _ScaleRatioA * scale);
|
||||
float bias = (0.5 - weight) * scale - 0.5;
|
||||
float outline = _OutlineWidth * _ScaleRatioA * 0.5 * scale;
|
||||
|
||||
float opacity = input.color.a;
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
opacity = 1.0;
|
||||
#endif
|
||||
|
||||
fixed4 faceColor = fixed4(input.color.rgb, opacity) * _FaceColor;
|
||||
faceColor.rgb *= faceColor.a;
|
||||
|
||||
fixed4 outlineColor = _OutlineColor;
|
||||
outlineColor.a *= opacity;
|
||||
outlineColor.rgb *= outlineColor.a;
|
||||
outlineColor = lerp(faceColor, outlineColor, sqrt(min(1.0, (outline * 2))));
|
||||
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
|
||||
layerScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * layerScale);
|
||||
float layerBias = (.5 - weight) * layerScale - .5 - ((_UnderlayDilate * _ScaleRatioC) * .5 * layerScale);
|
||||
|
||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
||||
float2 layerOffset = float2(x, y);
|
||||
#endif
|
||||
|
||||
// Generate UV for the Masking Texture
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
||||
|
||||
// Structure for pixel shader
|
||||
pixel_t output = {
|
||||
vPosition,
|
||||
faceColor,
|
||||
outlineColor,
|
||||
float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y),
|
||||
half4(scale, bias - outline, bias + outline, bias),
|
||||
half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)),
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
float4(input.texcoord0 + layerOffset, input.color.a, 0),
|
||||
half2(layerScale, layerBias),
|
||||
#endif
|
||||
};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
// PIXEL SHADER
|
||||
fixed4 PixShader(pixel_t input) : SV_Target
|
||||
{
|
||||
half d = tex2D(_MainTex, input.texcoord0.xy).a * input.param.x;
|
||||
half4 c = input.faceColor * saturate(d - input.param.w);
|
||||
|
||||
#ifdef OUTLINE_ON
|
||||
c = lerp(input.outlineColor, input.faceColor, saturate(d - input.param.z));
|
||||
c *= saturate(d - input.param.y);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_ON
|
||||
d = tex2D(_MainTex, input.texcoord1.xy).a * input.underlayParam.x;
|
||||
c += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * saturate(d - input.underlayParam.y) * (1 - c.a);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_INNER
|
||||
half sd = saturate(d - input.param.z);
|
||||
d = tex2D(_MainTex, input.texcoord1.xy).a * input.underlayParam.x;
|
||||
c += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * (1 - saturate(d - input.underlayParam.y)) * sd * (1 - c.a);
|
||||
#endif
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
||||
c *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
//#if ALPHA_MASK_ON
|
||||
float a = abs(_MaskInverse - tex2D(_MaskTex, input.texcoord0.zw).a);
|
||||
float t = a + (1 - _MaskWipeControl) * _MaskEdgeSoftness - _MaskWipeControl;
|
||||
a = saturate(t / _MaskEdgeSoftness);
|
||||
c.rgb = lerp(_MaskEdgeColor.rgb*c.a, c.rgb, a);
|
||||
c *= a;
|
||||
//#endif
|
||||
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
c *= input.texcoord1.z;
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bc1ede39bf3643ee8e493720e4259791
|
||||
timeCreated: 1463704911
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,229 @@
|
|||
// Simplified SDF shader:
|
||||
// - No Shading Option (bevel / bump / env map)
|
||||
// - No Glow Option
|
||||
// - Softness is applied on both side of the outline
|
||||
|
||||
Shader "TextMeshPro/Mobile/Distance Field Overlay" {
|
||||
|
||||
Properties {
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
|
||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||
|
||||
_WeightNormal ("Weight Normal", float) = 0
|
||||
_WeightBold ("Weight Bold", float) = .5
|
||||
|
||||
_ShaderFlags ("Flags", float) = 0
|
||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
||||
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_TextureWidth ("Texture Width", float) = 512
|
||||
_TextureHeight ("Texture Height", float) = 512
|
||||
_GradientScale ("Gradient Scale", float) = 5
|
||||
_ScaleX ("Scale X", float) = 1
|
||||
_ScaleY ("Scale Y", float) = 1
|
||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
|
||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
|
||||
_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
|
||||
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags
|
||||
{
|
||||
"Queue"="Overlay"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
}
|
||||
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull [_CullMode]
|
||||
ZWrite Off
|
||||
Lighting Off
|
||||
Fog { Mode Off }
|
||||
ZTest Always
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex VertShader
|
||||
#pragma fragment PixShader
|
||||
#pragma shader_feature __ OUTLINE_ON
|
||||
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "TMPro_Properties.cginc"
|
||||
|
||||
struct vertex_t {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct pixel_t {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 faceColor : COLOR;
|
||||
fixed4 outlineColor : COLOR1;
|
||||
float4 texcoord0 : TEXCOORD0; // Texture UV, Mask UV
|
||||
half4 param : TEXCOORD1; // Scale(x), BiasIn(y), BiasOut(z), Bias(w)
|
||||
half4 mask : TEXCOORD2; // Position in clip space(xy), Softness(zw)
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved
|
||||
half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y)
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
|
||||
float4 vert = input.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
||||
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize));
|
||||
scale *= abs(input.texcoord1.y) * _GradientScale * 1.5;
|
||||
if(UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
|
||||
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
||||
|
||||
float layerScale = scale;
|
||||
|
||||
scale /= 1 + (_OutlineSoftness * _ScaleRatioA * scale);
|
||||
float bias = (0.5 - weight) * scale - 0.5;
|
||||
float outline = _OutlineWidth * _ScaleRatioA * 0.5 * scale;
|
||||
|
||||
float opacity = input.color.a;
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
opacity = 1.0;
|
||||
#endif
|
||||
|
||||
fixed4 faceColor = fixed4(input.color.rgb, opacity) * _FaceColor;
|
||||
faceColor.rgb *= faceColor.a;
|
||||
|
||||
fixed4 outlineColor = _OutlineColor;
|
||||
outlineColor.a *= opacity;
|
||||
outlineColor.rgb *= outlineColor.a;
|
||||
outlineColor = lerp(faceColor, outlineColor, sqrt(min(1.0, (outline * 2))));
|
||||
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
|
||||
layerScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * layerScale);
|
||||
float layerBias = (.5 - weight) * layerScale - .5 - ((_UnderlayDilate * _ScaleRatioC) * .5 * layerScale);
|
||||
|
||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
||||
float2 layerOffset = float2(x, y);
|
||||
#endif
|
||||
|
||||
// Generate UV for the Masking Texture
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
||||
|
||||
// Structure for pixel shader
|
||||
pixel_t output = {
|
||||
vPosition,
|
||||
faceColor,
|
||||
outlineColor,
|
||||
float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y),
|
||||
half4(scale, bias - outline, bias + outline, bias),
|
||||
half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)),
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
float4(input.texcoord0 + layerOffset, input.color.a, 0),
|
||||
half2(layerScale, layerBias),
|
||||
#endif
|
||||
};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
// PIXEL SHADER
|
||||
fixed4 PixShader(pixel_t input) : SV_Target
|
||||
{
|
||||
half d = tex2D(_MainTex, input.texcoord0.xy).a * input.param.x;
|
||||
half4 c = input.faceColor * saturate(d - input.param.w);
|
||||
|
||||
#ifdef OUTLINE_ON
|
||||
c = lerp(input.outlineColor, input.faceColor, saturate(d - input.param.z));
|
||||
c *= saturate(d - input.param.y);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_ON
|
||||
d = tex2D(_MainTex, input.texcoord1.xy).a * input.underlayParam.x;
|
||||
c += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * saturate(d - input.underlayParam.y) * (1 - c.a);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_INNER
|
||||
half sd = saturate(d - input.param.z);
|
||||
d = tex2D(_MainTex, input.texcoord1.xy).a * input.underlayParam.x;
|
||||
c += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * (1 - saturate(d - input.underlayParam.y)) * sd * (1 - c.a);
|
||||
#endif
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
||||
c *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(c.a - 0.001);
|
||||
#endif
|
||||
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
c *= input.texcoord1.z;
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a02a7d8c237544f1962732b55a9aebf1
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
229
Assets/TextMesh Pro/Resources/Shaders/TMP_SDF-Mobile.shader
Normal file
229
Assets/TextMesh Pro/Resources/Shaders/TMP_SDF-Mobile.shader
Normal file
|
@ -0,0 +1,229 @@
|
|||
// Simplified SDF shader:
|
||||
// - No Shading Option (bevel / bump / env map)
|
||||
// - No Glow Option
|
||||
// - Softness is applied on both side of the outline
|
||||
|
||||
Shader "TextMeshPro/Mobile/Distance Field" {
|
||||
|
||||
Properties {
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
|
||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||
|
||||
_WeightNormal ("Weight Normal", float) = 0
|
||||
_WeightBold ("Weight Bold", float) = .5
|
||||
|
||||
_ShaderFlags ("Flags", float) = 0
|
||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
||||
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_TextureWidth ("Texture Width", float) = 512
|
||||
_TextureHeight ("Texture Height", float) = 512
|
||||
_GradientScale ("Gradient Scale", float) = 5
|
||||
_ScaleX ("Scale X", float) = 1
|
||||
_ScaleY ("Scale Y", float) = 1
|
||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
|
||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
|
||||
_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
|
||||
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
}
|
||||
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull [_CullMode]
|
||||
ZWrite Off
|
||||
Lighting Off
|
||||
Fog { Mode Off }
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex VertShader
|
||||
#pragma fragment PixShader
|
||||
#pragma shader_feature __ OUTLINE_ON
|
||||
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "TMPro_Properties.cginc"
|
||||
|
||||
struct vertex_t {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct pixel_t {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 faceColor : COLOR;
|
||||
fixed4 outlineColor : COLOR1;
|
||||
float4 texcoord0 : TEXCOORD0; // Texture UV, Mask UV
|
||||
half4 param : TEXCOORD1; // Scale(x), BiasIn(y), BiasOut(z), Bias(w)
|
||||
half4 mask : TEXCOORD2; // Position in clip space(xy), Softness(zw)
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved
|
||||
half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y)
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
|
||||
float4 vert = input.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
||||
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize));
|
||||
scale *= abs(input.texcoord1.y) * _GradientScale * 1.5;
|
||||
if(UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
|
||||
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
||||
|
||||
float layerScale = scale;
|
||||
|
||||
scale /= 1 + (_OutlineSoftness * _ScaleRatioA * scale);
|
||||
float bias = (0.5 - weight) * scale - 0.5;
|
||||
float outline = _OutlineWidth * _ScaleRatioA * 0.5 * scale;
|
||||
|
||||
float opacity = input.color.a;
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
opacity = 1.0;
|
||||
#endif
|
||||
|
||||
fixed4 faceColor = fixed4(input.color.rgb, opacity) * _FaceColor;
|
||||
faceColor.rgb *= faceColor.a;
|
||||
|
||||
fixed4 outlineColor = _OutlineColor;
|
||||
outlineColor.a *= opacity;
|
||||
outlineColor.rgb *= outlineColor.a;
|
||||
outlineColor = lerp(faceColor, outlineColor, sqrt(min(1.0, (outline * 2))));
|
||||
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
|
||||
layerScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * layerScale);
|
||||
float layerBias = (.5 - weight) * layerScale - .5 - ((_UnderlayDilate * _ScaleRatioC) * .5 * layerScale);
|
||||
|
||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
||||
float2 layerOffset = float2(x, y);
|
||||
#endif
|
||||
|
||||
// Generate UV for the Masking Texture
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
||||
|
||||
// Structure for pixel shader
|
||||
pixel_t output = {
|
||||
vPosition,
|
||||
faceColor,
|
||||
outlineColor,
|
||||
float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y),
|
||||
half4(scale, bias - outline, bias + outline, bias),
|
||||
half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)),
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
float4(input.texcoord0 + layerOffset, input.color.a, 0),
|
||||
half2(layerScale, layerBias),
|
||||
#endif
|
||||
};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
// PIXEL SHADER
|
||||
fixed4 PixShader(pixel_t input) : SV_Target
|
||||
{
|
||||
half d = tex2D(_MainTex, input.texcoord0.xy).a * input.param.x;
|
||||
half4 c = input.faceColor * saturate(d - input.param.w);
|
||||
|
||||
#ifdef OUTLINE_ON
|
||||
c = lerp(input.outlineColor, input.faceColor, saturate(d - input.param.z));
|
||||
c *= saturate(d - input.param.y);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_ON
|
||||
d = tex2D(_MainTex, input.texcoord1.xy).a * input.underlayParam.x;
|
||||
c += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * saturate(d - input.underlayParam.y) * (1 - c.a);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_INNER
|
||||
half sd = saturate(d - input.param.z);
|
||||
d = tex2D(_MainTex, input.texcoord1.xy).a * input.underlayParam.x;
|
||||
c += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * (1 - saturate(d - input.underlayParam.y)) * sd * (1 - c.a);
|
||||
#endif
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
||||
c *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
c *= input.texcoord1.z;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(c.a - 0.001);
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fe393ace9b354375a9cb14cdbbc28be4
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,136 @@
|
|||
// Simplified version of the SDF Surface shader :
|
||||
// - No support for Bevel, Bump or envmap
|
||||
// - Diffuse only lighting
|
||||
// - Fully supports only 1 directional light. Other lights can affect it, but it will be per-vertex/SH.
|
||||
|
||||
Shader "TextMeshPro/Mobile/Distance Field (Surface)" {
|
||||
|
||||
Properties {
|
||||
_FaceTex ("Fill Texture", 2D) = "white" {}
|
||||
_FaceColor ("Fill Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineTex ("Outline Texture", 2D) = "white" {}
|
||||
_OutlineWidth ("Outline Thickness", Range(0, 1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_GlowOffset ("Offset", Range(-1,1)) = 0
|
||||
_GlowInner ("Inner", Range(0,1)) = 0.05
|
||||
_GlowOuter ("Outer", Range(0,1)) = 0.05
|
||||
_GlowPower ("Falloff", Range(1, 0)) = 0.75
|
||||
|
||||
_WeightNormal ("Weight Normal", float) = 0
|
||||
_WeightBold ("Weight Bold", float) = 0.5
|
||||
|
||||
// Should not be directly exposed to the user
|
||||
_ShaderFlags ("Flags", float) = 0
|
||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
||||
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_TextureWidth ("Texture Width", float) = 512
|
||||
_TextureHeight ("Texture Height", float) = 512
|
||||
_GradientScale ("Gradient Scale", float) = 5.0
|
||||
_ScaleX ("Scale X", float) = 1.0
|
||||
_ScaleY ("Scale Y", float) = 1.0
|
||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
|
||||
//_MaskCoord ("Mask Coords", vector) = (0,0,0,0)
|
||||
//_MaskSoftness ("Mask Softness", float) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
|
||||
Tags {
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
}
|
||||
|
||||
LOD 300
|
||||
Cull [_CullMode]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface PixShader Lambert alpha:blend vertex:VertShader noforwardadd nolightmap nodirlightmap
|
||||
#pragma target 3.0
|
||||
#pragma shader_feature __ GLOW_ON
|
||||
|
||||
#include "TMPro_Properties.cginc"
|
||||
#include "TMPro.cginc"
|
||||
|
||||
half _FaceShininess;
|
||||
half _OutlineShininess;
|
||||
|
||||
struct Input
|
||||
{
|
||||
fixed4 color : COLOR;
|
||||
float2 uv_MainTex;
|
||||
float2 uv2_FaceTex;
|
||||
float2 uv2_OutlineTex;
|
||||
float2 param; // Weight, Scale
|
||||
float3 viewDirEnv;
|
||||
};
|
||||
|
||||
#include "TMPro_Surface.cginc"
|
||||
|
||||
ENDCG
|
||||
|
||||
// Pass to render object as a shadow caster
|
||||
Pass
|
||||
{
|
||||
Name "Caster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
Fog {Mode Off}
|
||||
ZWrite On ZTest LEqual Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_shadowcaster
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
float2 uv2 : TEXCOORD3;
|
||||
float alphaClip : TEXCOORD2;
|
||||
};
|
||||
|
||||
uniform float4 _MainTex_ST;
|
||||
uniform float4 _OutlineTex_ST;
|
||||
float _OutlineWidth;
|
||||
float _FaceDilate;
|
||||
float _ScaleRatioA;
|
||||
|
||||
v2f vert( appdata_base v )
|
||||
{
|
||||
v2f o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uv2 = TRANSFORM_TEX(v.texcoord, _OutlineTex);
|
||||
o.alphaClip = o.alphaClip = (1.0 - _OutlineWidth * _ScaleRatioA - _FaceDilate * _ScaleRatioA) / 2;
|
||||
return o;
|
||||
}
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
|
||||
float4 frag(v2f i) : COLOR
|
||||
{
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv).a;
|
||||
clip(texcol.a - i.alphaClip);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 85187c2149c549c5b33f0cdb02836b17
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
155
Assets/TextMesh Pro/Resources/Shaders/TMP_SDF-Surface.shader
Normal file
155
Assets/TextMesh Pro/Resources/Shaders/TMP_SDF-Surface.shader
Normal file
|
@ -0,0 +1,155 @@
|
|||
Shader "TextMeshPro/Distance Field (Surface)" {
|
||||
|
||||
Properties {
|
||||
_FaceTex ("Fill Texture", 2D) = "white" {}
|
||||
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
|
||||
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
|
||||
_FaceColor ("Fill Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineTex ("Outline Texture", 2D) = "white" {}
|
||||
_OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0
|
||||
_OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0
|
||||
_OutlineWidth ("Outline Thickness", Range(0, 1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
_Bevel ("Bevel", Range(0,1)) = 0.5
|
||||
_BevelOffset ("Bevel Offset", Range(-0.5,0.5)) = 0
|
||||
_BevelWidth ("Bevel Width", Range(-.5,0.5)) = 0
|
||||
_BevelClamp ("Bevel Clamp", Range(0,1)) = 0
|
||||
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
|
||||
|
||||
_BumpMap ("Normalmap", 2D) = "bump" {}
|
||||
_BumpOutline ("Bump Outline", Range(0,1)) = 0.5
|
||||
_BumpFace ("Bump Face", Range(0,1)) = 0.5
|
||||
|
||||
_ReflectFaceColor ("Face Color", Color) = (0,0,0,1)
|
||||
_ReflectOutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ }
|
||||
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
|
||||
_SpecColor ("Specular Color", Color) = (0,0,0,1)
|
||||
|
||||
_FaceShininess ("Face Shininess", Range(0,1)) = 0
|
||||
_OutlineShininess ("Outline Shininess", Range(0,1)) = 0
|
||||
|
||||
_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_GlowOffset ("Offset", Range(-1,1)) = 0
|
||||
_GlowInner ("Inner", Range(0,1)) = 0.05
|
||||
_GlowOuter ("Outer", Range(0,1)) = 0.05
|
||||
_GlowPower ("Falloff", Range(1, 0)) = 0.75
|
||||
|
||||
_WeightNormal ("Weight Normal", float) = 0
|
||||
_WeightBold ("Weight Bold", float) = 0.5
|
||||
|
||||
// Should not be directly exposed to the user
|
||||
_ShaderFlags ("Flags", float) = 0
|
||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
||||
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_TextureWidth ("Texture Width", float) = 512
|
||||
_TextureHeight ("Texture Height", float) = 512
|
||||
_GradientScale ("Gradient Scale", float) = 5.0
|
||||
_ScaleX ("Scale X", float) = 1.0
|
||||
_ScaleY ("Scale Y", float) = 1.0
|
||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
//_MaskCoord ("Mask Coords", vector) = (0,0,0,0)
|
||||
//_MaskSoftness ("Mask Softness", float) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
|
||||
LOD 300
|
||||
Cull [_CullMode]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface PixShader BlinnPhong alpha:blend vertex:VertShader nolightmap nodirlightmap
|
||||
#pragma target 3.0
|
||||
#pragma shader_feature __ GLOW_ON
|
||||
#pragma glsl
|
||||
|
||||
#include "TMPro_Properties.cginc"
|
||||
#include "TMPro.cginc"
|
||||
|
||||
half _FaceShininess;
|
||||
half _OutlineShininess;
|
||||
|
||||
struct Input
|
||||
{
|
||||
fixed4 color : COLOR;
|
||||
float2 uv_MainTex;
|
||||
float2 uv2_FaceTex;
|
||||
float2 uv2_OutlineTex;
|
||||
float2 param; // Weight, Scale
|
||||
float3 viewDirEnv;
|
||||
};
|
||||
|
||||
|
||||
#define BEVEL_ON 1
|
||||
#include "TMPro_Surface.cginc"
|
||||
|
||||
ENDCG
|
||||
|
||||
// Pass to render object as a shadow caster
|
||||
Pass
|
||||
{
|
||||
Name "Caster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
Fog {Mode Off}
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_shadowcaster
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float2 uv : TEXCOORD1;
|
||||
float2 uv2 : TEXCOORD3;
|
||||
float alphaClip : TEXCOORD2;
|
||||
};
|
||||
|
||||
uniform float4 _MainTex_ST;
|
||||
uniform float4 _OutlineTex_ST;
|
||||
float _OutlineWidth;
|
||||
float _FaceDilate;
|
||||
float _ScaleRatioA;
|
||||
|
||||
v2f vert( appdata_base v )
|
||||
{
|
||||
v2f o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uv2 = TRANSFORM_TEX(v.texcoord, _OutlineTex);
|
||||
o.alphaClip = (1.0 - _OutlineWidth * _ScaleRatioA - _FaceDilate * _ScaleRatioA) / 2;
|
||||
return o;
|
||||
}
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
|
||||
float4 frag(v2f i) : COLOR
|
||||
{
|
||||
fixed4 texcol = tex2D(_MainTex, i.uv).a;
|
||||
clip(texcol.a - i.alphaClip);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f7ada0af4f174f0694ca6a487b8f543d
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
305
Assets/TextMesh Pro/Resources/Shaders/TMP_SDF.shader
Normal file
305
Assets/TextMesh Pro/Resources/Shaders/TMP_SDF.shader
Normal file
|
@ -0,0 +1,305 @@
|
|||
Shader "TextMeshPro/Distance Field" {
|
||||
|
||||
Properties {
|
||||
_FaceTex ("Face Texture", 2D) = "white" {}
|
||||
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
|
||||
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineTex ("Outline Texture", 2D) = "white" {}
|
||||
_OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0
|
||||
_OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0
|
||||
_OutlineWidth ("Outline Thickness", Range(0, 1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(-1,1)) = 0
|
||||
|
||||
_Bevel ("Bevel", Range(0,1)) = 0.5
|
||||
_BevelOffset ("Bevel Offset", Range(-0.5,0.5)) = 0
|
||||
_BevelWidth ("Bevel Width", Range(-.5,0.5)) = 0
|
||||
_BevelClamp ("Bevel Clamp", Range(0,1)) = 0
|
||||
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
|
||||
|
||||
_LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416
|
||||
_SpecularColor ("Specular", Color) = (1,1,1,1)
|
||||
_SpecularPower ("Specular", Range(0,4)) = 2.0
|
||||
_Reflectivity ("Reflectivity", Range(5.0,15.0)) = 10
|
||||
_Diffuse ("Diffuse", Range(0,1)) = 0.5
|
||||
_Ambient ("Ambient", Range(1,0)) = 0.5
|
||||
|
||||
_BumpMap ("Normal map", 2D) = "bump" {}
|
||||
_BumpOutline ("Bump Outline", Range(0,1)) = 0
|
||||
_BumpFace ("Bump Face", Range(0,1)) = 0
|
||||
|
||||
_ReflectFaceColor ("Reflection Color", Color) = (0,0,0,1)
|
||||
_ReflectOutlineColor("Reflection Color", Color) = (0,0,0,1)
|
||||
_Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ }
|
||||
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
|
||||
|
||||
|
||||
_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||
|
||||
_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_GlowOffset ("Offset", Range(-1,1)) = 0
|
||||
_GlowInner ("Inner", Range(0,1)) = 0.05
|
||||
_GlowOuter ("Outer", Range(0,1)) = 0.05
|
||||
_GlowPower ("Falloff", Range(1, 0)) = 0.75
|
||||
|
||||
_WeightNormal ("Weight Normal", float) = 0
|
||||
_WeightBold ("Weight Bold", float) = 0.5
|
||||
|
||||
_ShaderFlags ("Flags", float) = 0
|
||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
||||
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_TextureWidth ("Texture Width", float) = 512
|
||||
_TextureHeight ("Texture Height", float) = 512
|
||||
_GradientScale ("Gradient Scale", float) = 5.0
|
||||
_ScaleX ("Scale X", float) = 1.0
|
||||
_ScaleY ("Scale Y", float) = 1.0
|
||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
|
||||
_MaskCoord ("Mask Coordinates", vector) = (0, 0, 32767, 32767)
|
||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
|
||||
_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
|
||||
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader {
|
||||
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull [_CullMode]
|
||||
ZWrite Off
|
||||
Lighting Off
|
||||
Fog { Mode Off }
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex VertShader
|
||||
#pragma fragment PixShader
|
||||
#pragma shader_feature __ BEVEL_ON
|
||||
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
||||
#pragma shader_feature __ GLOW_ON
|
||||
#pragma shader_feature __ MASK_OFF
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "TMPro_Properties.cginc"
|
||||
#include "TMPro.cginc"
|
||||
|
||||
struct vertex_t {
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
|
||||
struct pixel_t {
|
||||
float4 position : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 atlas : TEXCOORD0; // Atlas
|
||||
float4 param : TEXCOORD1; // alphaClip, scale, bias, weight
|
||||
float4 mask : TEXCOORD2; // Position in object space(xy), pixel Size(zw)
|
||||
float3 viewDir : TEXCOORD3;
|
||||
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 texcoord2 : TEXCOORD4; // u,v, scale, bias
|
||||
fixed4 underlayColor : COLOR1;
|
||||
#endif
|
||||
float4 textures : TEXCOORD5;
|
||||
};
|
||||
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
float4 _FaceTex_ST;
|
||||
float4 _OutlineTex_ST;
|
||||
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize));
|
||||
scale *= abs(input.texcoord1.y) * _GradientScale * 1.5;
|
||||
if (UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
|
||||
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
||||
|
||||
float bias =(.5 - weight) + (.5 / scale);
|
||||
|
||||
float alphaClip = (1.0 - _OutlineWidth*_ScaleRatioA - _OutlineSoftness*_ScaleRatioA);
|
||||
|
||||
#if GLOW_ON
|
||||
alphaClip = min(alphaClip, 1.0 - _GlowOffset * _ScaleRatioB - _GlowOuter * _ScaleRatioB);
|
||||
#endif
|
||||
|
||||
alphaClip = alphaClip / 2.0 - ( .5 / scale) - weight;
|
||||
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 underlayColor = _UnderlayColor;
|
||||
underlayColor.rgb *= underlayColor.a;
|
||||
|
||||
float bScale = scale;
|
||||
bScale /= 1 + ((_UnderlaySoftness*_ScaleRatioC) * bScale);
|
||||
float bBias = (0.5 - weight) * bScale - 0.5 - ((_UnderlayDilate * _ScaleRatioC) * 0.5 * bScale);
|
||||
|
||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
||||
float2 bOffset = float2(x, y);
|
||||
#endif
|
||||
|
||||
// Generate UV for the Masking Texture
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
||||
|
||||
// Support for texture tiling and offset
|
||||
float2 textureUV = UnpackUV(input.texcoord1.x);
|
||||
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
|
||||
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
|
||||
|
||||
pixel_t output = {
|
||||
vPosition,
|
||||
input.color,
|
||||
input.texcoord0,
|
||||
float4(alphaClip, scale, bias, weight),
|
||||
half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)),
|
||||
mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz),
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4(input.texcoord0 + bOffset, bScale, bBias),
|
||||
underlayColor,
|
||||
#endif
|
||||
float4(faceUV, outlineUV),
|
||||
};
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
fixed4 PixShader(pixel_t input) : SV_Target
|
||||
{
|
||||
float c = tex2D(_MainTex, input.atlas).a;
|
||||
|
||||
#ifndef UNDERLAY_ON
|
||||
clip(c - input.param.x);
|
||||
#endif
|
||||
|
||||
float scale = input.param.y;
|
||||
float bias = input.param.z;
|
||||
float weight = input.param.w;
|
||||
float sd = (bias - c) * scale;
|
||||
|
||||
float outline = (_OutlineWidth * _ScaleRatioA) * scale;
|
||||
float softness = (_OutlineSoftness * _ScaleRatioA) * scale;
|
||||
|
||||
half4 faceColor = _FaceColor;
|
||||
half4 outlineColor = _OutlineColor;
|
||||
|
||||
faceColor.rgb *= input.color.rgb;
|
||||
|
||||
faceColor *= tex2D(_FaceTex, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y);
|
||||
outlineColor *= tex2D(_OutlineTex, input.textures.zw + float2(_OutlineUVSpeedX, _OutlineUVSpeedY) * _Time.y);
|
||||
|
||||
faceColor = GetColor(sd, faceColor, outlineColor, outline, softness);
|
||||
|
||||
#if BEVEL_ON
|
||||
float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0);
|
||||
float3 n = GetSurfaceNormal(input.atlas, weight, dxy);
|
||||
|
||||
float3 bump = UnpackNormal(tex2D(_BumpMap, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y)).xyz;
|
||||
bump *= lerp(_BumpFace, _BumpOutline, saturate(sd + outline * 0.5));
|
||||
n = normalize(n- bump);
|
||||
|
||||
float3 light = normalize(float3(sin(_LightAngle), cos(_LightAngle), -1.0));
|
||||
|
||||
float3 col = GetSpecular(n, light);
|
||||
faceColor.rgb += col*faceColor.a;
|
||||
faceColor.rgb *= 1-(dot(n, light)*_Diffuse);
|
||||
faceColor.rgb *= lerp(_Ambient, 1, n.z*n.z);
|
||||
|
||||
fixed4 reflcol = texCUBE(_Cube, reflect(input.viewDir, -n));
|
||||
faceColor.rgb += reflcol.rgb * lerp(_ReflectFaceColor.rgb, _ReflectOutlineColor.rgb, saturate(sd + outline * 0.5)) * faceColor.a;
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_ON
|
||||
float d = tex2D(_MainTex, input.texcoord2.xy).a * input.texcoord2.z;
|
||||
faceColor += input.underlayColor * saturate(d - input.texcoord2.w) * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_INNER
|
||||
float d = tex2D(_MainTex, input.texcoord2.xy).a * input.texcoord2.z;
|
||||
faceColor += input.underlayColor * (1 - saturate(d - input.texcoord2.w)) * saturate(1 - sd) * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#if GLOW_ON
|
||||
float4 glowColor = GetGlowColor(sd, scale);
|
||||
faceColor.rgb += glowColor.rgb * glowColor.a;
|
||||
#endif
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
||||
faceColor *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(faceColor.a - 0.001);
|
||||
#endif
|
||||
|
||||
return faceColor * input.color.a;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "TextMeshPro/Mobile/Distance Field"
|
||||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 68e6db2ebdc24f95958faec2be5558d6
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
113
Assets/TextMesh Pro/Resources/Shaders/TMP_Sprite.shader
Normal file
113
Assets/TextMesh Pro/Resources/Shaders/TMP_Sprite.shader
Normal file
|
@ -0,0 +1,113 @@
|
|||
Shader "TextMeshPro/Sprite"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
_Color ("Tint", Color) = (1,1,1,1)
|
||||
|
||||
_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
|
||||
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
|
||||
v2f vert(appdata_t IN)
|
||||
{
|
||||
v2f OUT;
|
||||
OUT.worldPosition = IN.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
||||
|
||||
OUT.texcoord = IN.texcoord;
|
||||
|
||||
#ifdef UNITY_HALF_TEXEL_OFFSET
|
||||
OUT.vertex.xy += (_ScreenParams.zw-1.0)*float2(-1,1);
|
||||
#endif
|
||||
|
||||
OUT.color = IN.color * _Color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
|
||||
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip (color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cf81c85f95fe47e1a27f6ae460cf182c
|
||||
timeCreated: 1450517184
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
84
Assets/TextMesh Pro/Resources/Shaders/TMPro.cginc
Normal file
84
Assets/TextMesh Pro/Resources/Shaders/TMPro.cginc
Normal file
|
@ -0,0 +1,84 @@
|
|||
float2 UnpackUV(float uv)
|
||||
{
|
||||
float2 output;
|
||||
output.x = floor(uv / 4096);
|
||||
output.y = uv - 4096 * output.x;
|
||||
|
||||
return output * 0.001953125;
|
||||
}
|
||||
|
||||
fixed4 GetColor(half d, fixed4 faceColor, fixed4 outlineColor, half outline, half softness)
|
||||
{
|
||||
half faceAlpha = 1-saturate((d - outline * 0.5 + softness * 0.5) / (1.0 + softness));
|
||||
half outlineAlpha = saturate((d + outline * 0.5)) * sqrt(min(1.0, outline));
|
||||
|
||||
faceColor.rgb *= faceColor.a;
|
||||
outlineColor.rgb *= outlineColor.a;
|
||||
|
||||
faceColor = lerp(faceColor, outlineColor, outlineAlpha);
|
||||
|
||||
faceColor *= faceAlpha;
|
||||
|
||||
return faceColor;
|
||||
}
|
||||
|
||||
float3 GetSurfaceNormal(float4 h, float bias)
|
||||
{
|
||||
bool raisedBevel = step(1, fmod(_ShaderFlags, 2));
|
||||
|
||||
h += bias+_BevelOffset;
|
||||
|
||||
float bevelWidth = max(.01, _OutlineWidth+_BevelWidth);
|
||||
|
||||
// Track outline
|
||||
h -= .5;
|
||||
h /= bevelWidth;
|
||||
h = saturate(h+.5);
|
||||
|
||||
if(raisedBevel) h = 1 - abs(h*2.0 - 1.0);
|
||||
h = lerp(h, sin(h*3.141592/2.0), _BevelRoundness);
|
||||
h = min(h, 1.0-_BevelClamp);
|
||||
h *= _Bevel * bevelWidth * _GradientScale * -2.0;
|
||||
|
||||
float3 va = normalize(float3(1.0, 0.0, h.y - h.x));
|
||||
float3 vb = normalize(float3(0.0, -1.0, h.w - h.z));
|
||||
|
||||
return cross(va, vb);
|
||||
}
|
||||
|
||||
float3 GetSurfaceNormal(float2 uv, float bias, float3 delta)
|
||||
{
|
||||
// Read "height field"
|
||||
float4 h = {tex2D(_MainTex, uv - delta.xz).a,
|
||||
tex2D(_MainTex, uv + delta.xz).a,
|
||||
tex2D(_MainTex, uv - delta.zy).a,
|
||||
tex2D(_MainTex, uv + delta.zy).a};
|
||||
|
||||
return GetSurfaceNormal(h, bias);
|
||||
}
|
||||
|
||||
float3 GetSpecular(float3 n, float3 l)
|
||||
{
|
||||
float spec = pow(max(0.0, dot(n, l)), _Reflectivity);
|
||||
return _SpecularColor.rgb * spec * _SpecularPower;
|
||||
}
|
||||
|
||||
float4 GetGlowColor(float d, float scale)
|
||||
{
|
||||
float glow = d - (_GlowOffset*_ScaleRatioB) * 0.5 * scale;
|
||||
float t = lerp(_GlowInner, (_GlowOuter * _ScaleRatioB), step(0.0, glow)) * 0.5 * scale;
|
||||
glow = saturate(abs(glow/(1.0 + t)));
|
||||
glow = 1.0-pow(glow, _GlowPower);
|
||||
glow *= sqrt(min(1.0, t)); // Fade off glow thinner than 1 screen pixel
|
||||
return float4(_GlowColor.rgb, saturate(_GlowColor.a * glow * 2));
|
||||
}
|
||||
|
||||
float4 BlendARGB(float4 overlying, float4 underlying)
|
||||
{
|
||||
overlying.rgb *= overlying.a;
|
||||
underlying.rgb *= underlying.a;
|
||||
float3 blended = overlying.rgb + ((1-overlying.a)*underlying.rgb);
|
||||
float alpha = underlying.a + (1-underlying.a)*overlying.a;
|
||||
return float4(blended, alpha);
|
||||
}
|
||||
|
7
Assets/TextMesh Pro/Resources/Shaders/TMPro.cginc.meta
Normal file
7
Assets/TextMesh Pro/Resources/Shaders/TMPro.cginc.meta
Normal file
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 407bc68d299748449bbf7f48ee690f8d
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
84
Assets/TextMesh Pro/Resources/Shaders/TMPro_Properties.cginc
Normal file
84
Assets/TextMesh Pro/Resources/Shaders/TMPro_Properties.cginc
Normal file
|
@ -0,0 +1,84 @@
|
|||
// UI Editable properties
|
||||
uniform sampler2D _FaceTex; // Alpha : Signed Distance
|
||||
uniform float _FaceUVSpeedX;
|
||||
uniform float _FaceUVSpeedY;
|
||||
uniform fixed4 _FaceColor; // RGBA : Color + Opacity
|
||||
uniform float _FaceDilate; // v[ 0, 1]
|
||||
uniform float _OutlineSoftness; // v[ 0, 1]
|
||||
|
||||
uniform sampler2D _OutlineTex; // RGBA : Color + Opacity
|
||||
uniform float _OutlineUVSpeedX;
|
||||
uniform float _OutlineUVSpeedY;
|
||||
uniform fixed4 _OutlineColor; // RGBA : Color + Opacity
|
||||
uniform float _OutlineWidth; // v[ 0, 1]
|
||||
|
||||
uniform float _Bevel; // v[ 0, 1]
|
||||
uniform float _BevelOffset; // v[-1, 1]
|
||||
uniform float _BevelWidth; // v[-1, 1]
|
||||
uniform float _BevelClamp; // v[ 0, 1]
|
||||
uniform float _BevelRoundness; // v[ 0, 1]
|
||||
|
||||
uniform sampler2D _BumpMap; // Normal map
|
||||
uniform float _BumpOutline; // v[ 0, 1]
|
||||
uniform float _BumpFace; // v[ 0, 1]
|
||||
|
||||
uniform samplerCUBE _Cube; // Cube / sphere map
|
||||
uniform fixed4 _ReflectFaceColor; // RGB intensity
|
||||
uniform fixed4 _ReflectOutlineColor;
|
||||
//uniform float _EnvTiltX; // v[-1, 1]
|
||||
//uniform float _EnvTiltY; // v[-1, 1]
|
||||
uniform float3 _EnvMatrixRotation;
|
||||
uniform float4x4 _EnvMatrix;
|
||||
|
||||
uniform fixed4 _SpecularColor; // RGB intensity
|
||||
uniform float _LightAngle; // v[ 0,Tau]
|
||||
uniform float _SpecularPower; // v[ 0, 1]
|
||||
uniform float _Reflectivity; // v[ 5, 15]
|
||||
uniform float _Diffuse; // v[ 0, 1]
|
||||
uniform float _Ambient; // v[ 0, 1]
|
||||
|
||||
uniform fixed4 _UnderlayColor; // RGBA : Color + Opacity
|
||||
uniform float _UnderlayOffsetX; // v[-1, 1]
|
||||
uniform float _UnderlayOffsetY; // v[-1, 1]
|
||||
uniform float _UnderlayDilate; // v[-1, 1]
|
||||
uniform float _UnderlaySoftness; // v[ 0, 1]
|
||||
|
||||
uniform fixed4 _GlowColor; // RGBA : Color + Intesity
|
||||
uniform float _GlowOffset; // v[-1, 1]
|
||||
uniform float _GlowOuter; // v[ 0, 1]
|
||||
uniform float _GlowInner; // v[ 0, 1]
|
||||
uniform float _GlowPower; // v[ 1, 1/(1+4*4)]
|
||||
|
||||
// API Editable properties
|
||||
uniform float _ShaderFlags;
|
||||
uniform float _WeightNormal;
|
||||
uniform float _WeightBold;
|
||||
|
||||
uniform float _ScaleRatioA;
|
||||
uniform float _ScaleRatioB;
|
||||
uniform float _ScaleRatioC;
|
||||
|
||||
uniform float _VertexOffsetX;
|
||||
uniform float _VertexOffsetY;
|
||||
|
||||
//uniform float _UseClipRect;
|
||||
uniform float _MaskID;
|
||||
uniform sampler2D _MaskTex;
|
||||
uniform float4 _MaskCoord;
|
||||
uniform float4 _ClipRect; // bottom left(x,y) : top right(z,w)
|
||||
//uniform float _MaskWipeControl;
|
||||
//uniform float _MaskEdgeSoftness;
|
||||
//uniform fixed4 _MaskEdgeColor;
|
||||
//uniform bool _MaskInverse;
|
||||
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
|
||||
// Font Atlas properties
|
||||
uniform sampler2D _MainTex;
|
||||
uniform float _TextureWidth;
|
||||
uniform float _TextureHeight;
|
||||
uniform float _GradientScale;
|
||||
uniform float _ScaleX;
|
||||
uniform float _ScaleY;
|
||||
uniform float _PerspectiveFilter;
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3997e2241185407d80309a82f9148466
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
115
Assets/TextMesh Pro/Resources/Shaders/TMPro_Surface.cginc
Normal file
115
Assets/TextMesh Pro/Resources/Shaders/TMPro_Surface.cginc
Normal file
|
@ -0,0 +1,115 @@
|
|||
void VertShader(inout appdata_full v, out Input data)
|
||||
{
|
||||
v.vertex.x += _VertexOffsetX;
|
||||
v.vertex.y += _VertexOffsetY;
|
||||
|
||||
UNITY_INITIALIZE_OUTPUT(Input, data);
|
||||
|
||||
float bold = step(v.texcoord1.y, 0);
|
||||
|
||||
// Generate normal for backface
|
||||
float3 view = ObjSpaceViewDir(v.vertex);
|
||||
v.normal *= sign(dot(v.normal, view));
|
||||
|
||||
#if USE_DERIVATIVE
|
||||
data.param.y = 1;
|
||||
#else
|
||||
float4 vert = v.vertex;
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
float2 pixelSize = vPosition.w;
|
||||
|
||||
pixelSize /= float2(_ScaleX, _ScaleY) * mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy);
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize));
|
||||
scale *= abs(v.texcoord1.y) * _GradientScale * 1.5;
|
||||
scale = lerp(scale * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(v.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
|
||||
data.param.y = scale;
|
||||
#endif
|
||||
|
||||
//float opacity = v.color.a;
|
||||
|
||||
data.param.x = (lerp(_WeightNormal, _WeightBold, bold) / 4.0 + _FaceDilate) * _ScaleRatioA * 0.5; //
|
||||
|
||||
v.texcoord1.xy = UnpackUV(v.texcoord1.x);
|
||||
data.viewDirEnv = mul((float3x3)_EnvMatrix, WorldSpaceViewDir(v.vertex));
|
||||
}
|
||||
|
||||
void PixShader(Input input, inout SurfaceOutput o)
|
||||
{
|
||||
|
||||
#if USE_DERIVATIVE | BEVEL_ON
|
||||
float3 delta = float3(1.0 / _TextureWidth, 1.0 / _TextureHeight, 0.0);
|
||||
|
||||
float4 smp4x = { tex2D(_MainTex, input.uv_MainTex - delta.xz).a,
|
||||
tex2D(_MainTex, input.uv_MainTex + delta.xz).a,
|
||||
tex2D(_MainTex, input.uv_MainTex - delta.zy).a,
|
||||
tex2D(_MainTex, input.uv_MainTex + delta.zy).a };
|
||||
#endif
|
||||
|
||||
#if USE_DERIVATIVE
|
||||
// Screen space scaling reciprocal with anisotropic correction
|
||||
float2 edgeNormal = Normalize(float2(smp4x.x - smp4x.y, smp4x.z - smp4x.w));
|
||||
float2 res = float2(_TextureWidth * input.param.y, _TextureHeight);
|
||||
float2 tdx = ddx(input.uv_MainTex)*res;
|
||||
float2 tdy = ddy(input.uv_MainTex)*res;
|
||||
float lx = length(tdx);
|
||||
float ly = length(tdy);
|
||||
float s = sqrt(min(lx, ly) / max(lx, ly));
|
||||
s = lerp(1, s, abs(dot(normalize(tdx + tdy), edgeNormal)));
|
||||
float scale = rsqrt(abs(tdx.x * tdy.y - tdx.y * tdy.x)) * (_GradientScale * 2) * s;
|
||||
#else
|
||||
float scale = input.param.y;
|
||||
#endif
|
||||
|
||||
// Signed distance
|
||||
float c = tex2D(_MainTex, input.uv_MainTex).a;
|
||||
float sd = (.5 - c - input.param.x) * scale + .5;
|
||||
float outline = _OutlineWidth*_ScaleRatioA * scale;
|
||||
float softness = _OutlineSoftness*_ScaleRatioA * scale;
|
||||
|
||||
// Color & Alpha
|
||||
float4 faceColor = _FaceColor;
|
||||
float4 outlineColor = _OutlineColor;
|
||||
faceColor *= input.color;
|
||||
outlineColor.a *= input.color.a;
|
||||
faceColor *= tex2D(_FaceTex, float2(input.uv2_FaceTex.x + _FaceUVSpeedX * _Time.y, input.uv2_FaceTex.y + _FaceUVSpeedY * _Time.y));
|
||||
outlineColor *= tex2D(_OutlineTex, float2(input.uv2_OutlineTex.x + _OutlineUVSpeedX * _Time.y, input.uv2_OutlineTex.y + _OutlineUVSpeedY * _Time.y));
|
||||
faceColor = GetColor(sd, faceColor, outlineColor, outline, softness);
|
||||
faceColor.rgb /= max(faceColor.a, 0.0001);
|
||||
|
||||
|
||||
#if BEVEL_ON
|
||||
// Face Normal
|
||||
float3 n = GetSurfaceNormal(smp4x, input.param.x);
|
||||
|
||||
// Bumpmap
|
||||
float3 bump = UnpackNormal(tex2D(_BumpMap, input.uv2_FaceTex.xy)).xyz;
|
||||
bump *= lerp(_BumpFace, _BumpOutline, saturate(sd + outline * 0.5));
|
||||
bump = lerp(float3(0, 0, 1), bump, faceColor.a);
|
||||
n = normalize(n - bump);
|
||||
|
||||
// Cubemap reflection
|
||||
fixed4 reflcol = texCUBE(_Cube, reflect(input.viewDirEnv, mul((float3x3)unity_ObjectToWorld, n)));
|
||||
float3 emission = reflcol.rgb * lerp(_ReflectFaceColor.rgb, _ReflectOutlineColor.rgb, saturate(sd + outline * 0.5)) * faceColor.a;
|
||||
#else
|
||||
float3 n = float3(0, 0, -1);
|
||||
float3 emission = float3(0, 0, 0);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if GLOW_ON
|
||||
float4 glowColor = GetGlowColor(sd, scale);
|
||||
glowColor.a *= input.color.a;
|
||||
emission += glowColor.rgb*glowColor.a;
|
||||
faceColor = BlendARGB(glowColor, faceColor);
|
||||
faceColor.rgb /= max(faceColor.a, 0.0001);
|
||||
#endif
|
||||
|
||||
// Set Standard output structure
|
||||
o.Albedo = faceColor.rgb;
|
||||
o.Normal = -n;
|
||||
o.Emission = emission;
|
||||
o.Specular = lerp(_FaceShininess, _OutlineShininess, saturate(sd + outline * 0.5));
|
||||
o.Gloss = 1;
|
||||
o.Alpha = faceColor.a;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d930090c0cd643c7b55f19a38538c162
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/TextMesh Pro/Resources/Sprite Assets.meta
Normal file
9
Assets/TextMesh Pro/Resources/Sprite Assets.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 512a49d95c0c4332bdd98131869c23c9
|
||||
folderAsset: yes
|
||||
timeCreated: 1441876896
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
296
Assets/TextMesh Pro/Resources/Sprite Assets/EmojiOne.asset
Normal file
296
Assets/TextMesh Pro/Resources/Sprite Assets/EmojiOne.asset
Normal file
|
@ -0,0 +1,296 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2103686
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: TextMeshPro/Sprite
|
||||
m_Shader: {fileID: 4800000, guid: cf81c85f95fe47e1a27f6ae460cf182c, type: 3}
|
||||
m_ShaderKeywords: UNITY_UI_CLIP_RECT
|
||||
m_LightmapFlags: 5
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: dffef66376be4fa480fb02b19edbe903, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _ColorMask: 15
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UseUIAlphaClip: 0
|
||||
m_Colors:
|
||||
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 84a92b25f83d49b9bc132d206b370281, type: 3}
|
||||
m_Name: EmojiOne
|
||||
m_EditorClassIdentifier:
|
||||
hashCode: -1836805472
|
||||
material: {fileID: 2103686}
|
||||
materialHashCode: 0
|
||||
spriteSheet: {fileID: 2800000, guid: dffef66376be4fa480fb02b19edbe903, type: 3}
|
||||
spriteInfoList:
|
||||
- id: 0
|
||||
x: 0
|
||||
y: 384
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f60a
|
||||
hashCode: 57188336
|
||||
unicode: 128522
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 1
|
||||
x: 128
|
||||
y: 384
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f60b
|
||||
hashCode: 57188339
|
||||
unicode: 128523
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 2
|
||||
x: 256
|
||||
y: 384
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f60d
|
||||
hashCode: 57188341
|
||||
unicode: 128525
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 3
|
||||
x: 384
|
||||
y: 384
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f60e
|
||||
hashCode: 57188340
|
||||
unicode: 128526
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 4
|
||||
x: 0
|
||||
y: 256
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f600
|
||||
hashCode: 57188257
|
||||
unicode: 128512
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 5
|
||||
x: 128
|
||||
y: 256
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f601
|
||||
hashCode: 57188256
|
||||
unicode: 128513
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 6
|
||||
x: 256
|
||||
y: 256
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f602
|
||||
hashCode: 57188259
|
||||
unicode: 128514
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 7
|
||||
x: 384
|
||||
y: 256
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f603
|
||||
hashCode: 57188258
|
||||
unicode: 128515
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 8
|
||||
x: 0
|
||||
y: 128
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f604
|
||||
hashCode: 57188261
|
||||
unicode: 128516
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 9
|
||||
x: 128
|
||||
y: 128
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f605
|
||||
hashCode: 57188260
|
||||
unicode: 128517
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 10
|
||||
x: 256
|
||||
y: 128
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f606
|
||||
hashCode: 57188263
|
||||
unicode: 128518
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 11
|
||||
x: 384
|
||||
y: 128
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f609
|
||||
hashCode: 57188264
|
||||
unicode: 128521
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 12
|
||||
x: 0
|
||||
y: 0
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f618
|
||||
hashCode: 57188168
|
||||
unicode: 128536
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 13
|
||||
x: 128
|
||||
y: 0
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 1f923
|
||||
hashCode: 57200239
|
||||
unicode: 129315
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 14
|
||||
x: 256
|
||||
y: 0
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 263a
|
||||
hashCode: 1748406
|
||||
unicode: 9786
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
- id: 15
|
||||
x: 384
|
||||
y: 0
|
||||
width: 128
|
||||
height: 128
|
||||
xOffset: 0
|
||||
yOffset: 115.6
|
||||
xAdvance: 128
|
||||
scale: 1
|
||||
name: 2639
|
||||
hashCode: 1748462
|
||||
unicode: 9785
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
sprite: {fileID: 0}
|
||||
fallbackSpriteAssets: []
|
||||
--- !u!21 &1369835458
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: TextMeshPro/Sprite
|
||||
m_Shader: {fileID: 4800000, guid: cf81c85f95fe47e1a27f6ae460cf182c, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 5
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs: []
|
||||
m_Floats: []
|
||||
m_Colors: []
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c41005c129ba4d66911b75229fd70b45
|
||||
timeCreated: 1480316912
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/TextMesh Pro/Resources/Style Sheets.meta
Normal file
9
Assets/TextMesh Pro/Resources/Style Sheets.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4aecb92fff08436c8303b10eab8da368
|
||||
folderAsset: yes
|
||||
timeCreated: 1441876950
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,68 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ab2114bdc8544297b417dfefe9f1e410, type: 3}
|
||||
m_Name: Default Style Sheet
|
||||
m_EditorClassIdentifier:
|
||||
m_StyleList:
|
||||
- m_Name: H1
|
||||
m_HashCode: 2425
|
||||
m_OpeningDefinition: <size=2em><b><#40ff80>*
|
||||
m_ClosingDefinition: '*</size></b></color>'
|
||||
m_OpeningTagArray: 3c00000073000000690000007a000000650000003d00000032000000650000006d0000003e0000003c000000620000003e0000003c000000230000003400000030000000660000006600000038000000300000003e0000002a000000
|
||||
m_ClosingTagArray: 2a0000003c0000002f00000073000000690000007a000000650000003e0000003c0000002f000000620000003e0000003c0000002f000000630000006f0000006c0000006f000000720000003e000000
|
||||
- m_Name: Quote
|
||||
m_HashCode: 92254330
|
||||
m_OpeningDefinition: <i><size=75%><margin=10%>
|
||||
m_ClosingDefinition: </i></size></width></margin>
|
||||
m_OpeningTagArray: 3c000000690000003e0000003c00000073000000690000007a000000650000003d0000003700000035000000250000003e0000003c0000006d000000610000007200000067000000690000006e0000003d0000003100000030000000250000003e000000
|
||||
m_ClosingTagArray: 3c0000002f000000690000003e0000003c0000002f00000073000000690000007a000000650000003e0000003c0000002f00000077000000690000006400000074000000680000003e0000003c0000002f0000006d000000610000007200000067000000690000006e0000003e000000
|
||||
- m_Name: Link
|
||||
m_HashCode: 2687968
|
||||
m_OpeningDefinition: <u><#40a0ff><link="ID_01>
|
||||
m_ClosingDefinition: </u></color></link>
|
||||
m_OpeningTagArray: 3c000000750000003e0000003c000000230000003400000030000000610000003000000066000000660000003e0000003c0000006c000000690000006e0000006b0000003d0000002200000049000000440000005f00000030000000310000003e000000
|
||||
m_ClosingTagArray: 3c0000002f000000750000003e0000003c0000002f000000630000006f0000006c0000006f000000720000003e0000003c0000002f0000006c000000690000006e0000006b0000003e000000
|
||||
- m_Name: Title
|
||||
m_HashCode: 98732960
|
||||
m_OpeningDefinition: <size=125%><b><align=center>
|
||||
m_ClosingDefinition: </size></b></align>
|
||||
m_OpeningTagArray: 3c00000073000000690000007a000000650000003d000000310000003200000035000000250000003e0000003c000000620000003e0000003c000000610000006c00000069000000670000006e0000003d00000063000000650000006e0000007400000065000000720000003e000000
|
||||
m_ClosingTagArray: 3c0000002f00000073000000690000007a000000650000003e0000003c0000002f000000620000003e0000003c0000002f000000610000006c00000069000000670000006e0000003e000000
|
||||
- m_Name: H2
|
||||
m_HashCode: 2426
|
||||
m_OpeningDefinition: <size=1.5em><b><#4080FF>
|
||||
m_ClosingDefinition: </size></b></color>
|
||||
m_OpeningTagArray: 3c00000073000000690000007a000000650000003d000000310000002e00000035000000650000006d0000003e0000003c000000620000003e0000003c000000230000003400000030000000380000003000000046000000460000003e000000
|
||||
m_ClosingTagArray: 3c0000002f00000073000000690000007a000000650000003e0000003c0000002f000000620000003e0000003c0000002f000000630000006f0000006c0000006f000000720000003e000000
|
||||
- m_Name: H3
|
||||
m_HashCode: 2427
|
||||
m_OpeningDefinition: <size=1.17em><b><#FF8040>
|
||||
m_ClosingDefinition: </size></b></color>
|
||||
m_OpeningTagArray: 3c00000073000000690000007a000000650000003d000000310000002e0000003100000037000000650000006d0000003e0000003c000000620000003e0000003c000000230000004600000046000000380000003000000034000000300000003e000000
|
||||
m_ClosingTagArray: 3c0000002f00000073000000690000007a000000650000003e0000003c0000002f000000620000003e0000003c0000002f000000630000006f0000006c0000006f000000720000003e000000
|
||||
- m_Name: C1
|
||||
m_HashCode: 2194
|
||||
m_OpeningDefinition: <color=#ffff40>
|
||||
m_ClosingDefinition: </color>
|
||||
m_OpeningTagArray: 3c000000630000006f0000006c0000006f000000720000003d000000230000006600000066000000660000006600000034000000300000003e000000
|
||||
m_ClosingTagArray: 3c0000002f000000630000006f0000006c0000006f000000720000003e000000
|
||||
- m_Name: C2
|
||||
m_HashCode: 2193
|
||||
m_OpeningDefinition: <color=#ff40FF><size=125%>
|
||||
m_ClosingDefinition: </color></size>
|
||||
m_OpeningTagArray: 3c000000630000006f0000006c0000006f000000720000003d000000230000006600000066000000340000003000000046000000460000003e0000003c00000073000000690000007a000000650000003d000000310000003200000035000000250000003e000000
|
||||
m_ClosingTagArray: 3c0000002f000000630000006f0000006c0000006f000000720000003e0000003c0000002f00000073000000690000007a000000650000003e000000
|
||||
- m_Name: C3
|
||||
m_HashCode: 2192
|
||||
m_OpeningDefinition: <color=#80A0FF><b>
|
||||
m_ClosingDefinition: </color></b>
|
||||
m_OpeningTagArray: 3c000000630000006f0000006c0000006f000000720000003d000000230000003800000030000000410000003000000046000000460000003e0000003c000000620000003e000000
|
||||
m_ClosingTagArray: 3c0000002f000000630000006f0000006c0000006f000000720000003e0000003c0000002f000000620000003e000000
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f952c082cb03451daed3ee968ac6c63e
|
||||
timeCreated: 1432805430
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
41
Assets/TextMesh Pro/Resources/TMP Settings.asset
Normal file
41
Assets/TextMesh Pro/Resources/TMP Settings.asset
Normal file
|
@ -0,0 +1,41 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2705215ac5b84b70bacc50632be6e391, type: 3}
|
||||
m_Name: TMP Settings
|
||||
m_EditorClassIdentifier:
|
||||
m_version: 1.0.56.0b1
|
||||
m_enableWordWrapping: 1
|
||||
m_enableKerning: 1
|
||||
m_enableExtraPadding: 0
|
||||
m_enableTintAllSprites: 0
|
||||
m_enableParseEscapeCharacters: 1
|
||||
m_missingGlyphCharacter: 0
|
||||
m_warningsDisabled: 0
|
||||
m_defaultFontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_defaultFontAssetPath: Fonts & Materials/
|
||||
m_defaultFontSize: 36
|
||||
m_defaultAutoSizeMinRatio: 0.5
|
||||
m_defaultAutoSizeMaxRatio: 2
|
||||
m_defaultTextMeshProTextContainerSize: {x: 20, y: 5}
|
||||
m_defaultTextMeshProUITextContainerSize: {x: 200, y: 50}
|
||||
m_autoSizeTextContainer: 0
|
||||
m_fallbackFontAssets: []
|
||||
m_matchMaterialPreset: 1
|
||||
m_defaultSpriteAsset: {fileID: 11400000, guid: c41005c129ba4d66911b75229fd70b45,
|
||||
type: 2}
|
||||
m_defaultSpriteAssetPath: Sprite Assets/
|
||||
m_defaultColorGradientPresetsPath: Color Gradient Presets/
|
||||
m_enableEmojiSupport: 1
|
||||
m_defaultStyleSheet: {fileID: 11400000, guid: f952c082cb03451daed3ee968ac6c63e,
|
||||
type: 2}
|
||||
m_leadingCharacters: {fileID: 4900000, guid: d82c1b31c7e74239bff1220585707d2b, type: 3}
|
||||
m_followingCharacters: {fileID: 4900000, guid: fade42e8bc714b018fac513c043d323b,
|
||||
type: 3}
|
8
Assets/TextMesh Pro/Resources/TMP Settings.asset.meta
Normal file
8
Assets/TextMesh Pro/Resources/TMP Settings.asset.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3f5b5dff67a942289a9defa416b206f3
|
||||
timeCreated: 1436653997
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/TextMesh Pro/Scripts/Editor.meta
Normal file
8
Assets/TextMesh Pro/Scripts/Editor.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b5d6c28ed7b94775be9e2560f300247c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/TextMesh Pro/Scripts/Runtime.meta
Normal file
8
Assets/TextMesh Pro/Scripts/Runtime.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5fc988a1d5b04aee9a5222502b201a45
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
150
Assets/TextMesh Pro/Scripts/Runtime/FastAction.cs
Normal file
150
Assets/TextMesh Pro/Scripts/Runtime/FastAction.cs
Normal file
|
@ -0,0 +1,150 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
public class FastAction
|
||||
{
|
||||
|
||||
LinkedList<System.Action> delegates = new LinkedList<System.Action>();
|
||||
|
||||
Dictionary<System.Action, LinkedListNode<System.Action>> lookup = new Dictionary<System.Action, LinkedListNode<System.Action>>();
|
||||
|
||||
public void Add(System.Action rhs)
|
||||
{
|
||||
if (lookup.ContainsKey(rhs)) return;
|
||||
|
||||
lookup[rhs] = delegates.AddLast(rhs);
|
||||
}
|
||||
|
||||
public void Remove(System.Action rhs)
|
||||
{
|
||||
LinkedListNode<System.Action> node;
|
||||
if (lookup.TryGetValue(rhs, out node))
|
||||
{
|
||||
lookup.Remove(rhs);
|
||||
delegates.Remove(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void Call()
|
||||
{
|
||||
var node = delegates.First;
|
||||
while (node != null)
|
||||
{
|
||||
node.Value();
|
||||
node = node.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class FastAction<A>
|
||||
{
|
||||
|
||||
LinkedList<System.Action<A>> delegates = new LinkedList<System.Action<A>>();
|
||||
|
||||
Dictionary<System.Action<A>, LinkedListNode<System.Action<A>>> lookup = new Dictionary<System.Action<A>, LinkedListNode<System.Action<A>>>();
|
||||
|
||||
public void Add(System.Action<A> rhs)
|
||||
{
|
||||
if (lookup.ContainsKey(rhs)) return;
|
||||
|
||||
lookup[rhs] = delegates.AddLast(rhs);
|
||||
}
|
||||
|
||||
public void Remove(System.Action<A> rhs)
|
||||
{
|
||||
LinkedListNode<System.Action<A>> node;
|
||||
if (lookup.TryGetValue(rhs, out node))
|
||||
{
|
||||
lookup.Remove(rhs);
|
||||
delegates.Remove(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void Call(A a)
|
||||
{
|
||||
var node = delegates.First;
|
||||
while (node != null)
|
||||
{
|
||||
node.Value(a);
|
||||
node = node.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class FastAction<A, B>
|
||||
{
|
||||
|
||||
LinkedList<System.Action<A, B>> delegates = new LinkedList<System.Action<A, B>>();
|
||||
|
||||
Dictionary<System.Action<A, B>, LinkedListNode<System.Action<A, B>>> lookup = new Dictionary<System.Action<A, B>, LinkedListNode<System.Action<A, B>>>();
|
||||
|
||||
public void Add(System.Action<A, B> rhs)
|
||||
{
|
||||
if (lookup.ContainsKey(rhs)) return;
|
||||
|
||||
lookup[rhs] = delegates.AddLast(rhs);
|
||||
}
|
||||
|
||||
public void Remove(System.Action<A, B> rhs)
|
||||
{
|
||||
LinkedListNode<System.Action<A, B>> node;
|
||||
if (lookup.TryGetValue(rhs, out node))
|
||||
{
|
||||
lookup.Remove(rhs);
|
||||
delegates.Remove(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void Call(A a, B b)
|
||||
{
|
||||
var node = delegates.First;
|
||||
while (node != null)
|
||||
{
|
||||
node.Value(a, b);
|
||||
node = node.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class FastAction<A, B, C>
|
||||
{
|
||||
|
||||
LinkedList<System.Action<A, B, C>> delegates = new LinkedList<System.Action<A, B, C>>();
|
||||
|
||||
Dictionary<System.Action<A, B, C>, LinkedListNode<System.Action<A, B, C>>> lookup = new Dictionary<System.Action<A, B, C>, LinkedListNode<System.Action<A, B, C>>>();
|
||||
|
||||
public void Add(System.Action<A, B, C> rhs)
|
||||
{
|
||||
if (lookup.ContainsKey(rhs)) return;
|
||||
|
||||
lookup[rhs] = delegates.AddLast(rhs);
|
||||
}
|
||||
|
||||
public void Remove(System.Action<A, B, C> rhs)
|
||||
{
|
||||
LinkedListNode<System.Action<A, B, C>> node;
|
||||
if (lookup.TryGetValue(rhs, out node))
|
||||
{
|
||||
lookup.Remove(rhs);
|
||||
delegates.Remove(node);
|
||||
}
|
||||
}
|
||||
|
||||
public void Call(A a, B b, C c)
|
||||
{
|
||||
var node = delegates.First;
|
||||
while (node != null)
|
||||
{
|
||||
node.Value(a, b, c);
|
||||
node = node.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
Assets/TextMesh Pro/Scripts/Runtime/FastAction.cs.meta
Normal file
12
Assets/TextMesh Pro/Scripts/Runtime/FastAction.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 871f8edd56e84b8fb295b10cc3c78f36
|
||||
timeCreated: 1435956061
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
646
Assets/TextMesh Pro/Scripts/Runtime/MaterialReferenceManager.cs
Normal file
646
Assets/TextMesh Pro/Scripts/Runtime/MaterialReferenceManager.cs
Normal file
|
@ -0,0 +1,646 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
|
||||
public class MaterialReferenceManager
|
||||
{
|
||||
private static MaterialReferenceManager s_Instance;
|
||||
|
||||
// Dictionaries used to track Asset references.
|
||||
private Dictionary<int, Material> m_FontMaterialReferenceLookup = new Dictionary<int, Material>();
|
||||
private Dictionary<int, TMP_FontAsset> m_FontAssetReferenceLookup = new Dictionary<int, TMP_FontAsset>();
|
||||
private Dictionary<int, TMP_SpriteAsset> m_SpriteAssetReferenceLookup = new Dictionary<int, TMP_SpriteAsset>();
|
||||
private Dictionary<int, TMP_ColorGradient> m_ColorGradientReferenceLookup = new Dictionary<int, TMP_ColorGradient>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a singleton instance of the registry
|
||||
/// </summary>
|
||||
public static MaterialReferenceManager instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (MaterialReferenceManager.s_Instance == null)
|
||||
MaterialReferenceManager.s_Instance = new MaterialReferenceManager();
|
||||
return MaterialReferenceManager.s_Instance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add new font asset reference to dictionary.
|
||||
/// </summary>
|
||||
/// <param name="fontAsset"></param>
|
||||
public static void AddFontAsset(TMP_FontAsset fontAsset)
|
||||
{
|
||||
MaterialReferenceManager.instance.AddFontAssetInternal(fontAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add new Font Asset reference to dictionary.
|
||||
/// </summary>
|
||||
/// <param name="fontAsset"></param>
|
||||
private void AddFontAssetInternal(TMP_FontAsset fontAsset)
|
||||
{
|
||||
if (m_FontAssetReferenceLookup.ContainsKey(fontAsset.hashCode)) return;
|
||||
|
||||
// Add reference to the font asset.
|
||||
m_FontAssetReferenceLookup.Add(fontAsset.hashCode, fontAsset);
|
||||
|
||||
// Add reference to the font material.
|
||||
m_FontMaterialReferenceLookup.Add(fontAsset.materialHashCode, fontAsset.material);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add new Sprite Asset to dictionary.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
public static void AddSpriteAsset(TMP_SpriteAsset spriteAsset)
|
||||
{
|
||||
MaterialReferenceManager.instance.AddSpriteAssetInternal(spriteAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to add a new sprite asset to the dictionary.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
private void AddSpriteAssetInternal(TMP_SpriteAsset spriteAsset)
|
||||
{
|
||||
if (m_SpriteAssetReferenceLookup.ContainsKey(spriteAsset.hashCode)) return;
|
||||
|
||||
// Add reference to sprite asset.
|
||||
m_SpriteAssetReferenceLookup.Add(spriteAsset.hashCode, spriteAsset);
|
||||
|
||||
// Adding reference to the sprite asset material as well
|
||||
m_FontMaterialReferenceLookup.Add(spriteAsset.hashCode, spriteAsset.material);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add new Sprite Asset to dictionary.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
public static void AddSpriteAsset(int hashCode, TMP_SpriteAsset spriteAsset)
|
||||
{
|
||||
MaterialReferenceManager.instance.AddSpriteAssetInternal(hashCode, spriteAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to add a new sprite asset to the dictionary.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
private void AddSpriteAssetInternal(int hashCode, TMP_SpriteAsset spriteAsset)
|
||||
{
|
||||
if (m_SpriteAssetReferenceLookup.ContainsKey(hashCode)) return;
|
||||
|
||||
// Add reference to Sprite Asset.
|
||||
m_SpriteAssetReferenceLookup.Add(hashCode, spriteAsset);
|
||||
|
||||
// Add reference to Sprite Asset using the asset hashcode.
|
||||
m_FontMaterialReferenceLookup.Add(hashCode, spriteAsset.material);
|
||||
|
||||
// Compatibility check
|
||||
if (spriteAsset.hashCode == 0) spriteAsset.hashCode = hashCode;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add new Material reference to dictionary.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="material"></param>
|
||||
public static void AddFontMaterial(int hashCode, Material material)
|
||||
{
|
||||
MaterialReferenceManager.instance.AddFontMaterialInternal(hashCode, material);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add new material reference to dictionary.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="material"></param>
|
||||
private void AddFontMaterialInternal(int hashCode, Material material)
|
||||
{
|
||||
// Since this function is called after checking if the material is
|
||||
// contained in the dictionary, there is no need to check again.
|
||||
m_FontMaterialReferenceLookup.Add(hashCode, material);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add new Color Gradient Preset to dictionary.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
public static void AddColorGradientPreset(int hashCode, TMP_ColorGradient spriteAsset)
|
||||
{
|
||||
MaterialReferenceManager.instance.AddColorGradientPreset_Internal(hashCode, spriteAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal method to add a new Color Gradient Preset to the dictionary.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
private void AddColorGradientPreset_Internal(int hashCode, TMP_ColorGradient spriteAsset)
|
||||
{
|
||||
if (m_ColorGradientReferenceLookup.ContainsKey(hashCode)) return;
|
||||
|
||||
// Add reference to Color Gradient Preset Asset.
|
||||
m_ColorGradientReferenceLookup.Add(hashCode, spriteAsset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add new material reference and return the index of this new reference in the materialReferences array.
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
/// <param name="materialHashCode"></param>
|
||||
/// <param name="fontAsset"></param>
|
||||
//public int AddMaterial(Material material, int materialHashCode, TMP_FontAsset fontAsset)
|
||||
//{
|
||||
// if (!m_MaterialReferenceLookup.ContainsKey(materialHashCode))
|
||||
// {
|
||||
// int index = m_MaterialReferenceLookup.Count;
|
||||
|
||||
// materialReferences[index].fontAsset = fontAsset;
|
||||
// materialReferences[index].material = material;
|
||||
// materialReferences[index].isDefaultMaterial = material.GetInstanceID() == fontAsset.material.GetInstanceID() ? true : false;
|
||||
// materialReferences[index].index = index;
|
||||
// materialReferences[index].referenceCount = 0;
|
||||
|
||||
// m_MaterialReferenceLookup[materialHashCode] = index;
|
||||
|
||||
// // Compute Padding value and store it
|
||||
// // TODO
|
||||
|
||||
// int fontAssetHashCode = fontAsset.hashCode;
|
||||
|
||||
// if (!m_FontAssetReferenceLookup.ContainsKey(fontAssetHashCode))
|
||||
// m_FontAssetReferenceLookup.Add(fontAssetHashCode, fontAsset);
|
||||
|
||||
// m_countInternal += 1;
|
||||
|
||||
// return index;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return m_MaterialReferenceLookup[materialHashCode];
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add new material reference and return the index of this new reference in the materialReferences array.
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
/// <param name="materialHashCode"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
/// <returns></returns>
|
||||
//public int AddMaterial(Material material, int materialHashCode, TMP_SpriteAsset spriteAsset)
|
||||
//{
|
||||
// if (!m_MaterialReferenceLookup.ContainsKey(materialHashCode))
|
||||
// {
|
||||
// int index = m_MaterialReferenceLookup.Count;
|
||||
|
||||
// materialReferences[index].fontAsset = materialReferences[0].fontAsset;
|
||||
// materialReferences[index].spriteAsset = spriteAsset;
|
||||
// materialReferences[index].material = material;
|
||||
// materialReferences[index].isDefaultMaterial = true;
|
||||
// materialReferences[index].index = index;
|
||||
// materialReferences[index].referenceCount = 0;
|
||||
|
||||
// m_MaterialReferenceLookup[materialHashCode] = index;
|
||||
|
||||
// int spriteAssetHashCode = spriteAsset.hashCode;
|
||||
|
||||
// if (!m_SpriteAssetReferenceLookup.ContainsKey(spriteAssetHashCode))
|
||||
// m_SpriteAssetReferenceLookup.Add(spriteAssetHashCode, spriteAsset);
|
||||
|
||||
// m_countInternal += 1;
|
||||
|
||||
// return index;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return m_MaterialReferenceLookup[materialHashCode];
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to check if the font asset is already referenced.
|
||||
/// </summary>
|
||||
/// <param name="font"></param>
|
||||
/// <returns></returns>
|
||||
public bool Contains(TMP_FontAsset font)
|
||||
{
|
||||
if (m_FontAssetReferenceLookup.ContainsKey(font.hashCode))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to check if the sprite asset is already referenced.
|
||||
/// </summary>
|
||||
/// <param name="font"></param>
|
||||
/// <returns></returns>
|
||||
public bool Contains(TMP_SpriteAsset sprite)
|
||||
{
|
||||
if (m_FontAssetReferenceLookup.ContainsKey(sprite.hashCode))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function returning the Font Asset corresponding to the provided hash code.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="fontAsset"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGetFontAsset(int hashCode, out TMP_FontAsset fontAsset)
|
||||
{
|
||||
return MaterialReferenceManager.instance.TryGetFontAssetInternal(hashCode, out fontAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal Function returning the Font Asset corresponding to the provided hash code.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="fontAsset"></param>
|
||||
/// <returns></returns>
|
||||
private bool TryGetFontAssetInternal(int hashCode, out TMP_FontAsset fontAsset)
|
||||
{
|
||||
fontAsset = null;
|
||||
|
||||
if (m_FontAssetReferenceLookup.TryGetValue(hashCode, out fontAsset))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function returning the Sprite Asset corresponding to the provided hash code.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGetSpriteAsset(int hashCode, out TMP_SpriteAsset spriteAsset)
|
||||
{
|
||||
return MaterialReferenceManager.instance.TryGetSpriteAssetInternal(hashCode, out spriteAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal function returning the Sprite Asset corresponding to the provided hash code.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="fontAsset"></param>
|
||||
/// <returns></returns>
|
||||
private bool TryGetSpriteAssetInternal(int hashCode, out TMP_SpriteAsset spriteAsset)
|
||||
{
|
||||
spriteAsset = null;
|
||||
|
||||
if (m_SpriteAssetReferenceLookup.TryGetValue(hashCode, out spriteAsset))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function returning the Color Gradient Preset corresponding to the provided hash code.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="gradientPreset"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGetColorGradientPreset(int hashCode, out TMP_ColorGradient gradientPreset)
|
||||
{
|
||||
return MaterialReferenceManager.instance.TryGetColorGradientPresetInternal(hashCode, out gradientPreset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal function returning the Color Gradient Preset corresponding to the provided hash code.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="fontAsset"></param>
|
||||
/// <returns></returns>
|
||||
private bool TryGetColorGradientPresetInternal(int hashCode, out TMP_ColorGradient gradientPreset)
|
||||
{
|
||||
gradientPreset = null;
|
||||
|
||||
if (m_ColorGradientReferenceLookup.TryGetValue(hashCode, out gradientPreset))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function returning the Font Material corresponding to the provided hash code.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="material"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGetMaterial(int hashCode, out Material material)
|
||||
{
|
||||
return MaterialReferenceManager.instance.TryGetMaterialInternal(hashCode, out material);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal function returning the Font Material corresponding to the provided hash code.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="material"></param>
|
||||
/// <returns></returns>
|
||||
private bool TryGetMaterialInternal(int hashCode, out Material material)
|
||||
{
|
||||
material = null;
|
||||
|
||||
if (m_FontMaterialReferenceLookup.TryGetValue(hashCode, out material))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to lookup a material based on hash code and returning the MaterialReference containing this material.
|
||||
/// </summary>
|
||||
/// <param name="hashCode"></param>
|
||||
/// <param name="material"></param>
|
||||
/// <returns></returns>
|
||||
//public bool TryGetMaterial(int hashCode, out MaterialReference materialReference)
|
||||
//{
|
||||
// int materialIndex = -1;
|
||||
|
||||
// if (m_MaterialReferenceLookup.TryGetValue(hashCode, out materialIndex))
|
||||
// {
|
||||
// materialReference = materialReferences[materialIndex];
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// materialReference = new MaterialReference();
|
||||
|
||||
// return false;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="fontAsset"></param>
|
||||
/// <returns></returns>
|
||||
//public int GetMaterialIndex(TMP_FontAsset fontAsset)
|
||||
//{
|
||||
// if (m_MaterialReferenceLookup.ContainsKey(fontAsset.materialHashCode))
|
||||
// return m_MaterialReferenceLookup[fontAsset.materialHashCode];
|
||||
|
||||
// return -1;
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
//public TMP_FontAsset GetFontAsset(int index)
|
||||
//{
|
||||
// if (index >= 0 && index < materialReferences.Length)
|
||||
// return materialReferences[index].fontAsset;
|
||||
|
||||
// return null;
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
/// <param name="materialHashCode"></param>
|
||||
/// <param name="fontAsset"></param>
|
||||
//public void SetDefaultMaterial(Material material, int materialHashCode, TMP_FontAsset fontAsset)
|
||||
//{
|
||||
// if (!m_MaterialReferenceLookup.ContainsKey(materialHashCode))
|
||||
// {
|
||||
// materialReferences[0].fontAsset = fontAsset;
|
||||
// materialReferences[0].material = material;
|
||||
// materialReferences[0].index = 0;
|
||||
// materialReferences[0].isDefaultMaterial = material.GetInstanceID() == fontAsset.material.GetInstanceID() ? true : false;
|
||||
// materialReferences[0].referenceCount = 0;
|
||||
// m_MaterialReferenceLookup[materialHashCode] = 0;
|
||||
|
||||
// // Compute Padding value and store it
|
||||
// // TODO
|
||||
|
||||
// int fontHashCode = fontAsset.hashCode;
|
||||
|
||||
// if (!m_FontAssetReferenceLookup.ContainsKey(fontHashCode))
|
||||
// m_FontAssetReferenceLookup.Add(fontHashCode, fontAsset);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// materialReferences[0].fontAsset = fontAsset;
|
||||
// materialReferences[0].material = material;
|
||||
// materialReferences[0].index = 0;
|
||||
// materialReferences[0].referenceCount = 0;
|
||||
// m_MaterialReferenceLookup[materialHashCode] = 0;
|
||||
// }
|
||||
// // Compute padding
|
||||
// // TODO
|
||||
|
||||
// m_countInternal = 1;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//public void Clear()
|
||||
//{
|
||||
// //m_currentIndex = 0;
|
||||
// m_MaterialReferenceLookup.Clear();
|
||||
// m_SpriteAssetReferenceLookup.Clear();
|
||||
// m_FontAssetReferenceLookup.Clear();
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to clear the reference count for each of the material references.
|
||||
/// </summary>
|
||||
//public void ClearReferenceCount()
|
||||
//{
|
||||
// m_countInternal = 0;
|
||||
|
||||
// for (int i = 0; i < materialReferences.Length; i++)
|
||||
// {
|
||||
// if (materialReferences[i].fontAsset == null)
|
||||
// return;
|
||||
|
||||
// materialReferences[i].referenceCount = 0;
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public struct MaterialReference
|
||||
{
|
||||
|
||||
public int index;
|
||||
public TMP_FontAsset fontAsset;
|
||||
public TMP_SpriteAsset spriteAsset;
|
||||
public Material material;
|
||||
public bool isDefaultMaterial;
|
||||
public bool isFallbackMaterial;
|
||||
public Material fallbackMaterial;
|
||||
public float padding;
|
||||
public int referenceCount;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for new Material Reference.
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="fontAsset"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
/// <param name="material"></param>
|
||||
/// <param name="padding"></param>
|
||||
public MaterialReference(int index, TMP_FontAsset fontAsset, TMP_SpriteAsset spriteAsset, Material material, float padding)
|
||||
{
|
||||
this.index = index;
|
||||
this.fontAsset = fontAsset;
|
||||
this.spriteAsset = spriteAsset;
|
||||
this.material = material;
|
||||
this.isDefaultMaterial = material.GetInstanceID() == fontAsset.material.GetInstanceID() ? true : false;
|
||||
this.isFallbackMaterial = false;
|
||||
this.fallbackMaterial = null;
|
||||
this.padding = padding;
|
||||
this.referenceCount = 0;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to check if a certain font asset is contained in the material reference array.
|
||||
/// </summary>
|
||||
/// <param name="materialReferences"></param>
|
||||
/// <param name="fontAsset"></param>
|
||||
/// <returns></returns>
|
||||
public static bool Contains(MaterialReference[] materialReferences, TMP_FontAsset fontAsset)
|
||||
{
|
||||
int id = fontAsset.GetInstanceID();
|
||||
|
||||
for (int i = 0; i < materialReferences.Length && materialReferences[i].fontAsset != null; i++)
|
||||
{
|
||||
if (materialReferences[i].fontAsset.GetInstanceID() == id)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to add a new material reference and returning its index in the material reference array.
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
/// <param name="fontAsset"></param>
|
||||
/// <param name="materialReferences"></param>
|
||||
/// <param name="materialReferenceIndexLookup"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddMaterialReference(Material material, TMP_FontAsset fontAsset, MaterialReference[] materialReferences, Dictionary<int, int> materialReferenceIndexLookup)
|
||||
{
|
||||
int materialID = material.GetInstanceID();
|
||||
int index = 0;
|
||||
|
||||
if (materialReferenceIndexLookup.TryGetValue(materialID, out index))
|
||||
{
|
||||
return index;
|
||||
}
|
||||
else
|
||||
{
|
||||
index = materialReferenceIndexLookup.Count;
|
||||
|
||||
// Add new reference index
|
||||
materialReferenceIndexLookup[materialID] = index;
|
||||
|
||||
materialReferences[index].index = index;
|
||||
materialReferences[index].fontAsset = fontAsset;
|
||||
materialReferences[index].spriteAsset = null;
|
||||
materialReferences[index].material = material;
|
||||
materialReferences[index].isDefaultMaterial = materialID == fontAsset.material.GetInstanceID() ? true : false;
|
||||
//materialReferences[index].padding = 0;
|
||||
materialReferences[index].referenceCount = 0;
|
||||
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
/// <param name="spriteAsset"></param>
|
||||
/// <param name="materialReferences"></param>
|
||||
/// <param name="materialReferenceIndexLookup"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddMaterialReference(Material material, TMP_SpriteAsset spriteAsset, MaterialReference[] materialReferences, Dictionary<int, int> materialReferenceIndexLookup)
|
||||
{
|
||||
int materialID = material.GetInstanceID();
|
||||
int index = 0;
|
||||
|
||||
if (materialReferenceIndexLookup.TryGetValue(materialID, out index))
|
||||
{
|
||||
return index;
|
||||
}
|
||||
else
|
||||
{
|
||||
index = materialReferenceIndexLookup.Count;
|
||||
|
||||
// Add new reference index
|
||||
materialReferenceIndexLookup[materialID] = index;
|
||||
|
||||
materialReferences[index].index = index;
|
||||
materialReferences[index].fontAsset = materialReferences[0].fontAsset;
|
||||
materialReferences[index].spriteAsset = spriteAsset;
|
||||
materialReferences[index].material = material;
|
||||
materialReferences[index].isDefaultMaterial = true;
|
||||
//materialReferences[index].padding = 0;
|
||||
materialReferences[index].referenceCount = 0;
|
||||
|
||||
return index;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 11a6a034ab84493cbed6af5ae7aae78b
|
||||
timeCreated: 1449743129
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,234 @@
|
|||
#if UNITY_EDITOR
|
||||
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
public class PackageResourceImporterWindow : EditorWindow
|
||||
{
|
||||
public static void ShowPackageImporterWindow()
|
||||
{
|
||||
var window = GetWindow<PackageResourceImporterWindow>();
|
||||
window.titleContent = new GUIContent("TMP Importer");
|
||||
window.Focus();
|
||||
}
|
||||
|
||||
|
||||
public GUISkin LightSkin;
|
||||
public GUISkin DarkSkin;
|
||||
|
||||
static GUIStyle k_Label;
|
||||
static GUIStyle k_SectionLabel;
|
||||
static GUIStyle k_SquareAreaBoxGrey;
|
||||
|
||||
[SerializeField]
|
||||
bool k_EssentialResourcesImported;
|
||||
[SerializeField]
|
||||
bool k_ExamplesAndExtrasResourcesImported;
|
||||
[SerializeField]
|
||||
bool k_IsImportingExamples;
|
||||
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
// Set Editor Window Size
|
||||
SetEditorWindowSize();
|
||||
|
||||
// Get the UI Skin and Styles for the various Editors
|
||||
GetGUIStyles();
|
||||
|
||||
// Special handling due to scripts imported in a .unitypackage result in resulting in an assembly reload which clears the callbacks.
|
||||
if (k_IsImportingExamples)
|
||||
{
|
||||
AssetDatabase.importPackageCompleted += ImportCallback;
|
||||
k_IsImportingExamples = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
k_EssentialResourcesImported = false;
|
||||
k_ExamplesAndExtrasResourcesImported = false;
|
||||
}
|
||||
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
bool importEssentialsPackage = false;
|
||||
bool importExamplesPackage = false;
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
{
|
||||
GUILayout.Label("<b>TextMesh Pro Resources Importer</b>", k_SectionLabel);
|
||||
|
||||
// Display options to import Essential resources
|
||||
GUILayout.BeginVertical(k_SquareAreaBoxGrey);
|
||||
{
|
||||
GUILayout.Label("<b>TMP Essentials</b>", k_Label);
|
||||
GUILayout.Label("This appears to be the first time you access TextMesh Pro, as such we need to add resources to your project that are essential for using TextMesh Pro. These new resources will be placed at the root of your project in the \"TextMesh Pro\" folder.", k_Label);
|
||||
GUILayout.Space(5f);
|
||||
|
||||
GUI.enabled = k_EssentialResourcesImported == false ? true : false;
|
||||
if (GUILayout.Button("Import TMP Essentials"))
|
||||
{
|
||||
importEssentialsPackage = true;
|
||||
}
|
||||
GUILayout.Space(5f);
|
||||
GUI.enabled = true;
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Display options to import Examples & Extras
|
||||
GUILayout.BeginVertical(k_SquareAreaBoxGrey);
|
||||
{
|
||||
GUILayout.Label("<b>TMP Examples & Extras</b>", k_Label);
|
||||
GUILayout.Label("The Examples & Extras package contains addition resources and examples that will make discovering and learning about TextMesh Pro's powerful features easier. These additional resources will be placed in the same folder as the TMP essential resources.", k_Label);
|
||||
GUILayout.Space(5f);
|
||||
|
||||
GUI.enabled = (k_EssentialResourcesImported == true && k_ExamplesAndExtrasResourcesImported == false) ? true : false;
|
||||
if (GUILayout.Button("Import TMP Examples & Extras"))
|
||||
{
|
||||
importExamplesPackage = true;
|
||||
}
|
||||
GUILayout.Space(5f);
|
||||
GUI.enabled = true;
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.Space(5f);
|
||||
|
||||
// Import Essential Resources
|
||||
if (importEssentialsPackage)
|
||||
{
|
||||
AssetDatabase.importPackageCompleted += ImportCallback;
|
||||
|
||||
string packageFullPath = GetPackageFullPath();
|
||||
AssetDatabase.ImportPackage(packageFullPath + "/Package Resources/TMP Essential Resources.unitypackage", false);
|
||||
}
|
||||
|
||||
// Import Examples & Extras
|
||||
if (importExamplesPackage)
|
||||
{
|
||||
// Set flag to get around importing scripts as per of this package which results in an assembly reload which in turn prevents / clears any callbacks.
|
||||
k_IsImportingExamples = true;
|
||||
|
||||
string packageFullPath = GetPackageFullPath();
|
||||
AssetDatabase.ImportPackage(packageFullPath + "/Package Resources/TMP Examples & Extras.unitypackage", false);
|
||||
}
|
||||
}
|
||||
|
||||
void OnInspectorUpdate()
|
||||
{
|
||||
Repaint();
|
||||
}
|
||||
|
||||
|
||||
void GetGUIStyles()
|
||||
{
|
||||
GUISkin skin;
|
||||
|
||||
if (EditorGUIUtility.isProSkin)
|
||||
skin = DarkSkin;
|
||||
else
|
||||
skin = LightSkin;
|
||||
|
||||
k_Label = skin.FindStyle("Label");
|
||||
k_SectionLabel = skin.FindStyle("Section Label");
|
||||
k_SquareAreaBoxGrey = skin.FindStyle("Square Area Box (85 Grey)");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Limits the minimum size of the editor window.
|
||||
/// </summary>
|
||||
void SetEditorWindowSize()
|
||||
{
|
||||
EditorWindow editorWindow = this;
|
||||
|
||||
Vector2 windowSize = new Vector2(640, 240);
|
||||
editorWindow.minSize = windowSize;
|
||||
editorWindow.maxSize = windowSize;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="packageName"></param>
|
||||
void ImportCallback(string packageName)
|
||||
{
|
||||
if (packageName == "TMP Essential Resources")
|
||||
{
|
||||
k_EssentialResourcesImported = true;
|
||||
TMPro_EventManager.ON_RESOURCES_LOADED();
|
||||
}
|
||||
else if (packageName == "TMP Examples & Extras")
|
||||
{
|
||||
k_ExamplesAndExtrasResourcesImported = true;
|
||||
k_IsImportingExamples = false;
|
||||
}
|
||||
|
||||
Debug.Log("[" + packageName + "] have been imported.");
|
||||
|
||||
AssetDatabase.importPackageCompleted -= ImportCallback;
|
||||
}
|
||||
|
||||
|
||||
string GetPackageFullPath()
|
||||
{
|
||||
// Check for potential UPM package
|
||||
string packagePath = Path.GetFullPath("Packages/com.unity.textmeshpro");
|
||||
if (Directory.Exists(packagePath))
|
||||
{
|
||||
return packagePath;
|
||||
}
|
||||
|
||||
packagePath = Path.GetFullPath("Assets/..");
|
||||
if (Directory.Exists(packagePath))
|
||||
{
|
||||
// Search default location for development package
|
||||
if (Directory.Exists(packagePath + "/Assets/Packages/com.unity.TextMeshPro/Editor Resources"))
|
||||
{
|
||||
return packagePath + "/Assets/Packages/com.unity.TextMeshPro";
|
||||
}
|
||||
|
||||
// Search for default location of normal TextMesh Pro AssetStore package
|
||||
if (Directory.Exists(packagePath + "/Assets/TextMesh Pro/Editor Resources"))
|
||||
{
|
||||
return packagePath + "/Assets/TextMesh Pro";
|
||||
}
|
||||
|
||||
// Search for potential alternative locations in the user project
|
||||
string[] matchingPaths = Directory.GetDirectories(packagePath, "TextMesh Pro", SearchOption.AllDirectories);
|
||||
string path = ValidateLocation(matchingPaths, packagePath);
|
||||
if (path != null) return packagePath + path;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
string ValidateLocation(string[] paths, string projectPath)
|
||||
{
|
||||
for (int i = 0; i < paths.Length; i++)
|
||||
{
|
||||
// Check if any of the matching directories contain a GUISkins directory.
|
||||
if (Directory.Exists(paths[i] + "/Editor Resources"))
|
||||
{
|
||||
string folderPath = paths[i].Replace(projectPath, "");
|
||||
folderPath = folderPath.TrimStart('\\', '/');
|
||||
return folderPath;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,16 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cf1fe50a641faac4691bf49eb32ce333
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- m_PersistentViewDataDictionary: {instanceID: 0}
|
||||
- LightSkin: {fileID: 11400000, guid: 0c156a7b2f4d450da1716b1625b5441d, type: 2}
|
||||
- DarkSkin: {fileID: 11400000, guid: 9d345c3252c147c89e8b61a249a46a9d, type: 2}
|
||||
- TMPEssentials: {fileID: 102900000, guid: ce4ff17ca867d2b48b5c8a4181611901, type: 3}
|
||||
- TMPExamples: {fileID: 102900000, guid: bc00e25696e4132499f56528d3fed2e3, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
26
Assets/TextMesh Pro/Scripts/Runtime/TMP_Asset.cs
Normal file
26
Assets/TextMesh Pro/Scripts/Runtime/TMP_Asset.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
|
||||
// Base class inherited by the various TextMeshPro Assets.
|
||||
[System.Serializable]
|
||||
public class TMP_Asset : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// HashCode based on the name of the asset.
|
||||
/// </summary>
|
||||
public int hashCode;
|
||||
|
||||
/// <summary>
|
||||
/// The material used by this asset.
|
||||
/// </summary>
|
||||
public Material material;
|
||||
|
||||
/// <summary>
|
||||
/// HashCode based on the name of the material assigned to this asset.
|
||||
/// </summary>
|
||||
public int materialHashCode;
|
||||
|
||||
}
|
||||
}
|
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_Asset.cs.meta
Normal file
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_Asset.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3bda1886f58f4e0ab1139400b160c3ee
|
||||
timeCreated: 1459318952
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
54
Assets/TextMesh Pro/Scripts/Runtime/TMP_ColorGradient.cs
Normal file
54
Assets/TextMesh Pro/Scripts/Runtime/TMP_ColorGradient.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
[System.Serializable]
|
||||
public class TMP_ColorGradient : ScriptableObject
|
||||
{
|
||||
public Color topLeft;
|
||||
public Color topRight;
|
||||
public Color bottomLeft;
|
||||
public Color bottomRight;
|
||||
|
||||
private static Color k_defaultColor = Color.white;
|
||||
|
||||
/// <summary>
|
||||
/// Default Constructor which sets each of the colors as white.
|
||||
/// </summary>
|
||||
public TMP_ColorGradient()
|
||||
{
|
||||
this.topLeft = k_defaultColor;
|
||||
this.topRight = k_defaultColor;
|
||||
this.bottomLeft = k_defaultColor;
|
||||
this.bottomRight = k_defaultColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor allowing to set the default color of the Color Gradient.
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
public TMP_ColorGradient(Color color)
|
||||
{
|
||||
this.topLeft = color;
|
||||
this.topRight = color;
|
||||
this.bottomLeft = color;
|
||||
this.bottomRight = color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The vertex colors at the corners of the characters.
|
||||
/// </summary>
|
||||
/// <param name="color0">Top left color.</param>
|
||||
/// <param name="color1">Top right color.</param>
|
||||
/// <param name="color2">Bottom left color.</param>
|
||||
/// <param name="color3">Bottom right color.</param>
|
||||
public TMP_ColorGradient(Color color0, Color color1, Color color2, Color color3)
|
||||
{
|
||||
this.topLeft = color0;
|
||||
this.topRight = color1;
|
||||
this.bottomLeft = color2;
|
||||
this.bottomRight = color3;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 54d21f6ece3b46479f0c328f8c6007e0
|
||||
timeCreated: 1468187202
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
74
Assets/TextMesh Pro/Scripts/Runtime/TMP_Compatibility.cs
Normal file
74
Assets/TextMesh Pro/Scripts/Runtime/TMP_Compatibility.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
// Class used to convert scenes and objects saved in version 0.1.44 to the new Text Container
|
||||
public static class TMP_Compatibility
|
||||
{
|
||||
public enum AnchorPositions { TopLeft, Top, TopRight, Left, Center, Right, BottomLeft, Bottom, BottomRight, BaseLine, None };
|
||||
|
||||
/// <summary>
|
||||
/// Function used to convert text alignment option enumeration format.
|
||||
/// </summary>
|
||||
/// <param name="oldValue"></param>
|
||||
/// <returns></returns>
|
||||
public static TextAlignmentOptions ConvertTextAlignmentEnumValues(TextAlignmentOptions oldValue)
|
||||
{
|
||||
switch ((int)oldValue)
|
||||
{
|
||||
case 0:
|
||||
return TextAlignmentOptions.TopLeft;
|
||||
case 1:
|
||||
return TextAlignmentOptions.Top;
|
||||
case 2:
|
||||
return TextAlignmentOptions.TopRight;
|
||||
case 3:
|
||||
return TextAlignmentOptions.TopJustified;
|
||||
case 4:
|
||||
return TextAlignmentOptions.Left;
|
||||
case 5:
|
||||
return TextAlignmentOptions.Center;
|
||||
case 6:
|
||||
return TextAlignmentOptions.Right;
|
||||
case 7:
|
||||
return TextAlignmentOptions.Justified;
|
||||
case 8:
|
||||
return TextAlignmentOptions.BottomLeft;
|
||||
case 9:
|
||||
return TextAlignmentOptions.Bottom;
|
||||
case 10:
|
||||
return TextAlignmentOptions.BottomRight;
|
||||
case 11:
|
||||
return TextAlignmentOptions.BottomJustified;
|
||||
case 12:
|
||||
return TextAlignmentOptions.BaselineLeft;
|
||||
case 13:
|
||||
return TextAlignmentOptions.Baseline;
|
||||
case 14:
|
||||
return TextAlignmentOptions.BaselineRight;
|
||||
case 15:
|
||||
return TextAlignmentOptions.BaselineJustified;
|
||||
case 16:
|
||||
return TextAlignmentOptions.MidlineLeft;
|
||||
case 17:
|
||||
return TextAlignmentOptions.Midline;
|
||||
case 18:
|
||||
return TextAlignmentOptions.MidlineRight;
|
||||
case 19:
|
||||
return TextAlignmentOptions.MidlineJustified;
|
||||
case 20:
|
||||
return TextAlignmentOptions.CaplineLeft;
|
||||
case 21:
|
||||
return TextAlignmentOptions.Capline;
|
||||
case 22:
|
||||
return TextAlignmentOptions.CaplineRight;
|
||||
case 23:
|
||||
return TextAlignmentOptions.CaplineJustified;
|
||||
}
|
||||
|
||||
return TextAlignmentOptions.TopLeft;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 62a7573e463b4f68b578fcba3a94110c
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
246
Assets/TextMesh Pro/Scripts/Runtime/TMP_CoroutineTween.cs
Normal file
246
Assets/TextMesh Pro/Scripts/Runtime/TMP_CoroutineTween.cs
Normal file
|
@ -0,0 +1,246 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
// Base interface for tweeners,
|
||||
// using an interface instead of
|
||||
// an abstract class as we want the
|
||||
// tweens to be structs.
|
||||
internal interface ITweenValue
|
||||
{
|
||||
void TweenValue(float floatPercentage);
|
||||
bool ignoreTimeScale { get; }
|
||||
float duration { get; }
|
||||
bool ValidTarget();
|
||||
}
|
||||
|
||||
// Color tween class, receives the
|
||||
// TweenValue callback and then sets
|
||||
// the value on the target.
|
||||
internal struct ColorTween : ITweenValue
|
||||
{
|
||||
public enum ColorTweenMode
|
||||
{
|
||||
All,
|
||||
RGB,
|
||||
Alpha
|
||||
}
|
||||
|
||||
public class ColorTweenCallback : UnityEvent<Color> { }
|
||||
|
||||
private ColorTweenCallback m_Target;
|
||||
private Color m_StartColor;
|
||||
private Color m_TargetColor;
|
||||
private ColorTweenMode m_TweenMode;
|
||||
|
||||
private float m_Duration;
|
||||
private bool m_IgnoreTimeScale;
|
||||
|
||||
public Color startColor
|
||||
{
|
||||
get { return m_StartColor; }
|
||||
set { m_StartColor = value; }
|
||||
}
|
||||
|
||||
public Color targetColor
|
||||
{
|
||||
get { return m_TargetColor; }
|
||||
set { m_TargetColor = value; }
|
||||
}
|
||||
|
||||
public ColorTweenMode tweenMode
|
||||
{
|
||||
get { return m_TweenMode; }
|
||||
set { m_TweenMode = value; }
|
||||
}
|
||||
|
||||
public float duration
|
||||
{
|
||||
get { return m_Duration; }
|
||||
set { m_Duration = value; }
|
||||
}
|
||||
|
||||
public bool ignoreTimeScale
|
||||
{
|
||||
get { return m_IgnoreTimeScale; }
|
||||
set { m_IgnoreTimeScale = value; }
|
||||
}
|
||||
|
||||
public void TweenValue(float floatPercentage)
|
||||
{
|
||||
if (!ValidTarget())
|
||||
return;
|
||||
|
||||
var newColor = Color.Lerp(m_StartColor, m_TargetColor, floatPercentage);
|
||||
|
||||
if (m_TweenMode == ColorTweenMode.Alpha)
|
||||
{
|
||||
newColor.r = m_StartColor.r;
|
||||
newColor.g = m_StartColor.g;
|
||||
newColor.b = m_StartColor.b;
|
||||
}
|
||||
else if (m_TweenMode == ColorTweenMode.RGB)
|
||||
{
|
||||
newColor.a = m_StartColor.a;
|
||||
}
|
||||
m_Target.Invoke(newColor);
|
||||
}
|
||||
|
||||
public void AddOnChangedCallback(UnityAction<Color> callback)
|
||||
{
|
||||
if (m_Target == null)
|
||||
m_Target = new ColorTweenCallback();
|
||||
|
||||
m_Target.AddListener(callback);
|
||||
}
|
||||
|
||||
public bool GetIgnoreTimescale()
|
||||
{
|
||||
return m_IgnoreTimeScale;
|
||||
}
|
||||
|
||||
public float GetDuration()
|
||||
{
|
||||
return m_Duration;
|
||||
}
|
||||
|
||||
public bool ValidTarget()
|
||||
{
|
||||
return m_Target != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Float tween class, receives the
|
||||
// TweenValue callback and then sets
|
||||
// the value on the target.
|
||||
internal struct FloatTween : ITweenValue
|
||||
{
|
||||
public class FloatTweenCallback : UnityEvent<float> { }
|
||||
|
||||
private FloatTweenCallback m_Target;
|
||||
private float m_StartValue;
|
||||
private float m_TargetValue;
|
||||
|
||||
private float m_Duration;
|
||||
private bool m_IgnoreTimeScale;
|
||||
|
||||
public float startValue
|
||||
{
|
||||
get { return m_StartValue; }
|
||||
set { m_StartValue = value; }
|
||||
}
|
||||
|
||||
public float targetValue
|
||||
{
|
||||
get { return m_TargetValue; }
|
||||
set { m_TargetValue = value; }
|
||||
}
|
||||
|
||||
public float duration
|
||||
{
|
||||
get { return m_Duration; }
|
||||
set { m_Duration = value; }
|
||||
}
|
||||
|
||||
public bool ignoreTimeScale
|
||||
{
|
||||
get { return m_IgnoreTimeScale; }
|
||||
set { m_IgnoreTimeScale = value; }
|
||||
}
|
||||
|
||||
public void TweenValue(float floatPercentage)
|
||||
{
|
||||
if (!ValidTarget())
|
||||
return;
|
||||
|
||||
var newValue = Mathf.Lerp(m_StartValue, m_TargetValue, floatPercentage);
|
||||
m_Target.Invoke(newValue);
|
||||
}
|
||||
|
||||
public void AddOnChangedCallback(UnityAction<float> callback)
|
||||
{
|
||||
if (m_Target == null)
|
||||
m_Target = new FloatTweenCallback();
|
||||
|
||||
m_Target.AddListener(callback);
|
||||
}
|
||||
|
||||
public bool GetIgnoreTimescale()
|
||||
{
|
||||
return m_IgnoreTimeScale;
|
||||
}
|
||||
|
||||
public float GetDuration()
|
||||
{
|
||||
return m_Duration;
|
||||
}
|
||||
|
||||
public bool ValidTarget()
|
||||
{
|
||||
return m_Target != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Tween runner, executes the given tween.
|
||||
// The coroutine will live within the given
|
||||
// behaviour container.
|
||||
internal class TweenRunner<T> where T : struct, ITweenValue
|
||||
{
|
||||
protected MonoBehaviour m_CoroutineContainer;
|
||||
protected IEnumerator m_Tween;
|
||||
|
||||
// utility function for starting the tween
|
||||
private static IEnumerator Start(T tweenInfo)
|
||||
{
|
||||
if (!tweenInfo.ValidTarget())
|
||||
yield break;
|
||||
|
||||
var elapsedTime = 0.0f;
|
||||
while (elapsedTime < tweenInfo.duration)
|
||||
{
|
||||
elapsedTime += tweenInfo.ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime;
|
||||
var percentage = Mathf.Clamp01(elapsedTime / tweenInfo.duration);
|
||||
tweenInfo.TweenValue(percentage);
|
||||
yield return null;
|
||||
}
|
||||
tweenInfo.TweenValue(1.0f);
|
||||
}
|
||||
|
||||
public void Init(MonoBehaviour coroutineContainer)
|
||||
{
|
||||
m_CoroutineContainer = coroutineContainer;
|
||||
}
|
||||
|
||||
public void StartTween(T info)
|
||||
{
|
||||
if (m_CoroutineContainer == null)
|
||||
{
|
||||
Debug.LogWarning("Coroutine container not configured... did you forget to call Init?");
|
||||
return;
|
||||
}
|
||||
|
||||
StopTween();
|
||||
|
||||
if (!m_CoroutineContainer.gameObject.activeInHierarchy)
|
||||
{
|
||||
info.TweenValue(1.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
m_Tween = Start(info);
|
||||
m_CoroutineContainer.StartCoroutine(m_Tween);
|
||||
}
|
||||
|
||||
public void StopTween()
|
||||
{
|
||||
if (m_Tween != null)
|
||||
{
|
||||
m_CoroutineContainer.StopCoroutine(m_Tween);
|
||||
m_Tween = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 658c1fb149e7498aa072b0c0f3bf13f0
|
||||
timeCreated: 1464850953
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
345
Assets/TextMesh Pro/Scripts/Runtime/TMP_DefaultControls.cs
Normal file
345
Assets/TextMesh Pro/Scripts/Runtime/TMP_DefaultControls.cs
Normal file
|
@ -0,0 +1,345 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
|
||||
public static class TMP_DefaultControls
|
||||
{
|
||||
public struct Resources
|
||||
{
|
||||
public Sprite standard;
|
||||
public Sprite background;
|
||||
public Sprite inputField;
|
||||
public Sprite knob;
|
||||
public Sprite checkmark;
|
||||
public Sprite dropdown;
|
||||
public Sprite mask;
|
||||
}
|
||||
|
||||
private const float kWidth = 160f;
|
||||
private const float kThickHeight = 30f;
|
||||
private const float kThinHeight = 20f;
|
||||
private static Vector2 s_ThickElementSize = new Vector2(kWidth, kThickHeight);
|
||||
private static Vector2 s_ThinElementSize = new Vector2(kWidth, kThinHeight);
|
||||
//private static Vector2 s_ImageElementSize = new Vector2(100f, 100f);
|
||||
private static Color s_DefaultSelectableColor = new Color(1f, 1f, 1f, 1f);
|
||||
//private static Color s_PanelColor = new Color(1f, 1f, 1f, 0.392f);
|
||||
private static Color s_TextColor = new Color(50f / 255f, 50f / 255f, 50f / 255f, 1f);
|
||||
|
||||
|
||||
private static GameObject CreateUIElementRoot(string name, Vector2 size)
|
||||
{
|
||||
GameObject child = new GameObject(name);
|
||||
RectTransform rectTransform = child.AddComponent<RectTransform>();
|
||||
rectTransform.sizeDelta = size;
|
||||
return child;
|
||||
}
|
||||
|
||||
static GameObject CreateUIObject(string name, GameObject parent)
|
||||
{
|
||||
GameObject go = new GameObject(name);
|
||||
go.AddComponent<RectTransform>();
|
||||
SetParentAndAlign(go, parent);
|
||||
return go;
|
||||
}
|
||||
|
||||
private static void SetDefaultTextValues(TMP_Text lbl)
|
||||
{
|
||||
// Set text values we want across UI elements in default controls.
|
||||
// Don't set values which are the same as the default values for the Text component,
|
||||
// since there's no point in that, and it's good to keep them as consistent as possible.
|
||||
lbl.color = s_TextColor;
|
||||
lbl.fontSize = 14;
|
||||
}
|
||||
|
||||
private static void SetDefaultColorTransitionValues(Selectable slider)
|
||||
{
|
||||
ColorBlock colors = slider.colors;
|
||||
colors.highlightedColor = new Color(0.882f, 0.882f, 0.882f);
|
||||
colors.pressedColor = new Color(0.698f, 0.698f, 0.698f);
|
||||
colors.disabledColor = new Color(0.521f, 0.521f, 0.521f);
|
||||
}
|
||||
|
||||
private static void SetParentAndAlign(GameObject child, GameObject parent)
|
||||
{
|
||||
if (parent == null)
|
||||
return;
|
||||
|
||||
child.transform.SetParent(parent.transform, false);
|
||||
SetLayerRecursively(child, parent.layer);
|
||||
}
|
||||
|
||||
private static void SetLayerRecursively(GameObject go, int layer)
|
||||
{
|
||||
go.layer = layer;
|
||||
Transform t = go.transform;
|
||||
for (int i = 0; i < t.childCount; i++)
|
||||
SetLayerRecursively(t.GetChild(i).gameObject, layer);
|
||||
}
|
||||
|
||||
// Actual controls
|
||||
|
||||
public static GameObject CreateScrollbar(Resources resources)
|
||||
{
|
||||
// Create GOs Hierarchy
|
||||
GameObject scrollbarRoot = CreateUIElementRoot("Scrollbar", s_ThinElementSize);
|
||||
|
||||
GameObject sliderArea = CreateUIObject("Sliding Area", scrollbarRoot);
|
||||
GameObject handle = CreateUIObject("Handle", sliderArea);
|
||||
|
||||
Image bgImage = scrollbarRoot.AddComponent<Image>();
|
||||
bgImage.sprite = resources.background;
|
||||
bgImage.type = Image.Type.Sliced;
|
||||
bgImage.color = s_DefaultSelectableColor;
|
||||
|
||||
Image handleImage = handle.AddComponent<Image>();
|
||||
handleImage.sprite = resources.standard;
|
||||
handleImage.type = Image.Type.Sliced;
|
||||
handleImage.color = s_DefaultSelectableColor;
|
||||
|
||||
RectTransform sliderAreaRect = sliderArea.GetComponent<RectTransform>();
|
||||
sliderAreaRect.sizeDelta = new Vector2(-20, -20);
|
||||
sliderAreaRect.anchorMin = Vector2.zero;
|
||||
sliderAreaRect.anchorMax = Vector2.one;
|
||||
|
||||
RectTransform handleRect = handle.GetComponent<RectTransform>();
|
||||
handleRect.sizeDelta = new Vector2(20, 20);
|
||||
|
||||
Scrollbar scrollbar = scrollbarRoot.AddComponent<Scrollbar>();
|
||||
scrollbar.handleRect = handleRect;
|
||||
scrollbar.targetGraphic = handleImage;
|
||||
SetDefaultColorTransitionValues(scrollbar);
|
||||
|
||||
return scrollbarRoot;
|
||||
}
|
||||
|
||||
|
||||
public static GameObject CreateInputField(Resources resources)
|
||||
{
|
||||
GameObject root = CreateUIElementRoot("TextMeshPro - InputField", s_ThickElementSize);
|
||||
|
||||
GameObject textArea = CreateUIObject("Text Area", root);
|
||||
GameObject childPlaceholder = CreateUIObject("Placeholder", textArea);
|
||||
GameObject childText = CreateUIObject("Text", textArea);
|
||||
|
||||
Image image = root.AddComponent<Image>();
|
||||
image.sprite = resources.inputField;
|
||||
image.type = Image.Type.Sliced;
|
||||
image.color = s_DefaultSelectableColor;
|
||||
|
||||
TMP_InputField inputField = root.AddComponent<TMP_InputField>();
|
||||
SetDefaultColorTransitionValues(inputField);
|
||||
|
||||
// Use UI.Mask for Unity 5.0 - 5.1 and 2D RectMask for Unity 5.2 and up
|
||||
textArea.AddComponent<RectMask2D>();
|
||||
|
||||
RectTransform textAreaRectTransform = textArea.GetComponent<RectTransform>();
|
||||
textAreaRectTransform.anchorMin = Vector2.zero;
|
||||
textAreaRectTransform.anchorMax = Vector2.one;
|
||||
textAreaRectTransform.sizeDelta = Vector2.zero;
|
||||
textAreaRectTransform.offsetMin = new Vector2(10, 6);
|
||||
textAreaRectTransform.offsetMax = new Vector2(-10, -7);
|
||||
|
||||
|
||||
TextMeshProUGUI text = childText.AddComponent<TextMeshProUGUI>();
|
||||
text.text = "";
|
||||
text.enableWordWrapping = false;
|
||||
text.extraPadding = true;
|
||||
text.richText = true;
|
||||
SetDefaultTextValues(text);
|
||||
|
||||
TextMeshProUGUI placeholder = childPlaceholder.AddComponent<TextMeshProUGUI>();
|
||||
placeholder.text = "Enter text...";
|
||||
placeholder.fontSize = 14;
|
||||
placeholder.fontStyle = FontStyles.Italic;
|
||||
placeholder.enableWordWrapping = false;
|
||||
placeholder.extraPadding = true;
|
||||
|
||||
// Make placeholder color half as opaque as normal text color.
|
||||
Color placeholderColor = text.color;
|
||||
placeholderColor.a *= 0.5f;
|
||||
placeholder.color = placeholderColor;
|
||||
|
||||
RectTransform textRectTransform = childText.GetComponent<RectTransform>();
|
||||
textRectTransform.anchorMin = Vector2.zero;
|
||||
textRectTransform.anchorMax = Vector2.one;
|
||||
textRectTransform.sizeDelta = Vector2.zero;
|
||||
textRectTransform.offsetMin = new Vector2(0, 0);
|
||||
textRectTransform.offsetMax = new Vector2(0, 0);
|
||||
|
||||
RectTransform placeholderRectTransform = childPlaceholder.GetComponent<RectTransform>();
|
||||
placeholderRectTransform.anchorMin = Vector2.zero;
|
||||
placeholderRectTransform.anchorMax = Vector2.one;
|
||||
placeholderRectTransform.sizeDelta = Vector2.zero;
|
||||
placeholderRectTransform.offsetMin = new Vector2(0, 0);
|
||||
placeholderRectTransform.offsetMax = new Vector2(0, 0);
|
||||
|
||||
inputField.textViewport = textAreaRectTransform;
|
||||
inputField.textComponent = text;
|
||||
inputField.placeholder = placeholder;
|
||||
inputField.fontAsset = text.font;
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
public static GameObject CreateDropdown(Resources resources)
|
||||
{
|
||||
GameObject root = CreateUIElementRoot("Dropdown", s_ThickElementSize);
|
||||
|
||||
GameObject label = CreateUIObject("Label", root);
|
||||
GameObject arrow = CreateUIObject("Arrow", root);
|
||||
GameObject template = CreateUIObject("Template", root);
|
||||
GameObject viewport = CreateUIObject("Viewport", template);
|
||||
GameObject content = CreateUIObject("Content", viewport);
|
||||
GameObject item = CreateUIObject("Item", content);
|
||||
GameObject itemBackground = CreateUIObject("Item Background", item);
|
||||
GameObject itemCheckmark = CreateUIObject("Item Checkmark", item);
|
||||
GameObject itemLabel = CreateUIObject("Item Label", item);
|
||||
|
||||
// Sub controls.
|
||||
|
||||
GameObject scrollbar = CreateScrollbar(resources);
|
||||
scrollbar.name = "Scrollbar";
|
||||
SetParentAndAlign(scrollbar, template);
|
||||
|
||||
Scrollbar scrollbarScrollbar = scrollbar.GetComponent<Scrollbar>();
|
||||
scrollbarScrollbar.SetDirection(Scrollbar.Direction.BottomToTop, true);
|
||||
|
||||
RectTransform vScrollbarRT = scrollbar.GetComponent<RectTransform>();
|
||||
vScrollbarRT.anchorMin = Vector2.right;
|
||||
vScrollbarRT.anchorMax = Vector2.one;
|
||||
vScrollbarRT.pivot = Vector2.one;
|
||||
vScrollbarRT.sizeDelta = new Vector2(vScrollbarRT.sizeDelta.x, 0);
|
||||
|
||||
// Setup item UI components.
|
||||
|
||||
TextMeshProUGUI itemLabelText = itemLabel.AddComponent<TextMeshProUGUI>();
|
||||
SetDefaultTextValues(itemLabelText);
|
||||
itemLabelText.alignment = TextAlignmentOptions.Left;
|
||||
|
||||
Image itemBackgroundImage = itemBackground.AddComponent<Image>();
|
||||
itemBackgroundImage.color = new Color32(245, 245, 245, 255);
|
||||
|
||||
Image itemCheckmarkImage = itemCheckmark.AddComponent<Image>();
|
||||
itemCheckmarkImage.sprite = resources.checkmark;
|
||||
|
||||
Toggle itemToggle = item.AddComponent<Toggle>();
|
||||
itemToggle.targetGraphic = itemBackgroundImage;
|
||||
itemToggle.graphic = itemCheckmarkImage;
|
||||
itemToggle.isOn = true;
|
||||
|
||||
// Setup template UI components.
|
||||
|
||||
Image templateImage = template.AddComponent<Image>();
|
||||
templateImage.sprite = resources.standard;
|
||||
templateImage.type = Image.Type.Sliced;
|
||||
|
||||
ScrollRect templateScrollRect = template.AddComponent<ScrollRect>();
|
||||
templateScrollRect.content = (RectTransform)content.transform;
|
||||
templateScrollRect.viewport = (RectTransform)viewport.transform;
|
||||
templateScrollRect.horizontal = false;
|
||||
templateScrollRect.movementType = ScrollRect.MovementType.Clamped;
|
||||
templateScrollRect.verticalScrollbar = scrollbarScrollbar;
|
||||
templateScrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport;
|
||||
templateScrollRect.verticalScrollbarSpacing = -3;
|
||||
|
||||
Mask scrollRectMask = viewport.AddComponent<Mask>();
|
||||
scrollRectMask.showMaskGraphic = false;
|
||||
|
||||
Image viewportImage = viewport.AddComponent<Image>();
|
||||
viewportImage.sprite = resources.mask;
|
||||
viewportImage.type = Image.Type.Sliced;
|
||||
|
||||
// Setup dropdown UI components.
|
||||
|
||||
TextMeshProUGUI labelText = label.AddComponent<TextMeshProUGUI>();
|
||||
SetDefaultTextValues(labelText);
|
||||
labelText.alignment = TextAlignmentOptions.Left;
|
||||
|
||||
Image arrowImage = arrow.AddComponent<Image>();
|
||||
arrowImage.sprite = resources.dropdown;
|
||||
|
||||
Image backgroundImage = root.AddComponent<Image>();
|
||||
backgroundImage.sprite = resources.standard;
|
||||
backgroundImage.color = s_DefaultSelectableColor;
|
||||
backgroundImage.type = Image.Type.Sliced;
|
||||
|
||||
TMP_Dropdown dropdown = root.AddComponent<TMP_Dropdown>();
|
||||
dropdown.targetGraphic = backgroundImage;
|
||||
SetDefaultColorTransitionValues(dropdown);
|
||||
dropdown.template = template.GetComponent<RectTransform>();
|
||||
dropdown.captionText = labelText;
|
||||
dropdown.itemText = itemLabelText;
|
||||
|
||||
// Setting default Item list.
|
||||
itemLabelText.text = "Option A";
|
||||
dropdown.options.Add(new TMP_Dropdown.OptionData {text = "Option A" });
|
||||
dropdown.options.Add(new TMP_Dropdown.OptionData {text = "Option B" });
|
||||
dropdown.options.Add(new TMP_Dropdown.OptionData {text = "Option C" });
|
||||
dropdown.RefreshShownValue();
|
||||
|
||||
// Set up RectTransforms.
|
||||
|
||||
RectTransform labelRT = label.GetComponent<RectTransform>();
|
||||
labelRT.anchorMin = Vector2.zero;
|
||||
labelRT.anchorMax = Vector2.one;
|
||||
labelRT.offsetMin = new Vector2(10, 6);
|
||||
labelRT.offsetMax = new Vector2(-25, -7);
|
||||
|
||||
RectTransform arrowRT = arrow.GetComponent<RectTransform>();
|
||||
arrowRT.anchorMin = new Vector2(1, 0.5f);
|
||||
arrowRT.anchorMax = new Vector2(1, 0.5f);
|
||||
arrowRT.sizeDelta = new Vector2(20, 20);
|
||||
arrowRT.anchoredPosition = new Vector2(-15, 0);
|
||||
|
||||
RectTransform templateRT = template.GetComponent<RectTransform>();
|
||||
templateRT.anchorMin = new Vector2(0, 0);
|
||||
templateRT.anchorMax = new Vector2(1, 0);
|
||||
templateRT.pivot = new Vector2(0.5f, 1);
|
||||
templateRT.anchoredPosition = new Vector2(0, 2);
|
||||
templateRT.sizeDelta = new Vector2(0, 150);
|
||||
|
||||
RectTransform viewportRT = viewport.GetComponent<RectTransform>();
|
||||
viewportRT.anchorMin = new Vector2(0, 0);
|
||||
viewportRT.anchorMax = new Vector2(1, 1);
|
||||
viewportRT.sizeDelta = new Vector2(-18, 0);
|
||||
viewportRT.pivot = new Vector2(0, 1);
|
||||
|
||||
RectTransform contentRT = content.GetComponent<RectTransform>();
|
||||
contentRT.anchorMin = new Vector2(0f, 1);
|
||||
contentRT.anchorMax = new Vector2(1f, 1);
|
||||
contentRT.pivot = new Vector2(0.5f, 1);
|
||||
contentRT.anchoredPosition = new Vector2(0, 0);
|
||||
contentRT.sizeDelta = new Vector2(0, 28);
|
||||
|
||||
RectTransform itemRT = item.GetComponent<RectTransform>();
|
||||
itemRT.anchorMin = new Vector2(0, 0.5f);
|
||||
itemRT.anchorMax = new Vector2(1, 0.5f);
|
||||
itemRT.sizeDelta = new Vector2(0, 20);
|
||||
|
||||
RectTransform itemBackgroundRT = itemBackground.GetComponent<RectTransform>();
|
||||
itemBackgroundRT.anchorMin = Vector2.zero;
|
||||
itemBackgroundRT.anchorMax = Vector2.one;
|
||||
itemBackgroundRT.sizeDelta = Vector2.zero;
|
||||
|
||||
RectTransform itemCheckmarkRT = itemCheckmark.GetComponent<RectTransform>();
|
||||
itemCheckmarkRT.anchorMin = new Vector2(0, 0.5f);
|
||||
itemCheckmarkRT.anchorMax = new Vector2(0, 0.5f);
|
||||
itemCheckmarkRT.sizeDelta = new Vector2(20, 20);
|
||||
itemCheckmarkRT.anchoredPosition = new Vector2(10, 0);
|
||||
|
||||
RectTransform itemLabelRT = itemLabel.GetComponent<RectTransform>();
|
||||
itemLabelRT.anchorMin = Vector2.zero;
|
||||
itemLabelRT.anchorMax = Vector2.one;
|
||||
itemLabelRT.offsetMin = new Vector2(20, 1);
|
||||
itemLabelRT.offsetMax = new Vector2(-10, -2);
|
||||
|
||||
template.SetActive(false);
|
||||
|
||||
return root;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 322392995be44d23a3c86cfd972f838f
|
||||
timeCreated: 1446378357
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
654
Assets/TextMesh Pro/Scripts/Runtime/TMP_Dropdown.cs
Normal file
654
Assets/TextMesh Pro/Scripts/Runtime/TMP_Dropdown.cs
Normal file
|
@ -0,0 +1,654 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI.CoroutineTween;
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
[AddComponentMenu("UI/TMP Dropdown", 35)]
|
||||
[RequireComponent(typeof(RectTransform))]
|
||||
public class TMP_Dropdown : Selectable, IPointerClickHandler, ISubmitHandler, ICancelHandler
|
||||
{
|
||||
protected internal class DropdownItem : MonoBehaviour, IPointerEnterHandler, ICancelHandler
|
||||
{
|
||||
[SerializeField]
|
||||
private TMP_Text m_Text;
|
||||
[SerializeField]
|
||||
private Image m_Image;
|
||||
[SerializeField]
|
||||
private RectTransform m_RectTransform;
|
||||
[SerializeField]
|
||||
private Toggle m_Toggle;
|
||||
|
||||
public TMP_Text text { get { return m_Text; } set { m_Text = value; } }
|
||||
public Image image { get { return m_Image; } set { m_Image = value; } }
|
||||
public RectTransform rectTransform { get { return m_RectTransform; } set { m_RectTransform = value; } }
|
||||
public Toggle toggle { get { return m_Toggle; } set { m_Toggle = value; } }
|
||||
|
||||
public virtual void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(gameObject);
|
||||
}
|
||||
|
||||
public virtual void OnCancel(BaseEventData eventData)
|
||||
{
|
||||
TMP_Dropdown dropdown = GetComponentInParent<TMP_Dropdown>();
|
||||
if (dropdown)
|
||||
dropdown.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class OptionData
|
||||
{
|
||||
[SerializeField]
|
||||
private string m_Text;
|
||||
[SerializeField]
|
||||
private Sprite m_Image;
|
||||
|
||||
public string text { get { return m_Text; } set { m_Text = value; } }
|
||||
public Sprite image { get { return m_Image; } set { m_Image = value; } }
|
||||
|
||||
public OptionData()
|
||||
{
|
||||
}
|
||||
|
||||
public OptionData(string text)
|
||||
{
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public OptionData(Sprite image)
|
||||
{
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public OptionData(string text, Sprite image)
|
||||
{
|
||||
this.text = text;
|
||||
this.image = image;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class OptionDataList
|
||||
{
|
||||
[SerializeField]
|
||||
private List<OptionData> m_Options;
|
||||
public List<OptionData> options { get { return m_Options; } set { m_Options = value; } }
|
||||
|
||||
|
||||
public OptionDataList()
|
||||
{
|
||||
options = new List<OptionData>();
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class DropdownEvent : UnityEvent<int> { }
|
||||
|
||||
// Template used to create the dropdown.
|
||||
[SerializeField]
|
||||
private RectTransform m_Template;
|
||||
public RectTransform template { get { return m_Template; } set { m_Template = value; RefreshShownValue(); } }
|
||||
|
||||
// Text to be used as a caption for the current value. It's not required, but it's kept here for convenience.
|
||||
[SerializeField]
|
||||
private TMP_Text m_CaptionText;
|
||||
public TMP_Text captionText { get { return m_CaptionText; } set { m_CaptionText = value; RefreshShownValue(); } }
|
||||
|
||||
[SerializeField]
|
||||
private Image m_CaptionImage;
|
||||
public Image captionImage { get { return m_CaptionImage; } set { m_CaptionImage = value; RefreshShownValue(); } }
|
||||
|
||||
[Space]
|
||||
|
||||
[SerializeField]
|
||||
private TMP_Text m_ItemText;
|
||||
public TMP_Text itemText { get { return m_ItemText; } set { m_ItemText = value; RefreshShownValue(); } }
|
||||
|
||||
[SerializeField]
|
||||
private Image m_ItemImage;
|
||||
public Image itemImage { get { return m_ItemImage; } set { m_ItemImage = value; RefreshShownValue(); } }
|
||||
|
||||
[Space]
|
||||
|
||||
[SerializeField]
|
||||
private int m_Value;
|
||||
|
||||
[Space]
|
||||
|
||||
// Items that will be visible when the dropdown is shown.
|
||||
// We box this into its own class so we can use a Property Drawer for it.
|
||||
[SerializeField]
|
||||
private OptionDataList m_Options = new OptionDataList();
|
||||
public List<OptionData> options
|
||||
{
|
||||
get { return m_Options.options; }
|
||||
set { m_Options.options = value; RefreshShownValue(); }
|
||||
}
|
||||
|
||||
[Space]
|
||||
|
||||
// Notification triggered when the dropdown changes.
|
||||
[SerializeField]
|
||||
private DropdownEvent m_OnValueChanged = new DropdownEvent();
|
||||
public DropdownEvent onValueChanged { get { return m_OnValueChanged; } set { m_OnValueChanged = value; } }
|
||||
|
||||
private GameObject m_Dropdown;
|
||||
private GameObject m_Blocker;
|
||||
private List<DropdownItem> m_Items = new List<DropdownItem>();
|
||||
private TweenRunner<FloatTween> m_AlphaTweenRunner;
|
||||
private bool validTemplate = false;
|
||||
|
||||
private static OptionData s_NoOptionData = new OptionData();
|
||||
|
||||
// Current value.
|
||||
public int value
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (Application.isPlaying && (value == m_Value || options.Count == 0))
|
||||
return;
|
||||
|
||||
m_Value = Mathf.Clamp(value, 0, options.Count - 1);
|
||||
RefreshShownValue();
|
||||
|
||||
// Notify all listeners
|
||||
m_OnValueChanged.Invoke(m_Value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExpanded
|
||||
{ get { return m_Dropdown != null; } }
|
||||
|
||||
protected TMP_Dropdown()
|
||||
{ }
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
return;
|
||||
#endif
|
||||
|
||||
m_AlphaTweenRunner = new TweenRunner<FloatTween>();
|
||||
m_AlphaTweenRunner.Init(this);
|
||||
|
||||
if (m_CaptionImage)
|
||||
m_CaptionImage.enabled = (m_CaptionImage.sprite != null);
|
||||
|
||||
if (m_Template)
|
||||
m_Template.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
|
||||
if (!IsActive())
|
||||
return;
|
||||
|
||||
RefreshShownValue();
|
||||
}
|
||||
#endif
|
||||
|
||||
public void RefreshShownValue()
|
||||
{
|
||||
OptionData data = s_NoOptionData;
|
||||
|
||||
if (options.Count > 0)
|
||||
data = options[Mathf.Clamp(m_Value, 0, options.Count - 1)];
|
||||
|
||||
if (m_CaptionText)
|
||||
{
|
||||
if (data != null && data.text != null)
|
||||
m_CaptionText.text = data.text;
|
||||
else
|
||||
m_CaptionText.text = "";
|
||||
}
|
||||
|
||||
if (m_CaptionImage)
|
||||
{
|
||||
if (data != null)
|
||||
m_CaptionImage.sprite = data.image;
|
||||
else
|
||||
m_CaptionImage.sprite = null;
|
||||
m_CaptionImage.enabled = (m_CaptionImage.sprite != null);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddOptions(List<OptionData> options)
|
||||
{
|
||||
this.options.AddRange(options);
|
||||
RefreshShownValue();
|
||||
}
|
||||
|
||||
public void AddOptions(List<string> options)
|
||||
{
|
||||
for (int i = 0; i < options.Count; i++)
|
||||
this.options.Add(new OptionData(options[i]));
|
||||
RefreshShownValue();
|
||||
}
|
||||
|
||||
public void AddOptions(List<Sprite> options)
|
||||
{
|
||||
for (int i = 0; i < options.Count; i++)
|
||||
this.options.Add(new OptionData(options[i]));
|
||||
RefreshShownValue();
|
||||
}
|
||||
|
||||
public void ClearOptions()
|
||||
{
|
||||
options.Clear();
|
||||
RefreshShownValue();
|
||||
}
|
||||
|
||||
private void SetupTemplate()
|
||||
{
|
||||
validTemplate = false;
|
||||
|
||||
if (!m_Template)
|
||||
{
|
||||
Debug.LogError("The dropdown template is not assigned. The template needs to be assigned and must have a child GameObject with a Toggle component serving as the item.", this);
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject templateGo = m_Template.gameObject;
|
||||
templateGo.SetActive(true);
|
||||
Toggle itemToggle = m_Template.GetComponentInChildren<Toggle>();
|
||||
|
||||
validTemplate = true;
|
||||
if (!itemToggle || itemToggle.transform == template)
|
||||
{
|
||||
validTemplate = false;
|
||||
Debug.LogError("The dropdown template is not valid. The template must have a child GameObject with a Toggle component serving as the item.", template);
|
||||
}
|
||||
else if (!(itemToggle.transform.parent is RectTransform))
|
||||
{
|
||||
validTemplate = false;
|
||||
Debug.LogError("The dropdown template is not valid. The child GameObject with a Toggle component (the item) must have a RectTransform on its parent.", template);
|
||||
}
|
||||
else if (itemText != null && !itemText.transform.IsChildOf(itemToggle.transform))
|
||||
{
|
||||
validTemplate = false;
|
||||
Debug.LogError("The dropdown template is not valid. The Item Text must be on the item GameObject or children of it.", template);
|
||||
}
|
||||
else if (itemImage != null && !itemImage.transform.IsChildOf(itemToggle.transform))
|
||||
{
|
||||
validTemplate = false;
|
||||
Debug.LogError("The dropdown template is not valid. The Item Image must be on the item GameObject or children of it.", template);
|
||||
}
|
||||
|
||||
if (!validTemplate)
|
||||
{
|
||||
templateGo.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
DropdownItem item = itemToggle.gameObject.AddComponent<DropdownItem>();
|
||||
item.text = m_ItemText;
|
||||
item.image = m_ItemImage;
|
||||
item.toggle = itemToggle;
|
||||
item.rectTransform = (RectTransform)itemToggle.transform;
|
||||
|
||||
Canvas popupCanvas = GetOrAddComponent<Canvas>(templateGo);
|
||||
popupCanvas.overrideSorting = true;
|
||||
popupCanvas.sortingOrder = 30000;
|
||||
|
||||
GetOrAddComponent<GraphicRaycaster>(templateGo);
|
||||
GetOrAddComponent<CanvasGroup>(templateGo);
|
||||
templateGo.SetActive(false);
|
||||
|
||||
validTemplate = true;
|
||||
}
|
||||
|
||||
private static T GetOrAddComponent<T>(GameObject go) where T : Component
|
||||
{
|
||||
T comp = go.GetComponent<T>();
|
||||
if (!comp)
|
||||
comp = go.AddComponent<T>();
|
||||
return comp;
|
||||
}
|
||||
|
||||
public virtual void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
Show();
|
||||
}
|
||||
|
||||
public virtual void OnSubmit(BaseEventData eventData)
|
||||
{
|
||||
Show();
|
||||
}
|
||||
|
||||
public virtual void OnCancel(BaseEventData eventData)
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
// Show the dropdown.
|
||||
//
|
||||
// Plan for dropdown scrolling to ensure dropdown is contained within screen.
|
||||
//
|
||||
// We assume the Canvas is the screen that the dropdown must be kept inside.
|
||||
// This is always valid for screen space canvas modes.
|
||||
// For world space canvases we don't know how it's used, but it could be e.g. for an in-game monitor.
|
||||
// We consider it a fair constraint that the canvas must be big enough to contains dropdowns.
|
||||
public void Show()
|
||||
{
|
||||
if (!IsActive() || !IsInteractable() || m_Dropdown != null)
|
||||
return;
|
||||
|
||||
if (!validTemplate)
|
||||
{
|
||||
SetupTemplate();
|
||||
if (!validTemplate)
|
||||
return;
|
||||
}
|
||||
|
||||
// Get root Canvas.
|
||||
var list = TMP_ListPool<Canvas>.Get();
|
||||
gameObject.GetComponentsInParent(false, list);
|
||||
if (list.Count == 0)
|
||||
return;
|
||||
Canvas rootCanvas = list[0];
|
||||
TMP_ListPool<Canvas>.Release(list);
|
||||
|
||||
m_Template.gameObject.SetActive(true);
|
||||
|
||||
// Instantiate the drop-down template
|
||||
m_Dropdown = CreateDropdownList(m_Template.gameObject);
|
||||
m_Dropdown.name = "Dropdown List";
|
||||
m_Dropdown.SetActive(true);
|
||||
|
||||
// Make drop-down RectTransform have same values as original.
|
||||
RectTransform dropdownRectTransform = m_Dropdown.transform as RectTransform;
|
||||
dropdownRectTransform.SetParent(m_Template.transform.parent, false);
|
||||
|
||||
// Instantiate the drop-down list items
|
||||
|
||||
// Find the dropdown item and disable it.
|
||||
DropdownItem itemTemplate = m_Dropdown.GetComponentInChildren<DropdownItem>();
|
||||
|
||||
GameObject content = itemTemplate.rectTransform.parent.gameObject;
|
||||
RectTransform contentRectTransform = content.transform as RectTransform;
|
||||
itemTemplate.rectTransform.gameObject.SetActive(true);
|
||||
|
||||
// Get the rects of the dropdown and item
|
||||
Rect dropdownContentRect = contentRectTransform.rect;
|
||||
Rect itemTemplateRect = itemTemplate.rectTransform.rect;
|
||||
|
||||
// Calculate the visual offset between the item's edges and the background's edges
|
||||
Vector2 offsetMin = itemTemplateRect.min - dropdownContentRect.min + (Vector2)itemTemplate.rectTransform.localPosition;
|
||||
Vector2 offsetMax = itemTemplateRect.max - dropdownContentRect.max + (Vector2)itemTemplate.rectTransform.localPosition;
|
||||
Vector2 itemSize = itemTemplateRect.size;
|
||||
|
||||
m_Items.Clear();
|
||||
|
||||
Toggle prev = null;
|
||||
for (int i = 0; i < options.Count; ++i)
|
||||
{
|
||||
OptionData data = options[i];
|
||||
DropdownItem item = AddItem(data, value == i, itemTemplate, m_Items);
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
// Automatically set up a toggle state change listener
|
||||
item.toggle.isOn = value == i;
|
||||
item.toggle.onValueChanged.AddListener(x => OnSelectItem(item.toggle));
|
||||
|
||||
// Select current option
|
||||
if (item.toggle.isOn)
|
||||
item.toggle.Select();
|
||||
|
||||
// Automatically set up explicit navigation
|
||||
if (prev != null)
|
||||
{
|
||||
Navigation prevNav = prev.navigation;
|
||||
Navigation toggleNav = item.toggle.navigation;
|
||||
prevNav.mode = Navigation.Mode.Explicit;
|
||||
toggleNav.mode = Navigation.Mode.Explicit;
|
||||
|
||||
prevNav.selectOnDown = item.toggle;
|
||||
prevNav.selectOnRight = item.toggle;
|
||||
toggleNav.selectOnLeft = prev;
|
||||
toggleNav.selectOnUp = prev;
|
||||
|
||||
prev.navigation = prevNav;
|
||||
item.toggle.navigation = toggleNav;
|
||||
}
|
||||
prev = item.toggle;
|
||||
}
|
||||
|
||||
// Reposition all items now that all of them have been added
|
||||
Vector2 sizeDelta = contentRectTransform.sizeDelta;
|
||||
sizeDelta.y = itemSize.y * m_Items.Count + offsetMin.y - offsetMax.y;
|
||||
contentRectTransform.sizeDelta = sizeDelta;
|
||||
|
||||
float extraSpace = dropdownRectTransform.rect.height - contentRectTransform.rect.height;
|
||||
if (extraSpace > 0)
|
||||
dropdownRectTransform.sizeDelta = new Vector2(dropdownRectTransform.sizeDelta.x, dropdownRectTransform.sizeDelta.y - extraSpace);
|
||||
|
||||
// Invert anchoring and position if dropdown is partially or fully outside of canvas rect.
|
||||
// Typically this will have the effect of placing the dropdown above the button instead of below,
|
||||
// but it works as inversion regardless of initial setup.
|
||||
Vector3[] corners = new Vector3[4];
|
||||
dropdownRectTransform.GetWorldCorners(corners);
|
||||
|
||||
RectTransform rootCanvasRectTransform = rootCanvas.transform as RectTransform;
|
||||
Rect rootCanvasRect = rootCanvasRectTransform.rect;
|
||||
for (int axis = 0; axis < 2; axis++)
|
||||
{
|
||||
bool outside = false;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Vector3 corner = rootCanvasRectTransform.InverseTransformPoint(corners[i]);
|
||||
if (corner[axis] < rootCanvasRect.min[axis] || corner[axis] > rootCanvasRect.max[axis])
|
||||
{
|
||||
outside = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (outside)
|
||||
RectTransformUtility.FlipLayoutOnAxis(dropdownRectTransform, axis, false, false);
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_Items.Count; i++)
|
||||
{
|
||||
RectTransform itemRect = m_Items[i].rectTransform;
|
||||
itemRect.anchorMin = new Vector2(itemRect.anchorMin.x, 0);
|
||||
itemRect.anchorMax = new Vector2(itemRect.anchorMax.x, 0);
|
||||
itemRect.anchoredPosition = new Vector2(itemRect.anchoredPosition.x, offsetMin.y + itemSize.y * (m_Items.Count - 1 - i) + itemSize.y * itemRect.pivot.y);
|
||||
itemRect.sizeDelta = new Vector2(itemRect.sizeDelta.x, itemSize.y);
|
||||
}
|
||||
|
||||
// Fade in the popup
|
||||
AlphaFadeList(0.15f, 0f, 1f);
|
||||
|
||||
// Make drop-down template and item template inactive
|
||||
m_Template.gameObject.SetActive(false);
|
||||
itemTemplate.gameObject.SetActive(false);
|
||||
|
||||
m_Blocker = CreateBlocker(rootCanvas);
|
||||
}
|
||||
|
||||
protected virtual GameObject CreateBlocker(Canvas rootCanvas)
|
||||
{
|
||||
// Create blocker GameObject.
|
||||
GameObject blocker = new GameObject("Blocker");
|
||||
|
||||
// Setup blocker RectTransform to cover entire root canvas area.
|
||||
RectTransform blockerRect = blocker.AddComponent<RectTransform>();
|
||||
blockerRect.SetParent(rootCanvas.transform, false);
|
||||
blockerRect.anchorMin = Vector3.zero;
|
||||
blockerRect.anchorMax = Vector3.one;
|
||||
blockerRect.sizeDelta = Vector2.zero;
|
||||
|
||||
// Make blocker be in separate canvas in same layer as dropdown and in layer just below it.
|
||||
Canvas blockerCanvas = blocker.AddComponent<Canvas>();
|
||||
blockerCanvas.overrideSorting = true;
|
||||
Canvas dropdownCanvas = m_Dropdown.GetComponent<Canvas>();
|
||||
blockerCanvas.sortingLayerID = dropdownCanvas.sortingLayerID;
|
||||
blockerCanvas.sortingOrder = dropdownCanvas.sortingOrder - 1;
|
||||
|
||||
// Add raycaster since it's needed to block.
|
||||
blocker.AddComponent<GraphicRaycaster>();
|
||||
|
||||
// Add image since it's needed to block, but make it clear.
|
||||
Image blockerImage = blocker.AddComponent<Image>();
|
||||
blockerImage.color = Color.clear;
|
||||
|
||||
// Add button since it's needed to block, and to close the dropdown when blocking area is clicked.
|
||||
Button blockerButton = blocker.AddComponent<Button>();
|
||||
blockerButton.onClick.AddListener(Hide);
|
||||
|
||||
return blocker;
|
||||
}
|
||||
|
||||
protected virtual void DestroyBlocker(GameObject blocker)
|
||||
{
|
||||
Destroy(blocker);
|
||||
}
|
||||
|
||||
protected virtual GameObject CreateDropdownList(GameObject template)
|
||||
{
|
||||
return (GameObject)Instantiate(template);
|
||||
}
|
||||
|
||||
protected virtual void DestroyDropdownList(GameObject dropdownList)
|
||||
{
|
||||
Destroy(dropdownList);
|
||||
}
|
||||
|
||||
protected virtual DropdownItem CreateItem(DropdownItem itemTemplate)
|
||||
{
|
||||
return (DropdownItem)Instantiate(itemTemplate);
|
||||
}
|
||||
|
||||
protected virtual void DestroyItem(DropdownItem item)
|
||||
{
|
||||
// No action needed since destroying the dropdown list destroys all contained items as well.
|
||||
}
|
||||
|
||||
// Add a new drop-down list item with the specified values.
|
||||
private DropdownItem AddItem(OptionData data, bool selected, DropdownItem itemTemplate, List<DropdownItem> items)
|
||||
{
|
||||
// Add a new item to the dropdown.
|
||||
DropdownItem item = CreateItem(itemTemplate);
|
||||
item.rectTransform.SetParent(itemTemplate.rectTransform.parent, false);
|
||||
|
||||
item.gameObject.SetActive(true);
|
||||
item.gameObject.name = "Item " + items.Count + (data.text != null ? ": " + data.text : "");
|
||||
|
||||
if (item.toggle != null)
|
||||
{
|
||||
item.toggle.isOn = false;
|
||||
}
|
||||
|
||||
// Set the item's data
|
||||
if (item.text)
|
||||
item.text.text = data.text;
|
||||
if (item.image)
|
||||
{
|
||||
item.image.sprite = data.image;
|
||||
item.image.enabled = (item.image.sprite != null);
|
||||
}
|
||||
|
||||
items.Add(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
private void AlphaFadeList(float duration, float alpha)
|
||||
{
|
||||
CanvasGroup group = m_Dropdown.GetComponent<CanvasGroup>();
|
||||
AlphaFadeList(duration, group.alpha, alpha);
|
||||
}
|
||||
|
||||
private void AlphaFadeList(float duration, float start, float end)
|
||||
{
|
||||
if (end.Equals(start))
|
||||
return;
|
||||
|
||||
FloatTween tween = new FloatTween { duration = duration, startValue = start, targetValue = end };
|
||||
tween.AddOnChangedCallback(SetAlpha);
|
||||
tween.ignoreTimeScale = true;
|
||||
m_AlphaTweenRunner.StartTween(tween);
|
||||
}
|
||||
|
||||
private void SetAlpha(float alpha)
|
||||
{
|
||||
if (!m_Dropdown)
|
||||
return;
|
||||
CanvasGroup group = m_Dropdown.GetComponent<CanvasGroup>();
|
||||
group.alpha = alpha;
|
||||
}
|
||||
|
||||
// Hide the dropdown.
|
||||
public void Hide()
|
||||
{
|
||||
if (m_Dropdown != null)
|
||||
{
|
||||
AlphaFadeList(0.15f, 0f);
|
||||
|
||||
// User could have disabled the dropdown during the OnValueChanged call.
|
||||
if (IsActive())
|
||||
StartCoroutine(DelayedDestroyDropdownList(0.15f));
|
||||
}
|
||||
if (m_Blocker != null)
|
||||
DestroyBlocker(m_Blocker);
|
||||
m_Blocker = null;
|
||||
Select();
|
||||
}
|
||||
|
||||
private IEnumerator DelayedDestroyDropdownList(float delay)
|
||||
{
|
||||
|
||||
yield return new WaitForSecondsRealtime(delay); // Unity 5.4
|
||||
|
||||
for (int i = 0; i < m_Items.Count; i++)
|
||||
{
|
||||
if (m_Items[i] != null)
|
||||
DestroyItem(m_Items[i]);
|
||||
m_Items.Clear();
|
||||
}
|
||||
if (m_Dropdown != null)
|
||||
DestroyDropdownList(m_Dropdown);
|
||||
m_Dropdown = null;
|
||||
}
|
||||
|
||||
// Change the value and hide the dropdown.
|
||||
private void OnSelectItem(Toggle toggle)
|
||||
{
|
||||
if (!toggle.isOn)
|
||||
toggle.isOn = true;
|
||||
|
||||
int selectedIndex = -1;
|
||||
Transform tr = toggle.transform;
|
||||
Transform parent = tr.parent;
|
||||
for (int i = 0; i < parent.childCount; i++)
|
||||
{
|
||||
if (parent.GetChild(i) == tr)
|
||||
{
|
||||
// Subtract one to account for template child.
|
||||
selectedIndex = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedIndex < 0)
|
||||
return;
|
||||
|
||||
value = selectedIndex;
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_Dropdown.cs.meta
Normal file
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_Dropdown.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7b743370ac3e4ec2a1668f5455a8ef8a
|
||||
timeCreated: 1464846493
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 55f8e7db943fe154ea3b3289fc82f8fa, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
578
Assets/TextMesh Pro/Scripts/Runtime/TMP_FontAsset.cs
Normal file
578
Assets/TextMesh Pro/Scripts/Runtime/TMP_FontAsset.cs
Normal file
|
@ -0,0 +1,578 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Contains the font asset for the specified font weight styles.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public struct TMP_FontWeights
|
||||
{
|
||||
public TMP_FontAsset regularTypeface;
|
||||
public TMP_FontAsset italicTypeface;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class TMP_FontAsset : TMP_Asset
|
||||
{
|
||||
/// <summary>
|
||||
/// Default Font Asset used as last resort when glyphs are missing.
|
||||
/// </summary>
|
||||
public static TMP_FontAsset defaultFontAsset
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_defaultFontAsset == null)
|
||||
{
|
||||
s_defaultFontAsset = Resources.Load<TMP_FontAsset>("Fonts & Materials/LiberationSans SDF");
|
||||
}
|
||||
|
||||
return s_defaultFontAsset;
|
||||
}
|
||||
}
|
||||
private static TMP_FontAsset s_defaultFontAsset;
|
||||
|
||||
|
||||
public enum FontAssetTypes { None = 0, SDF = 1, Bitmap = 2 };
|
||||
public FontAssetTypes fontAssetType;
|
||||
|
||||
/// <summary>
|
||||
/// The general information about the font.
|
||||
/// </summary>
|
||||
public FaceInfo fontInfo
|
||||
{ get { return m_fontInfo; } }
|
||||
|
||||
[SerializeField]
|
||||
private FaceInfo m_fontInfo;
|
||||
|
||||
[SerializeField]
|
||||
public Texture2D atlas; // Should add a property to make this read-only.
|
||||
|
||||
|
||||
// Glyph Info
|
||||
|
||||
[SerializeField]
|
||||
private List<TMP_Glyph> m_glyphInfoList;
|
||||
|
||||
public Dictionary<int, TMP_Glyph> characterDictionary
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_characterDictionary == null)
|
||||
ReadFontDefinition();
|
||||
|
||||
return m_characterDictionary;
|
||||
}
|
||||
}
|
||||
private Dictionary<int, TMP_Glyph> m_characterDictionary;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary containing the kerning data
|
||||
/// </summary>
|
||||
public Dictionary<int, KerningPair> kerningDictionary
|
||||
{
|
||||
get { return m_kerningDictionary; }
|
||||
}
|
||||
private Dictionary<int, KerningPair> m_kerningDictionary;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public KerningTable kerningInfo
|
||||
{
|
||||
get { return m_kerningInfo; }
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private KerningTable m_kerningInfo;
|
||||
|
||||
[SerializeField]
|
||||
#pragma warning disable 0169 // Property is used to create an empty Kerning Pair in the editor.
|
||||
private KerningPair m_kerningPair; // Used for creating a new kerning pair in Editor Panel.
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// List which contains the Fallback font assets for this font.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
public List<TMP_FontAsset> fallbackFontAssets;
|
||||
|
||||
|
||||
// TODO : Not implemented yet.
|
||||
[SerializeField]
|
||||
public FontCreationSetting fontCreationSettings;
|
||||
|
||||
// FONT WEIGHTS
|
||||
[SerializeField]
|
||||
public TMP_FontWeights[] fontWeights = new TMP_FontWeights[10];
|
||||
|
||||
private int[] m_characterSet; // Array containing all the characters in this font asset.
|
||||
|
||||
public float normalStyle = 0;
|
||||
public float normalSpacingOffset = 0;
|
||||
|
||||
public float boldStyle = 0.75f;
|
||||
public float boldSpacing = 7f;
|
||||
public byte italicStyle = 35;
|
||||
public byte tabSize = 10;
|
||||
|
||||
private byte m_oldTabSize;
|
||||
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
//Debug.Log("OnEnable has been called on " + this.name);
|
||||
}
|
||||
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
//Debug.Log("TextMeshPro Font Asset [" + this.name + "] has been disabled!");
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void OnValidate()
|
||||
{
|
||||
if (m_oldTabSize != tabSize)
|
||||
{
|
||||
m_oldTabSize = tabSize;
|
||||
ReadFontDefinition();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="faceInfo"></param>
|
||||
public void AddFaceInfo(FaceInfo faceInfo)
|
||||
{
|
||||
m_fontInfo = faceInfo;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="glyphInfo"></param>
|
||||
public void AddGlyphInfo(TMP_Glyph[] glyphInfo)
|
||||
{
|
||||
m_glyphInfoList = new List<TMP_Glyph>();
|
||||
int characterCount = glyphInfo.Length;
|
||||
|
||||
m_fontInfo.CharacterCount = characterCount;
|
||||
m_characterSet = new int[characterCount];
|
||||
|
||||
for (int i = 0; i < characterCount; i++)
|
||||
{
|
||||
TMP_Glyph g = new TMP_Glyph();
|
||||
g.id = glyphInfo[i].id;
|
||||
g.x = glyphInfo[i].x;
|
||||
g.y = glyphInfo[i].y;
|
||||
g.width = glyphInfo[i].width;
|
||||
g.height = glyphInfo[i].height;
|
||||
g.xOffset = glyphInfo[i].xOffset;
|
||||
g.yOffset = (glyphInfo[i].yOffset);
|
||||
g.xAdvance = glyphInfo[i].xAdvance;
|
||||
g.scale = 1;
|
||||
|
||||
m_glyphInfoList.Add(g);
|
||||
|
||||
// While iterating through list of glyphs, find the Descender & Ascender for this GlyphSet.
|
||||
//m_fontInfo.Ascender = Mathf.Max(m_fontInfo.Ascender, glyphInfo[i].yOffset);
|
||||
//m_fontInfo.Descender = Mathf.Min(m_fontInfo.Descender, glyphInfo[i].yOffset - glyphInfo[i].height);
|
||||
//Debug.Log(m_fontInfo.Ascender + " " + m_fontInfo.Descender);
|
||||
m_characterSet[i] = g.id; // Add Character ID to Array to make it easier to get the kerning pairs.
|
||||
}
|
||||
|
||||
// Sort List by ID.
|
||||
m_glyphInfoList = m_glyphInfoList.OrderBy(s => s.id).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="kerningTable"></param>
|
||||
public void AddKerningInfo(KerningTable kerningTable)
|
||||
{
|
||||
m_kerningInfo = kerningTable;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void ReadFontDefinition()
|
||||
{
|
||||
//Debug.Log("Reading Font Definition for " + this.name + ".");
|
||||
// Make sure that we have a Font Asset file assigned.
|
||||
if (m_fontInfo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check Font Asset type
|
||||
//Debug.Log(name + " " + fontAssetType);
|
||||
|
||||
// Create new instance of GlyphInfo Dictionary for fast access to glyph info.
|
||||
m_characterDictionary = new Dictionary<int, TMP_Glyph>();
|
||||
for (int i = 0; i < m_glyphInfoList.Count; i++)
|
||||
{
|
||||
TMP_Glyph glyph = m_glyphInfoList[i];
|
||||
|
||||
if (!m_characterDictionary.ContainsKey(glyph.id))
|
||||
m_characterDictionary.Add(glyph.id, glyph);
|
||||
|
||||
// Compatibility
|
||||
if (glyph.scale == 0) glyph.scale = 1;
|
||||
}
|
||||
|
||||
|
||||
//Debug.Log("PRE: BaseLine:" + m_fontInfo.Baseline + " Ascender:" + m_fontInfo.Ascender + " Descender:" + m_fontInfo.Descender); // + " Centerline:" + m_fontInfo.CenterLine);
|
||||
|
||||
TMP_Glyph temp_charInfo = new TMP_Glyph();
|
||||
|
||||
// Add Character (10) LineFeed, (13) Carriage Return & Space (32) to Dictionary if they don't exists.
|
||||
if (m_characterDictionary.ContainsKey(32))
|
||||
{
|
||||
m_characterDictionary[32].width = m_characterDictionary[32].xAdvance; // m_fontInfo.Ascender / 5;
|
||||
m_characterDictionary[32].height = m_fontInfo.Ascender - m_fontInfo.Descender;
|
||||
m_characterDictionary[32].yOffset= m_fontInfo.Ascender;
|
||||
m_characterDictionary[32].scale = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log("Adding Character 32 (Space) to Dictionary for Font (" + m_fontInfo.Name + ").");
|
||||
temp_charInfo = new TMP_Glyph();
|
||||
temp_charInfo.id = 32;
|
||||
temp_charInfo.x = 0;
|
||||
temp_charInfo.y = 0;
|
||||
temp_charInfo.width = m_fontInfo.Ascender / 5;
|
||||
temp_charInfo.height = m_fontInfo.Ascender - m_fontInfo.Descender;
|
||||
temp_charInfo.xOffset = 0;
|
||||
temp_charInfo.yOffset = m_fontInfo.Ascender;
|
||||
temp_charInfo.xAdvance = m_fontInfo.PointSize / 4;
|
||||
temp_charInfo.scale = 1;
|
||||
m_characterDictionary.Add(32, temp_charInfo);
|
||||
}
|
||||
|
||||
// Add Non-Breaking Space (160)
|
||||
if (!m_characterDictionary.ContainsKey(160))
|
||||
{
|
||||
temp_charInfo = TMP_Glyph.Clone(m_characterDictionary[32]);
|
||||
m_characterDictionary.Add(160, temp_charInfo);
|
||||
}
|
||||
|
||||
// Add Zero Width Space (8203)
|
||||
if (!m_characterDictionary.ContainsKey(8203))
|
||||
{
|
||||
temp_charInfo = TMP_Glyph.Clone(m_characterDictionary[32]);
|
||||
temp_charInfo.width = 0;
|
||||
temp_charInfo.xAdvance = 0;
|
||||
m_characterDictionary.Add(8203, temp_charInfo);
|
||||
}
|
||||
|
||||
//Add Zero Width no-break space (8288)
|
||||
if (!m_characterDictionary.ContainsKey(8288))
|
||||
{
|
||||
temp_charInfo = TMP_Glyph.Clone(m_characterDictionary[32]);
|
||||
temp_charInfo.width = 0;
|
||||
temp_charInfo.xAdvance = 0;
|
||||
m_characterDictionary.Add(8288, temp_charInfo);
|
||||
}
|
||||
|
||||
// Add Linefeed (10)
|
||||
if (m_characterDictionary.ContainsKey(10) == false)
|
||||
{
|
||||
//Debug.Log("Adding Character 10 (Linefeed) to Dictionary for Font (" + m_fontInfo.Name + ").");
|
||||
|
||||
temp_charInfo = new TMP_Glyph();
|
||||
temp_charInfo.id = 10;
|
||||
temp_charInfo.x = 0; // m_characterDictionary[32].x;
|
||||
temp_charInfo.y = 0; // m_characterDictionary[32].y;
|
||||
temp_charInfo.width = 10; // m_characterDictionary[32].width;
|
||||
temp_charInfo.height = m_characterDictionary[32].height;
|
||||
temp_charInfo.xOffset = 0; // m_characterDictionary[32].xOffset;
|
||||
temp_charInfo.yOffset = m_characterDictionary[32].yOffset;
|
||||
temp_charInfo.xAdvance = 0;
|
||||
temp_charInfo.scale = 1;
|
||||
m_characterDictionary.Add(10, temp_charInfo);
|
||||
|
||||
if (!m_characterDictionary.ContainsKey(13))
|
||||
m_characterDictionary.Add(13, temp_charInfo);
|
||||
}
|
||||
|
||||
// Add Tab Character to Dictionary. Tab is Tab Size * Space Character Width.
|
||||
if (m_characterDictionary.ContainsKey(9) == false)
|
||||
{
|
||||
//Debug.Log("Adding Character 9 (Tab) to Dictionary for Font (" + m_fontInfo.Name + ").");
|
||||
|
||||
temp_charInfo = new TMP_Glyph();
|
||||
temp_charInfo.id = 9;
|
||||
temp_charInfo.x = m_characterDictionary[32].x;
|
||||
temp_charInfo.y = m_characterDictionary[32].y;
|
||||
temp_charInfo.width = m_characterDictionary[32].width * tabSize + (m_characterDictionary[32].xAdvance - m_characterDictionary[32].width) * (tabSize - 1);
|
||||
temp_charInfo.height = m_characterDictionary[32].height;
|
||||
temp_charInfo.xOffset = m_characterDictionary[32].xOffset;
|
||||
temp_charInfo.yOffset = m_characterDictionary[32].yOffset;
|
||||
temp_charInfo.xAdvance = m_characterDictionary[32].xAdvance * tabSize;
|
||||
temp_charInfo.scale = 1;
|
||||
m_characterDictionary.Add(9, temp_charInfo);
|
||||
}
|
||||
|
||||
// Centerline is located at the center of character like { or in the middle of the lowercase o.
|
||||
//m_fontInfo.CenterLine = m_characterDictionary[111].yOffset - m_characterDictionary[111].height * 0.5f;
|
||||
|
||||
// Tab Width is using the same xAdvance as space (32).
|
||||
m_fontInfo.TabWidth = m_characterDictionary[9].xAdvance;
|
||||
|
||||
// Set Cap Height
|
||||
if (m_fontInfo.CapHeight == 0 && m_characterDictionary.ContainsKey(72))
|
||||
m_fontInfo.CapHeight = m_characterDictionary[72].yOffset;
|
||||
|
||||
// Adjust Font Scale for compatibility reasons
|
||||
if (m_fontInfo.Scale == 0)
|
||||
m_fontInfo.Scale = 1.0f;
|
||||
|
||||
// Set Strikethrough Offset (if needed)
|
||||
if (m_fontInfo.strikethrough == 0)
|
||||
m_fontInfo.strikethrough = m_fontInfo.CapHeight / 2.5f;
|
||||
|
||||
// Set Padding value for legacy font assets.
|
||||
if (m_fontInfo.Padding == 0)
|
||||
{
|
||||
if (material.HasProperty(ShaderUtilities.ID_GradientScale))
|
||||
m_fontInfo.Padding = material.GetFloat(ShaderUtilities.ID_GradientScale) - 1;
|
||||
}
|
||||
|
||||
// Populate Dictionary with Kerning Information
|
||||
m_kerningDictionary = new Dictionary<int, KerningPair>();
|
||||
List<KerningPair> pairs = m_kerningInfo.kerningPairs;
|
||||
|
||||
//Debug.Log(m_fontInfo.Name + " has " + pairs.Count + " Kerning Pairs.");
|
||||
for (int i = 0; i < pairs.Count; i++)
|
||||
{
|
||||
KerningPair pair = pairs[i];
|
||||
|
||||
// Convert legacy kerning data
|
||||
if (pair.xOffset != 0)
|
||||
pairs[i].ConvertLegacyKerningData();
|
||||
|
||||
KerningPairKey uniqueKey = new KerningPairKey(pair.firstGlyph, pair.secondGlyph);
|
||||
|
||||
if (m_kerningDictionary.ContainsKey((int)uniqueKey.key) == false)
|
||||
{
|
||||
m_kerningDictionary.Add((int)uniqueKey.key, pair);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!TMP_Settings.warningsDisabled)
|
||||
Debug.LogWarning("Kerning Key for [" + uniqueKey.ascii_Left + "] and [" + uniqueKey.ascii_Right + "] already exists.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Compute Hashcode for the font asset name
|
||||
hashCode = TMP_TextUtilities.GetSimpleHashCode(this.name);
|
||||
|
||||
// Compute Hashcode for the material name
|
||||
materialHashCode = TMP_TextUtilities.GetSimpleHashCode(material.name);
|
||||
|
||||
// Unload font atlas texture
|
||||
//ShaderUtilities.GetShaderPropertyIDs();
|
||||
//Resources.UnloadAsset(material.GetTexture(ShaderUtilities.ID_MainTex));
|
||||
|
||||
// Initialize Font Weights if needed
|
||||
//InitializeFontWeights();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to sort the list of glyphs.
|
||||
/// </summary>
|
||||
public void SortGlyphs()
|
||||
{
|
||||
if (m_glyphInfoList == null || m_glyphInfoList.Count == 0) return;
|
||||
|
||||
m_glyphInfoList = m_glyphInfoList.OrderBy(item => item.id).ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to check if a certain character exists in the font asset.
|
||||
/// </summary>
|
||||
/// <param name="character"></param>
|
||||
/// <returns></returns>
|
||||
public bool HasCharacter(int character)
|
||||
{
|
||||
if (m_characterDictionary == null)
|
||||
return false;
|
||||
|
||||
if (m_characterDictionary.ContainsKey(character))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to check if a certain character exists in the font asset.
|
||||
/// </summary>
|
||||
/// <param name="character"></param>
|
||||
/// <returns></returns>
|
||||
public bool HasCharacter(char character)
|
||||
{
|
||||
if (m_characterDictionary == null)
|
||||
return false;
|
||||
|
||||
if (m_characterDictionary.ContainsKey(character))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to check if a character is contained in a font asset with the option to also check through fallback font assets.
|
||||
/// </summary>
|
||||
/// <param name="character"></param>
|
||||
/// <param name="searchFallbacks"></param>
|
||||
/// <returns></returns>
|
||||
public bool HasCharacter(char character, bool searchFallbacks)
|
||||
{
|
||||
if (m_characterDictionary == null)
|
||||
return false;
|
||||
|
||||
// Check font asset
|
||||
if (m_characterDictionary.ContainsKey(character))
|
||||
return true;
|
||||
|
||||
|
||||
if (searchFallbacks)
|
||||
{
|
||||
// Check Font Asset Fallback fonts.
|
||||
if (fallbackFontAssets != null && fallbackFontAssets.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < fallbackFontAssets.Count && fallbackFontAssets[i] != null; i++)
|
||||
{
|
||||
if (fallbackFontAssets[i].characterDictionary != null && fallbackFontAssets[i].characterDictionary.ContainsKey(character))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check general fallback font assets.
|
||||
if (TMP_Settings.fallbackFontAssets != null && TMP_Settings.fallbackFontAssets.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < TMP_Settings.fallbackFontAssets.Count && TMP_Settings.fallbackFontAssets[i] != null; i++)
|
||||
{
|
||||
if (TMP_Settings.fallbackFontAssets[i].characterDictionary != null && TMP_Settings.fallbackFontAssets[i].characterDictionary.ContainsKey(character))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to check if certain characters exists in the font asset. Function returns a list of missing characters.
|
||||
/// </summary>
|
||||
/// <param name="character"></param>
|
||||
/// <returns></returns>
|
||||
public bool HasCharacters(string text, out List<char> missingCharacters)
|
||||
{
|
||||
if (m_characterDictionary == null)
|
||||
{
|
||||
missingCharacters = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
missingCharacters = new List<char>();
|
||||
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
if (!m_characterDictionary.ContainsKey(text[i]))
|
||||
missingCharacters.Add(text[i]);
|
||||
}
|
||||
|
||||
if (missingCharacters.Count == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to check if certain characters exists in the font asset. Function returns false if any characters are missing.
|
||||
/// </summary>
|
||||
/// <param name="text">String containing the characters to check</param>
|
||||
/// <returns></returns>
|
||||
public bool HasCharacters(string text)
|
||||
{
|
||||
if (m_characterDictionary == null)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
if (!m_characterDictionary.ContainsKey(text[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to extract all the characters from a font asset.
|
||||
/// </summary>
|
||||
/// <param name="fontAsset"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetCharacters(TMP_FontAsset fontAsset)
|
||||
{
|
||||
string characters = string.Empty;
|
||||
|
||||
for (int i = 0; i < fontAsset.m_glyphInfoList.Count; i++)
|
||||
{
|
||||
characters += (char)fontAsset.m_glyphInfoList[i].id;
|
||||
}
|
||||
|
||||
return characters;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function which returns an array that contains all the characters from a font asset.
|
||||
/// </summary>
|
||||
/// <param name="fontAsset"></param>
|
||||
/// <returns></returns>
|
||||
public static int[] GetCharactersArray(TMP_FontAsset fontAsset)
|
||||
{
|
||||
int[] characters = new int[fontAsset.m_glyphInfoList.Count];
|
||||
|
||||
for (int i = 0; i < fontAsset.m_glyphInfoList.Count; i++)
|
||||
{
|
||||
characters[i] = fontAsset.m_glyphInfoList[i].id;
|
||||
}
|
||||
|
||||
return characters;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_FontAsset.cs.meta
Normal file
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_FontAsset.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 71c1514a6bd24e1e882cebbe1904ce04
|
||||
timeCreated: 1463559269
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 7b024bd8880037b4bb6bcd92fa3620e4, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3543
Assets/TextMesh Pro/Scripts/Runtime/TMP_InputField.cs
Normal file
3543
Assets/TextMesh Pro/Scripts/Runtime/TMP_InputField.cs
Normal file
File diff suppressed because it is too large
Load diff
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_InputField.cs.meta
Normal file
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_InputField.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2da0c512f12947e489f739169773d7ca
|
||||
timeCreated: 1459318928
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: b0033ea3f5cebf942a8f9a11d98a0944, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
15
Assets/TextMesh Pro/Scripts/Runtime/TMP_InputValidator.cs
Normal file
15
Assets/TextMesh Pro/Scripts/Runtime/TMP_InputValidator.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom text input validator where user can implement their own custom character validation.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public abstract class TMP_InputValidator : ScriptableObject
|
||||
{
|
||||
public abstract char Validate(ref string text, ref int pos, char ch);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 79ff392d1bde4ad78a3836a4a480392d
|
||||
timeCreated: 1473021069
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
50
Assets/TextMesh Pro/Scripts/Runtime/TMP_LineInfo.cs
Normal file
50
Assets/TextMesh Pro/Scripts/Runtime/TMP_LineInfo.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
namespace TMPro
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Structure which contains information about the individual lines of text.
|
||||
/// </summary>
|
||||
public struct TMP_LineInfo
|
||||
{
|
||||
public int characterCount;
|
||||
public int visibleCharacterCount;
|
||||
public int spaceCount;
|
||||
public int wordCount;
|
||||
public int firstCharacterIndex;
|
||||
public int firstVisibleCharacterIndex;
|
||||
public int lastCharacterIndex;
|
||||
public int lastVisibleCharacterIndex;
|
||||
|
||||
public float length;
|
||||
public float lineHeight;
|
||||
public float ascender;
|
||||
public float baseline;
|
||||
public float descender;
|
||||
public float maxAdvance;
|
||||
|
||||
public float width;
|
||||
public float marginLeft;
|
||||
public float marginRight;
|
||||
|
||||
public TextAlignmentOptions alignment;
|
||||
public Extents lineExtents;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function returning the current line of text.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public string GetLineText()
|
||||
//{
|
||||
// string word = string.Empty;
|
||||
// TMP_CharacterInfo[] charInfo = textComponent.textInfo.characterInfo;
|
||||
|
||||
// for (int i = firstCharacterIndex; i < lastCharacterIndex + 1; i++)
|
||||
// {
|
||||
// word += charInfo[i].character;
|
||||
// }
|
||||
|
||||
// return word;
|
||||
//}
|
||||
}
|
||||
}
|
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_LineInfo.cs.meta
Normal file
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_LineInfo.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b6e75d7f429a4e7e9e1ffb4f85cff49f
|
||||
timeCreated: 1464310403
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
Assets/TextMesh Pro/Scripts/Runtime/TMP_ListPool.cs
Normal file
21
Assets/TextMesh Pro/Scripts/Runtime/TMP_ListPool.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
internal static class TMP_ListPool<T>
|
||||
{
|
||||
// Object pool to avoid allocations.
|
||||
private static readonly TMP_ObjectPool<List<T>> s_ListPool = new TMP_ObjectPool<List<T>>(null, l => l.Clear());
|
||||
|
||||
public static List<T> Get()
|
||||
{
|
||||
return s_ListPool.Get();
|
||||
}
|
||||
|
||||
public static void Release(List<T> toRelease)
|
||||
{
|
||||
s_ListPool.Release(toRelease);
|
||||
}
|
||||
}
|
||||
}
|
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_ListPool.cs.meta
Normal file
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_ListPool.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 28375447bcea455c9b51a6650b10c9d7
|
||||
timeCreated: 1458521386
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
633
Assets/TextMesh Pro/Scripts/Runtime/TMP_MaterialManager.cs
Normal file
633
Assets/TextMesh Pro/Scripts/Runtime/TMP_MaterialManager.cs
Normal file
|
@ -0,0 +1,633 @@
|
|||
//#define DEBUG_ON
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
|
||||
public static class TMP_MaterialManager
|
||||
{
|
||||
private static List<MaskingMaterial> m_materialList = new List<MaskingMaterial>();
|
||||
|
||||
private static Dictionary<long, FallbackMaterial> m_fallbackMaterials = new Dictionary<long, FallbackMaterial>();
|
||||
private static Dictionary<int, long> m_fallbackMaterialLookup = new Dictionary<int, long>();
|
||||
private static List<FallbackMaterial> m_fallbackCleanupList = new List<FallbackMaterial>();
|
||||
|
||||
private static bool isFallbackListDirty;
|
||||
|
||||
static TMP_MaterialManager()
|
||||
{
|
||||
Camera.onPreRender += new Camera.CameraCallback(OnPreRender);
|
||||
Canvas.willRenderCanvases += new Canvas.WillRenderCanvases(OnPreRenderCanvas);
|
||||
}
|
||||
|
||||
|
||||
static void OnPreRender(Camera cam)
|
||||
{
|
||||
if (isFallbackListDirty)
|
||||
{
|
||||
//Debug.Log("1 - Cleaning up Fallback Materials.");
|
||||
CleanupFallbackMaterials();
|
||||
isFallbackListDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void OnPreRenderCanvas()
|
||||
{
|
||||
if (isFallbackListDirty)
|
||||
{
|
||||
//Debug.Log("2 - Cleaning up Fallback Materials.");
|
||||
CleanupFallbackMaterials();
|
||||
isFallbackListDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a Masking Material Instance for the given ID
|
||||
/// </summary>
|
||||
/// <param name="baseMaterial"></param>
|
||||
/// <param name="stencilID"></param>
|
||||
/// <returns></returns>
|
||||
public static Material GetStencilMaterial(Material baseMaterial, int stencilID)
|
||||
{
|
||||
// Check if Material supports masking
|
||||
if (!baseMaterial.HasProperty(ShaderUtilities.ID_StencilID))
|
||||
{
|
||||
Debug.LogWarning("Selected Shader does not support Stencil Masking. Please select the Distance Field or Mobile Distance Field Shader.");
|
||||
return baseMaterial;
|
||||
}
|
||||
|
||||
int baseMaterialID = baseMaterial.GetInstanceID();
|
||||
|
||||
// If baseMaterial already has a corresponding masking material, return it.
|
||||
for (int i = 0; i < m_materialList.Count; i++)
|
||||
{
|
||||
if (m_materialList[i].baseMaterial.GetInstanceID() == baseMaterialID && m_materialList[i].stencilID == stencilID)
|
||||
{
|
||||
m_materialList[i].count += 1;
|
||||
|
||||
#if DEBUG_ON
|
||||
ListMaterials();
|
||||
#endif
|
||||
|
||||
return m_materialList[i].stencilMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
// No matching masking material found. Create and return a new one.
|
||||
|
||||
Material stencilMaterial;
|
||||
|
||||
//Create new Masking Material Instance for this Base Material
|
||||
stencilMaterial = new Material(baseMaterial);
|
||||
stencilMaterial.hideFlags = HideFlags.HideAndDontSave;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
stencilMaterial.name += " Masking ID:" + stencilID;
|
||||
#endif
|
||||
|
||||
stencilMaterial.shaderKeywords = baseMaterial.shaderKeywords;
|
||||
|
||||
// Set Stencil Properties
|
||||
ShaderUtilities.GetShaderPropertyIDs();
|
||||
stencilMaterial.SetFloat(ShaderUtilities.ID_StencilID, stencilID);
|
||||
//stencilMaterial.SetFloat(ShaderUtilities.ID_StencilOp, 0);
|
||||
stencilMaterial.SetFloat(ShaderUtilities.ID_StencilComp, 4);
|
||||
//stencilMaterial.SetFloat(ShaderUtilities.ID_StencilReadMask, stencilID);
|
||||
//stencilMaterial.SetFloat(ShaderUtilities.ID_StencilWriteMask, 0);
|
||||
|
||||
MaskingMaterial temp = new MaskingMaterial();
|
||||
temp.baseMaterial = baseMaterial;
|
||||
temp.stencilMaterial = stencilMaterial;
|
||||
temp.stencilID = stencilID;
|
||||
temp.count = 1;
|
||||
|
||||
m_materialList.Add(temp);
|
||||
|
||||
#if DEBUG_ON
|
||||
ListMaterials();
|
||||
#endif
|
||||
|
||||
return stencilMaterial;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to release the stencil material.
|
||||
/// </summary>
|
||||
/// <param name="stencilMaterial"></param>
|
||||
public static void ReleaseStencilMaterial(Material stencilMaterial)
|
||||
{
|
||||
int stencilMaterialID = stencilMaterial.GetInstanceID();
|
||||
|
||||
for (int i = 0; i < m_materialList.Count; i++)
|
||||
{
|
||||
if (m_materialList[i].stencilMaterial.GetInstanceID() == stencilMaterialID)
|
||||
{
|
||||
if (m_materialList[i].count > 1)
|
||||
m_materialList[i].count -= 1;
|
||||
else
|
||||
{
|
||||
Object.DestroyImmediate(m_materialList[i].stencilMaterial);
|
||||
m_materialList.RemoveAt(i);
|
||||
stencilMaterial = null;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if DEBUG_ON
|
||||
ListMaterials();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Function which returns the base material associated with a Masking Material
|
||||
public static Material GetBaseMaterial(Material stencilMaterial)
|
||||
{
|
||||
// Check if maskingMaterial already has a base material associated with it.
|
||||
int index = m_materialList.FindIndex(item => item.stencilMaterial == stencilMaterial);
|
||||
|
||||
if (index == -1)
|
||||
return null;
|
||||
else
|
||||
return m_materialList[index].baseMaterial;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to set the Material Stencil ID
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
/// <param name="stencilID"></param>
|
||||
/// <returns></returns>
|
||||
public static Material SetStencil(Material material, int stencilID)
|
||||
{
|
||||
material.SetFloat(ShaderUtilities.ID_StencilID, stencilID);
|
||||
|
||||
if (stencilID == 0)
|
||||
material.SetFloat(ShaderUtilities.ID_StencilComp, 8);
|
||||
else
|
||||
material.SetFloat(ShaderUtilities.ID_StencilComp, 4);
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
|
||||
public static void AddMaskingMaterial(Material baseMaterial, Material stencilMaterial, int stencilID)
|
||||
{
|
||||
// Check if maskingMaterial already has a base material associated with it.
|
||||
int index = m_materialList.FindIndex(item => item.stencilMaterial == stencilMaterial);
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
MaskingMaterial temp = new MaskingMaterial();
|
||||
temp.baseMaterial = baseMaterial;
|
||||
temp.stencilMaterial = stencilMaterial;
|
||||
temp.stencilID = stencilID;
|
||||
temp.count = 1;
|
||||
|
||||
m_materialList.Add(temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
stencilMaterial = m_materialList[index].stencilMaterial;
|
||||
m_materialList[index].count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void RemoveStencilMaterial(Material stencilMaterial)
|
||||
{
|
||||
// Check if maskingMaterial is already on the list.
|
||||
int index = m_materialList.FindIndex(item => item.stencilMaterial == stencilMaterial);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
m_materialList.RemoveAt(index);
|
||||
}
|
||||
|
||||
#if DEBUG_ON
|
||||
ListMaterials();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void ReleaseBaseMaterial(Material baseMaterial)
|
||||
{
|
||||
// Check if baseMaterial already has a masking material associated with it.
|
||||
int index = m_materialList.FindIndex(item => item.baseMaterial == baseMaterial);
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
Debug.Log("No Masking Material exists for " + baseMaterial.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_materialList[index].count > 1)
|
||||
{
|
||||
m_materialList[index].count -= 1;
|
||||
Debug.Log("Removed (1) reference to " + m_materialList[index].stencilMaterial.name + ". There are " + m_materialList[index].count + " references left.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Removed last reference to " + m_materialList[index].stencilMaterial.name + " with ID " + m_materialList[index].stencilMaterial.GetInstanceID());
|
||||
Object.DestroyImmediate(m_materialList[index].stencilMaterial);
|
||||
m_materialList.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_ON
|
||||
ListMaterials();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public static void ClearMaterials()
|
||||
{
|
||||
if (m_materialList.Count == 0)
|
||||
{
|
||||
Debug.Log("Material List has already been cleared.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_materialList.Count; i++)
|
||||
{
|
||||
//Material baseMaterial = m_materialList[i].baseMaterial;
|
||||
Material stencilMaterial = m_materialList[i].stencilMaterial;
|
||||
|
||||
Object.DestroyImmediate(stencilMaterial);
|
||||
m_materialList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to get the Stencil ID
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static int GetStencilID(GameObject obj)
|
||||
{
|
||||
// Implementation is almost copied from Unity UI
|
||||
|
||||
var count = 0;
|
||||
|
||||
var transform = obj.transform;
|
||||
var stopAfter = FindRootSortOverrideCanvas(transform);
|
||||
if (transform == stopAfter)
|
||||
return count;
|
||||
|
||||
var t = transform.parent;
|
||||
var components = TMP_ListPool<Mask>.Get();
|
||||
while (t != null)
|
||||
{
|
||||
t.GetComponents<Mask>(components);
|
||||
for (var i = 0; i < components.Count; ++i)
|
||||
{
|
||||
var mask = components[i];
|
||||
if (mask != null && mask.MaskEnabled() && mask.graphic.IsActive())
|
||||
{
|
||||
++count;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (t == stopAfter)
|
||||
break;
|
||||
|
||||
t = t.parent;
|
||||
}
|
||||
TMP_ListPool<Mask>.Release(components);
|
||||
|
||||
return Mathf.Min((1 << count) - 1, 255);
|
||||
}
|
||||
|
||||
|
||||
public static Material GetMaterialForRendering(MaskableGraphic graphic, Material baseMaterial)
|
||||
{
|
||||
if (baseMaterial == null)
|
||||
return null;
|
||||
|
||||
var modifiers = TMP_ListPool<IMaterialModifier>.Get();
|
||||
graphic.GetComponents(modifiers);
|
||||
|
||||
var result = baseMaterial;
|
||||
for (int i = 0; i < modifiers.Count; i++)
|
||||
result = modifiers[i].GetModifiedMaterial(result);
|
||||
|
||||
TMP_ListPool<IMaterialModifier>.Release(modifiers);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Transform FindRootSortOverrideCanvas(Transform start)
|
||||
{
|
||||
// Implementation is copied from Unity UI
|
||||
|
||||
var canvasList = TMP_ListPool<Canvas>.Get();
|
||||
start.GetComponentsInParent(false, canvasList);
|
||||
Canvas canvas = null;
|
||||
|
||||
for (int i = 0; i < canvasList.Count; ++i)
|
||||
{
|
||||
canvas = canvasList[i];
|
||||
|
||||
// We found the canvas we want to use break
|
||||
if (canvas.overrideSorting)
|
||||
break;
|
||||
}
|
||||
TMP_ListPool<Canvas>.Release(canvasList);
|
||||
|
||||
return canvas != null ? canvas.transform : null;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This function returns a material instance using the material properties of a previous material but using the font atlas texture of the new font asset.
|
||||
/// </summary>
|
||||
/// <param name="sourceMaterial">The material containing the source material properties to be copied to the new material.</param>
|
||||
/// <param name="targetMaterial">The font atlas texture that should be assigned to the new material.</param>
|
||||
/// <returns></returns>
|
||||
public static Material GetFallbackMaterial (Material sourceMaterial, Material targetMaterial)
|
||||
{
|
||||
int sourceID = sourceMaterial.GetInstanceID();
|
||||
Texture tex = targetMaterial.GetTexture(ShaderUtilities.ID_MainTex);
|
||||
int texID = tex.GetInstanceID();
|
||||
long key = (long)sourceID << 32 | (long)(uint)texID;
|
||||
|
||||
FallbackMaterial fallback;
|
||||
if (m_fallbackMaterials.TryGetValue(key, out fallback))
|
||||
{
|
||||
//Debug.Log("Material [" + fallback.fallbackMaterial.name + "] already exists.");
|
||||
return fallback.fallbackMaterial;
|
||||
}
|
||||
|
||||
// Create new material from the source material and copy properties if using distance field shaders.
|
||||
Material fallbackMaterial = null;
|
||||
if (sourceMaterial.HasProperty(ShaderUtilities.ID_GradientScale) && targetMaterial.HasProperty(ShaderUtilities.ID_GradientScale))
|
||||
{
|
||||
fallbackMaterial = new Material(sourceMaterial);
|
||||
fallbackMaterial.hideFlags = HideFlags.HideAndDontSave;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
fallbackMaterial.name += " + " + tex.name;
|
||||
//Debug.Log("Creating new fallback material for " + fallbackMaterial.name);
|
||||
#endif
|
||||
|
||||
fallbackMaterial.SetTexture(ShaderUtilities.ID_MainTex, tex);
|
||||
// Retain material properties unique to target material.
|
||||
fallbackMaterial.SetFloat(ShaderUtilities.ID_GradientScale, targetMaterial.GetFloat(ShaderUtilities.ID_GradientScale));
|
||||
fallbackMaterial.SetFloat(ShaderUtilities.ID_TextureWidth, targetMaterial.GetFloat(ShaderUtilities.ID_TextureWidth));
|
||||
fallbackMaterial.SetFloat(ShaderUtilities.ID_TextureHeight, targetMaterial.GetFloat(ShaderUtilities.ID_TextureHeight));
|
||||
fallbackMaterial.SetFloat(ShaderUtilities.ID_WeightNormal, targetMaterial.GetFloat(ShaderUtilities.ID_WeightNormal));
|
||||
fallbackMaterial.SetFloat(ShaderUtilities.ID_WeightBold, targetMaterial.GetFloat(ShaderUtilities.ID_WeightBold));
|
||||
}
|
||||
else
|
||||
{
|
||||
fallbackMaterial = new Material(targetMaterial);
|
||||
}
|
||||
|
||||
fallback = new FallbackMaterial();
|
||||
fallback.baseID = sourceID;
|
||||
fallback.baseMaterial = sourceMaterial;
|
||||
fallback.fallbackID = key;
|
||||
fallback.fallbackMaterial = fallbackMaterial;
|
||||
fallback.count = 0;
|
||||
|
||||
m_fallbackMaterials.Add(key, fallback);
|
||||
m_fallbackMaterialLookup.Add(fallbackMaterial.GetInstanceID(), key);
|
||||
|
||||
#if DEBUG_ON
|
||||
ListFallbackMaterials();
|
||||
#endif
|
||||
|
||||
return fallbackMaterial;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="targetMaterial"></param>
|
||||
public static void AddFallbackMaterialReference(Material targetMaterial)
|
||||
{
|
||||
if (targetMaterial == null) return;
|
||||
|
||||
int sourceID = targetMaterial.GetInstanceID();
|
||||
|
||||
long key;
|
||||
// Lookup key to retrieve
|
||||
if (m_fallbackMaterialLookup.TryGetValue(sourceID, out key))
|
||||
{
|
||||
FallbackMaterial fallback;
|
||||
if (m_fallbackMaterials.TryGetValue(key, out fallback))
|
||||
{
|
||||
//Debug.Log("Adding Fallback material " + fallback.fallbackMaterial.name + " with reference count of " + (fallback.count + 1));
|
||||
fallback.count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="targetMaterial"></param>
|
||||
public static void RemoveFallbackMaterialReference(Material targetMaterial)
|
||||
{
|
||||
if (targetMaterial == null) return;
|
||||
|
||||
int sourceID = targetMaterial.GetInstanceID();
|
||||
|
||||
long key;
|
||||
// Lookup key to retrieve
|
||||
if (m_fallbackMaterialLookup.TryGetValue(sourceID, out key))
|
||||
{
|
||||
FallbackMaterial fallback;
|
||||
if (m_fallbackMaterials.TryGetValue(key, out fallback))
|
||||
{
|
||||
fallback.count -= 1;
|
||||
|
||||
if (fallback.count < 1)
|
||||
m_fallbackCleanupList.Add(fallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static void CleanupFallbackMaterials()
|
||||
{
|
||||
// Return if the list is empty.
|
||||
if (m_fallbackCleanupList.Count == 0) return;
|
||||
|
||||
for (int i = 0; i < m_fallbackCleanupList.Count; i++)
|
||||
{
|
||||
FallbackMaterial fallback = m_fallbackCleanupList[i];
|
||||
|
||||
if (fallback.count < 1)
|
||||
{
|
||||
//Debug.Log("Cleaning up " + fallback.fallbackMaterial.name);
|
||||
|
||||
Material mat = fallback.fallbackMaterial;
|
||||
m_fallbackMaterials.Remove(fallback.fallbackID);
|
||||
m_fallbackMaterialLookup.Remove(mat.GetInstanceID());
|
||||
Object.DestroyImmediate(mat);
|
||||
mat = null;
|
||||
}
|
||||
}
|
||||
|
||||
m_fallbackCleanupList.Clear();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to release the fallback material.
|
||||
/// </summary>
|
||||
/// <param name="fallackMaterial"></param>
|
||||
public static void ReleaseFallbackMaterial(Material fallackMaterial)
|
||||
{
|
||||
if (fallackMaterial == null) return;
|
||||
|
||||
int materialID = fallackMaterial.GetInstanceID();
|
||||
|
||||
long key;
|
||||
if (m_fallbackMaterialLookup.TryGetValue(materialID, out key))
|
||||
{
|
||||
FallbackMaterial fallback;
|
||||
if (m_fallbackMaterials.TryGetValue(key, out fallback))
|
||||
{
|
||||
//Debug.Log("Releasing Fallback material " + fallback.fallbackMaterial.name + " with remaining reference count of " + (fallback.count - 1));
|
||||
|
||||
fallback.count -= 1;
|
||||
|
||||
if (fallback.count < 1)
|
||||
m_fallbackCleanupList.Add(fallback);
|
||||
}
|
||||
}
|
||||
|
||||
isFallbackListDirty = true;
|
||||
|
||||
#if DEBUG_ON
|
||||
ListFallbackMaterials();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
private class FallbackMaterial
|
||||
{
|
||||
public int baseID;
|
||||
public Material baseMaterial;
|
||||
public long fallbackID;
|
||||
public Material fallbackMaterial;
|
||||
public int count;
|
||||
}
|
||||
|
||||
|
||||
private class MaskingMaterial
|
||||
{
|
||||
public Material baseMaterial;
|
||||
public Material stencilMaterial;
|
||||
public int count;
|
||||
public int stencilID;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to copy the properties of a source material preset to another while preserving the unique font asset properties of the destination material.
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="destination"></param>
|
||||
public static void CopyMaterialPresetProperties(Material source, Material destination)
|
||||
{
|
||||
if (!source.HasProperty(ShaderUtilities.ID_GradientScale) || !destination.HasProperty(ShaderUtilities.ID_GradientScale))
|
||||
return;
|
||||
|
||||
// Save unique material properties
|
||||
Texture dst_texture = destination.GetTexture(ShaderUtilities.ID_MainTex);
|
||||
float dst_gradientScale = destination.GetFloat(ShaderUtilities.ID_GradientScale);
|
||||
float dst_texWidth = destination.GetFloat(ShaderUtilities.ID_TextureWidth);
|
||||
float dst_texHeight = destination.GetFloat(ShaderUtilities.ID_TextureHeight);
|
||||
float dst_weightNormal = destination.GetFloat(ShaderUtilities.ID_WeightNormal);
|
||||
float dst_weightBold = destination.GetFloat(ShaderUtilities.ID_WeightBold);
|
||||
|
||||
// Copy all material properties
|
||||
destination.CopyPropertiesFromMaterial(source);
|
||||
|
||||
// Copy shader keywords
|
||||
destination.shaderKeywords = source.shaderKeywords;
|
||||
|
||||
// Restore unique material properties
|
||||
destination.SetTexture(ShaderUtilities.ID_MainTex, dst_texture);
|
||||
destination.SetFloat(ShaderUtilities.ID_GradientScale, dst_gradientScale);
|
||||
destination.SetFloat(ShaderUtilities.ID_TextureWidth, dst_texWidth);
|
||||
destination.SetFloat(ShaderUtilities.ID_TextureHeight, dst_texHeight);
|
||||
destination.SetFloat(ShaderUtilities.ID_WeightNormal, dst_weightNormal);
|
||||
destination.SetFloat(ShaderUtilities.ID_WeightBold, dst_weightBold);
|
||||
}
|
||||
|
||||
|
||||
#if DEBUG_ON
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static void ListMaterials()
|
||||
{
|
||||
|
||||
if (m_materialList.Count() == 0)
|
||||
{
|
||||
Debug.Log("Material List is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
//Debug.Log("List contains " + m_materialList.Count() + " items.");
|
||||
|
||||
for (int i = 0; i < m_materialList.Count(); i++)
|
||||
{
|
||||
Material baseMaterial = m_materialList[i].baseMaterial;
|
||||
Material stencilMaterial = m_materialList[i].stencilMaterial;
|
||||
|
||||
Debug.Log("Item #" + (i + 1) + " - Base Material is [" + baseMaterial.name + "] with ID " + baseMaterial.GetInstanceID() + " is associated with [" + (stencilMaterial != null ? stencilMaterial.name : "Null") + "] Stencil ID " + m_materialList[i].stencilID + " with ID " + (stencilMaterial != null ? stencilMaterial.GetInstanceID() : 0) + " and is referenced " + m_materialList[i].count + " time(s).");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static void ListFallbackMaterials()
|
||||
{
|
||||
|
||||
if (m_fallbackMaterialList.Count() == 0)
|
||||
{
|
||||
Debug.Log("Material List is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log("List contains " + m_fallbackMaterialList.Count() + " items.");
|
||||
|
||||
for (int i = 0; i < m_fallbackMaterialList.Count(); i++)
|
||||
{
|
||||
Material baseMaterial = m_fallbackMaterialList[i].baseMaterial;
|
||||
Material fallbackMaterial = m_fallbackMaterialList[i].fallbackMaterial;
|
||||
|
||||
Debug.Log("Item #" + (i + 1) + " - Base Material is [" + baseMaterial.name + "] with ID " + baseMaterial.GetInstanceID() + " is associated with [" + (fallbackMaterial != null ? fallbackMaterial.name : "Null") + "] with ID " + (fallbackMaterial != null ? fallbackMaterial.GetInstanceID() : 0) + " and is referenced " + m_fallbackMaterialList[i].count + " time(s).");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6d9df2bc198c417db00037803568139c
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
664
Assets/TextMesh Pro/Scripts/Runtime/TMP_MeshInfo.cs
Normal file
664
Assets/TextMesh Pro/Scripts/Runtime/TMP_MeshInfo.cs
Normal file
|
@ -0,0 +1,664 @@
|
|||
using UnityEngine;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
public enum VertexSortingOrder { Normal, Reverse };
|
||||
|
||||
/// <summary>
|
||||
/// Structure which contains the vertex attributes (geometry) of the text object.
|
||||
/// </summary>
|
||||
public struct TMP_MeshInfo
|
||||
{
|
||||
private static readonly Color32 s_DefaultColor = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
|
||||
private static readonly Vector3 s_DefaultNormal = new Vector3(0.0f, 0.0f, -1f);
|
||||
private static readonly Vector4 s_DefaultTangent = new Vector4(-1f, 0.0f, 0.0f, 1f);
|
||||
|
||||
public Mesh mesh;
|
||||
public int vertexCount;
|
||||
|
||||
public Vector3[] vertices;
|
||||
public Vector3[] normals;
|
||||
public Vector4[] tangents;
|
||||
|
||||
public Vector2[] uvs0;
|
||||
public Vector2[] uvs2;
|
||||
//public Vector2[] uvs4;
|
||||
public Color32[] colors32;
|
||||
public int[] triangles;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to pre-allocate vertex attributes for a mesh of size X.
|
||||
/// </summary>
|
||||
/// <param name="mesh"></param>
|
||||
/// <param name="size"></param>
|
||||
public TMP_MeshInfo(Mesh mesh, int size)
|
||||
{
|
||||
// Reference to the TMP Text Component.
|
||||
//this.textComponent = null;
|
||||
|
||||
// Clear existing mesh data
|
||||
if (mesh == null)
|
||||
mesh = new Mesh();
|
||||
else
|
||||
mesh.Clear();
|
||||
|
||||
this.mesh = mesh;
|
||||
|
||||
// Limit the mesh to less than 65535 vertices which is the limit for Unity's Mesh.
|
||||
size = Mathf.Min(size, 16383);
|
||||
|
||||
int sizeX4 = size * 4;
|
||||
int sizeX6 = size * 6;
|
||||
|
||||
this.vertexCount = 0;
|
||||
|
||||
this.vertices = new Vector3[sizeX4];
|
||||
this.uvs0 = new Vector2[sizeX4];
|
||||
this.uvs2 = new Vector2[sizeX4];
|
||||
//this.uvs4 = new Vector2[sizeX4]; // SDF scale data
|
||||
this.colors32 = new Color32[sizeX4];
|
||||
|
||||
this.normals = new Vector3[sizeX4];
|
||||
this.tangents = new Vector4[sizeX4];
|
||||
|
||||
this.triangles = new int[sizeX6];
|
||||
|
||||
int index_X6 = 0;
|
||||
int index_X4 = 0;
|
||||
while (index_X4 / 4 < size)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
this.vertices[index_X4 + i] = Vector3.zero;
|
||||
this.uvs0[index_X4 + i] = Vector2.zero;
|
||||
this.uvs2[index_X4 + i] = Vector2.zero;
|
||||
//this.uvs4[index_X4 + i] = Vector2.zero;
|
||||
this.colors32[index_X4 + i] = s_DefaultColor;
|
||||
this.normals[index_X4 + i] = s_DefaultNormal;
|
||||
this.tangents[index_X4 + i] = s_DefaultTangent;
|
||||
}
|
||||
|
||||
this.triangles[index_X6 + 0] = index_X4 + 0;
|
||||
this.triangles[index_X6 + 1] = index_X4 + 1;
|
||||
this.triangles[index_X6 + 2] = index_X4 + 2;
|
||||
this.triangles[index_X6 + 3] = index_X4 + 2;
|
||||
this.triangles[index_X6 + 4] = index_X4 + 3;
|
||||
this.triangles[index_X6 + 5] = index_X4 + 0;
|
||||
|
||||
index_X4 += 4;
|
||||
index_X6 += 6;
|
||||
}
|
||||
|
||||
// Pre-assign base vertex attributes.
|
||||
this.mesh.vertices = this.vertices;
|
||||
this.mesh.normals = this.normals;
|
||||
this.mesh.tangents = this.tangents;
|
||||
this.mesh.triangles = this.triangles;
|
||||
this.mesh.bounds = new Bounds(Vector3.zero, new Vector3(3840, 2160, 0));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to pre-allocate vertex attributes for a mesh of size X.
|
||||
/// </summary>
|
||||
/// <param name="mesh"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="isVolumetric"></param>
|
||||
public TMP_MeshInfo(Mesh mesh, int size, bool isVolumetric)
|
||||
{
|
||||
// Reference to the TMP Text Component.
|
||||
//this.textComponent = null;
|
||||
|
||||
// Clear existing mesh data
|
||||
if (mesh == null)
|
||||
mesh = new Mesh();
|
||||
else
|
||||
mesh.Clear();
|
||||
|
||||
this.mesh = mesh;
|
||||
|
||||
int s0 = !isVolumetric ? 4 : 8;
|
||||
int s1 = !isVolumetric ? 6 : 36;
|
||||
|
||||
// Limit the mesh to less than 65535 vertices which is the limit for Unity's Mesh.
|
||||
size = Mathf.Min(size, 65532 / s0);
|
||||
|
||||
int size_x_s0 = size * s0;
|
||||
int size_x_s1 = size * s1;
|
||||
|
||||
this.vertexCount = 0;
|
||||
|
||||
this.vertices = new Vector3[size_x_s0];
|
||||
this.uvs0 = new Vector2[size_x_s0];
|
||||
this.uvs2 = new Vector2[size_x_s0];
|
||||
//this.uvs4 = new Vector2[sizeX8]; // SDF scale data
|
||||
this.colors32 = new Color32[size_x_s0];
|
||||
|
||||
this.normals = new Vector3[size_x_s0];
|
||||
this.tangents = new Vector4[size_x_s0];
|
||||
|
||||
this.triangles = new int[size_x_s1];
|
||||
|
||||
int index_x_s0 = 0;
|
||||
int index_x_s1 = 0;
|
||||
while (index_x_s0 / s0 < size)
|
||||
{
|
||||
for (int i = 0; i < s0; i++)
|
||||
{
|
||||
this.vertices[index_x_s0 + i] = Vector3.zero;
|
||||
this.uvs0[index_x_s0 + i] = Vector2.zero;
|
||||
this.uvs2[index_x_s0 + i] = Vector2.zero;
|
||||
//this.uvs4[index_X4 + i] = Vector2.zero;
|
||||
this.colors32[index_x_s0 + i] = s_DefaultColor;
|
||||
this.normals[index_x_s0 + i] = s_DefaultNormal;
|
||||
this.tangents[index_x_s0 + i] = s_DefaultTangent;
|
||||
}
|
||||
|
||||
// Front Face
|
||||
this.triangles[index_x_s1 + 0] = index_x_s0 + 0;
|
||||
this.triangles[index_x_s1 + 1] = index_x_s0 + 1;
|
||||
this.triangles[index_x_s1 + 2] = index_x_s0 + 2;
|
||||
this.triangles[index_x_s1 + 3] = index_x_s0 + 2;
|
||||
this.triangles[index_x_s1 + 4] = index_x_s0 + 3;
|
||||
this.triangles[index_x_s1 + 5] = index_x_s0 + 0;
|
||||
|
||||
if (isVolumetric)
|
||||
{
|
||||
// Left Face
|
||||
this.triangles[index_x_s1 + 6] = index_x_s0 + 4;
|
||||
this.triangles[index_x_s1 + 7] = index_x_s0 + 5;
|
||||
this.triangles[index_x_s1 + 8] = index_x_s0 + 1;
|
||||
this.triangles[index_x_s1 + 9] = index_x_s0 + 1;
|
||||
this.triangles[index_x_s1 + 10] = index_x_s0 + 0;
|
||||
this.triangles[index_x_s1 + 11] = index_x_s0 + 4;
|
||||
|
||||
// Right Face
|
||||
this.triangles[index_x_s1 + 12] = index_x_s0 + 3;
|
||||
this.triangles[index_x_s1 + 13] = index_x_s0 + 2;
|
||||
this.triangles[index_x_s1 + 14] = index_x_s0 + 6;
|
||||
this.triangles[index_x_s1 + 15] = index_x_s0 + 6;
|
||||
this.triangles[index_x_s1 + 16] = index_x_s0 + 7;
|
||||
this.triangles[index_x_s1 + 17] = index_x_s0 + 3;
|
||||
|
||||
// Top Face
|
||||
this.triangles[index_x_s1 + 18] = index_x_s0 + 1;
|
||||
this.triangles[index_x_s1 + 19] = index_x_s0 + 5;
|
||||
this.triangles[index_x_s1 + 20] = index_x_s0 + 6;
|
||||
this.triangles[index_x_s1 + 21] = index_x_s0 + 6;
|
||||
this.triangles[index_x_s1 + 22] = index_x_s0 + 2;
|
||||
this.triangles[index_x_s1 + 23] = index_x_s0 + 1;
|
||||
|
||||
// Bottom Face
|
||||
this.triangles[index_x_s1 + 24] = index_x_s0 + 4;
|
||||
this.triangles[index_x_s1 + 25] = index_x_s0 + 0;
|
||||
this.triangles[index_x_s1 + 26] = index_x_s0 + 3;
|
||||
this.triangles[index_x_s1 + 27] = index_x_s0 + 3;
|
||||
this.triangles[index_x_s1 + 28] = index_x_s0 + 7;
|
||||
this.triangles[index_x_s1 + 29] = index_x_s0 + 4;
|
||||
|
||||
// Back Face
|
||||
this.triangles[index_x_s1 + 30] = index_x_s0 + 7;
|
||||
this.triangles[index_x_s1 + 31] = index_x_s0 + 6;
|
||||
this.triangles[index_x_s1 + 32] = index_x_s0 + 5;
|
||||
this.triangles[index_x_s1 + 33] = index_x_s0 + 5;
|
||||
this.triangles[index_x_s1 + 34] = index_x_s0 + 4;
|
||||
this.triangles[index_x_s1 + 35] = index_x_s0 + 7;
|
||||
}
|
||||
|
||||
index_x_s0 += s0;
|
||||
index_x_s1 += s1;
|
||||
}
|
||||
|
||||
// Pre-assign base vertex attributes.
|
||||
this.mesh.vertices = this.vertices;
|
||||
this.mesh.normals = this.normals;
|
||||
this.mesh.tangents = this.tangents;
|
||||
this.mesh.triangles = this.triangles;
|
||||
this.mesh.bounds = new Bounds(Vector3.zero, new Vector3(3840, 2160, 64));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to resized the content of MeshData and re-assign normals, tangents and triangles.
|
||||
/// </summary>
|
||||
/// <param name="meshData"></param>
|
||||
/// <param name="size"></param>
|
||||
public void ResizeMeshInfo(int size)
|
||||
{
|
||||
// Limit the mesh to less than 65535 vertices which is the limit for Unity's Mesh.
|
||||
size = Mathf.Min(size, 16383);
|
||||
|
||||
int size_X4 = size * 4;
|
||||
int size_X6 = size * 6;
|
||||
|
||||
int previousSize = this.vertices.Length / 4;
|
||||
|
||||
Array.Resize(ref this.vertices, size_X4);
|
||||
Array.Resize(ref this.normals, size_X4);
|
||||
Array.Resize(ref this.tangents, size_X4);
|
||||
|
||||
Array.Resize(ref this.uvs0, size_X4);
|
||||
Array.Resize(ref this.uvs2, size_X4);
|
||||
//Array.Resize(ref this.uvs4, size_X4);
|
||||
|
||||
Array.Resize(ref this.colors32, size_X4);
|
||||
|
||||
Array.Resize(ref this.triangles, size_X6);
|
||||
|
||||
|
||||
// Re-assign Normals, Tangents and Triangles
|
||||
if (size <= previousSize)
|
||||
{
|
||||
this.mesh.triangles = this.triangles;
|
||||
this.mesh.vertices = this.vertices;
|
||||
this.mesh.normals = this.normals;
|
||||
this.mesh.tangents = this.tangents;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = previousSize; i < size; i++)
|
||||
{
|
||||
int index_X4 = i * 4;
|
||||
int index_X6 = i * 6;
|
||||
|
||||
this.normals[0 + index_X4] = s_DefaultNormal;
|
||||
this.normals[1 + index_X4] = s_DefaultNormal;
|
||||
this.normals[2 + index_X4] = s_DefaultNormal;
|
||||
this.normals[3 + index_X4] = s_DefaultNormal;
|
||||
|
||||
this.tangents[0 + index_X4] = s_DefaultTangent;
|
||||
this.tangents[1 + index_X4] = s_DefaultTangent;
|
||||
this.tangents[2 + index_X4] = s_DefaultTangent;
|
||||
this.tangents[3 + index_X4] = s_DefaultTangent;
|
||||
|
||||
// Setup Triangles
|
||||
this.triangles[0 + index_X6] = 0 + index_X4;
|
||||
this.triangles[1 + index_X6] = 1 + index_X4;
|
||||
this.triangles[2 + index_X6] = 2 + index_X4;
|
||||
this.triangles[3 + index_X6] = 2 + index_X4;
|
||||
this.triangles[4 + index_X6] = 3 + index_X4;
|
||||
this.triangles[5 + index_X6] = 0 + index_X4;
|
||||
}
|
||||
|
||||
this.mesh.vertices = this.vertices;
|
||||
this.mesh.normals = this.normals;
|
||||
this.mesh.tangents = this.tangents;
|
||||
this.mesh.triangles = this.triangles;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to resized the content of MeshData and re-assign normals, tangents and triangles.
|
||||
/// </summary>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="isVolumetric"></param>
|
||||
public void ResizeMeshInfo(int size, bool isVolumetric)
|
||||
{
|
||||
int s0 = !isVolumetric ? 4 : 8;
|
||||
int s1 = !isVolumetric ? 6 : 36;
|
||||
|
||||
// Limit the mesh to less than 65535 vertices which is the limit for Unity's Mesh.
|
||||
size = Mathf.Min(size, 65532 / s0);
|
||||
|
||||
int size_X4 = size * s0;
|
||||
int size_X6 = size * s1;
|
||||
|
||||
int previousSize = this.vertices.Length / s0;
|
||||
|
||||
Array.Resize(ref this.vertices, size_X4);
|
||||
Array.Resize(ref this.normals, size_X4);
|
||||
Array.Resize(ref this.tangents, size_X4);
|
||||
|
||||
Array.Resize(ref this.uvs0, size_X4);
|
||||
Array.Resize(ref this.uvs2, size_X4);
|
||||
//Array.Resize(ref this.uvs4, size_X4);
|
||||
|
||||
Array.Resize(ref this.colors32, size_X4);
|
||||
|
||||
Array.Resize(ref this.triangles, size_X6);
|
||||
|
||||
|
||||
// Re-assign Normals, Tangents and Triangles
|
||||
if (size <= previousSize)
|
||||
{
|
||||
this.mesh.triangles = this.triangles;
|
||||
this.mesh.vertices = this.vertices;
|
||||
this.mesh.normals = this.normals;
|
||||
this.mesh.tangents = this.tangents;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = previousSize; i < size; i++)
|
||||
{
|
||||
int index_X4 = i * s0;
|
||||
int index_X6 = i * s1;
|
||||
|
||||
this.normals[0 + index_X4] = s_DefaultNormal;
|
||||
this.normals[1 + index_X4] = s_DefaultNormal;
|
||||
this.normals[2 + index_X4] = s_DefaultNormal;
|
||||
this.normals[3 + index_X4] = s_DefaultNormal;
|
||||
|
||||
this.tangents[0 + index_X4] = s_DefaultTangent;
|
||||
this.tangents[1 + index_X4] = s_DefaultTangent;
|
||||
this.tangents[2 + index_X4] = s_DefaultTangent;
|
||||
this.tangents[3 + index_X4] = s_DefaultTangent;
|
||||
|
||||
if (isVolumetric)
|
||||
{
|
||||
this.normals[4 + index_X4] = s_DefaultNormal;
|
||||
this.normals[5 + index_X4] = s_DefaultNormal;
|
||||
this.normals[6 + index_X4] = s_DefaultNormal;
|
||||
this.normals[7 + index_X4] = s_DefaultNormal;
|
||||
|
||||
this.tangents[4 + index_X4] = s_DefaultTangent;
|
||||
this.tangents[5 + index_X4] = s_DefaultTangent;
|
||||
this.tangents[6 + index_X4] = s_DefaultTangent;
|
||||
this.tangents[7 + index_X4] = s_DefaultTangent;
|
||||
}
|
||||
|
||||
// Setup Triangles
|
||||
this.triangles[0 + index_X6] = 0 + index_X4;
|
||||
this.triangles[1 + index_X6] = 1 + index_X4;
|
||||
this.triangles[2 + index_X6] = 2 + index_X4;
|
||||
this.triangles[3 + index_X6] = 2 + index_X4;
|
||||
this.triangles[4 + index_X6] = 3 + index_X4;
|
||||
this.triangles[5 + index_X6] = 0 + index_X4;
|
||||
|
||||
if (isVolumetric)
|
||||
{
|
||||
// Left Face
|
||||
this.triangles[index_X6 + 6] = index_X4 + 4;
|
||||
this.triangles[index_X6 + 7] = index_X4 + 5;
|
||||
this.triangles[index_X6 + 8] = index_X4 + 1;
|
||||
this.triangles[index_X6 + 9] = index_X4 + 1;
|
||||
this.triangles[index_X6 + 10] = index_X4 + 0;
|
||||
this.triangles[index_X6 + 11] = index_X4 + 4;
|
||||
|
||||
// Right Face
|
||||
this.triangles[index_X6 + 12] = index_X4 + 3;
|
||||
this.triangles[index_X6 + 13] = index_X4 + 2;
|
||||
this.triangles[index_X6 + 14] = index_X4 + 6;
|
||||
this.triangles[index_X6 + 15] = index_X4 + 6;
|
||||
this.triangles[index_X6 + 16] = index_X4 + 7;
|
||||
this.triangles[index_X6 + 17] = index_X4 + 3;
|
||||
|
||||
// Top Face
|
||||
this.triangles[index_X6 + 18] = index_X4 + 1;
|
||||
this.triangles[index_X6 + 19] = index_X4 + 5;
|
||||
this.triangles[index_X6 + 20] = index_X4 + 6;
|
||||
this.triangles[index_X6 + 21] = index_X4 + 6;
|
||||
this.triangles[index_X6 + 22] = index_X4 + 2;
|
||||
this.triangles[index_X6 + 23] = index_X4 + 1;
|
||||
|
||||
// Bottom Face
|
||||
this.triangles[index_X6 + 24] = index_X4 + 4;
|
||||
this.triangles[index_X6 + 25] = index_X4 + 0;
|
||||
this.triangles[index_X6 + 26] = index_X4 + 3;
|
||||
this.triangles[index_X6 + 27] = index_X4 + 3;
|
||||
this.triangles[index_X6 + 28] = index_X4 + 7;
|
||||
this.triangles[index_X6 + 29] = index_X4 + 4;
|
||||
|
||||
// Back Face
|
||||
this.triangles[index_X6 + 30] = index_X4 + 7;
|
||||
this.triangles[index_X6 + 31] = index_X4 + 6;
|
||||
this.triangles[index_X6 + 32] = index_X4 + 5;
|
||||
this.triangles[index_X6 + 33] = index_X4 + 5;
|
||||
this.triangles[index_X6 + 34] = index_X4 + 4;
|
||||
this.triangles[index_X6 + 35] = index_X4 + 7;
|
||||
}
|
||||
}
|
||||
|
||||
this.mesh.vertices = this.vertices;
|
||||
this.mesh.normals = this.normals;
|
||||
this.mesh.tangents = this.tangents;
|
||||
this.mesh.triangles = this.triangles;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to clear the vertices while preserving the Triangles, Normals and Tangents.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
if (this.vertices == null) return;
|
||||
|
||||
Array.Clear(this.vertices, 0, this.vertices.Length);
|
||||
this.vertexCount = 0;
|
||||
|
||||
if (this.mesh != null)
|
||||
this.mesh.vertices = this.vertices;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to clear the vertices while preserving the Triangles, Normals and Tangents.
|
||||
/// </summary>
|
||||
public void Clear(bool uploadChanges)
|
||||
{
|
||||
if (this.vertices == null) return;
|
||||
|
||||
Array.Clear(this.vertices, 0, this.vertices.Length);
|
||||
this.vertexCount = 0;
|
||||
|
||||
if (uploadChanges && this.mesh != null)
|
||||
this.mesh.vertices = this.vertices;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to clear the vertices while preserving the Triangles, Normals and Tangents.
|
||||
/// </summary>
|
||||
public void ClearUnusedVertices()
|
||||
{
|
||||
int length = vertices.Length - vertexCount;
|
||||
|
||||
if (length > 0)
|
||||
Array.Clear(vertices, vertexCount, length);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function used to mark unused vertices as degenerate.
|
||||
/// </summary>
|
||||
/// <param name="startIndex"></param>
|
||||
public void ClearUnusedVertices(int startIndex)
|
||||
{
|
||||
int length = this.vertices.Length - startIndex;
|
||||
|
||||
if (length > 0)
|
||||
Array.Clear(this.vertices, startIndex, length);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function used to mark unused vertices as degenerate an upload resulting data to the mesh.
|
||||
/// </summary>
|
||||
/// <param name="startIndex"></param>
|
||||
public void ClearUnusedVertices(int startIndex, bool updateMesh)
|
||||
{
|
||||
int length = this.vertices.Length - startIndex;
|
||||
|
||||
if (length > 0)
|
||||
Array.Clear(this.vertices, startIndex, length);
|
||||
|
||||
if (updateMesh && mesh != null)
|
||||
this.mesh.vertices = this.vertices;
|
||||
}
|
||||
|
||||
|
||||
public void SortGeometry (VertexSortingOrder order)
|
||||
{
|
||||
switch (order)
|
||||
{
|
||||
case VertexSortingOrder.Normal:
|
||||
// Do nothing
|
||||
break;
|
||||
case VertexSortingOrder.Reverse:
|
||||
int size = vertexCount / 4;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
int src = i * 4;
|
||||
int dst = (size - i - 1) * 4;
|
||||
|
||||
if (src < dst)
|
||||
SwapVertexData(src, dst);
|
||||
|
||||
}
|
||||
break;
|
||||
//case VertexSortingOrder.Depth:
|
||||
// break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Function to rearrange the quads of the text object to change their rendering order.
|
||||
/// </summary>
|
||||
/// <param name="sortingOrder"></param>
|
||||
public void SortGeometry(IList<int> sortingOrder)
|
||||
{
|
||||
// Make sure the sorting order array is not larger than the vertices array.
|
||||
int indexCount = sortingOrder.Count;
|
||||
|
||||
if (indexCount * 4 > vertices.Length) return;
|
||||
|
||||
int src_index;
|
||||
|
||||
for (int dst_index = 0; dst_index < indexCount; dst_index++)
|
||||
{
|
||||
src_index = sortingOrder[dst_index];
|
||||
|
||||
while (src_index < dst_index)
|
||||
{
|
||||
src_index = sortingOrder[src_index];
|
||||
}
|
||||
|
||||
// Swap items
|
||||
if (src_index != dst_index)
|
||||
SwapVertexData(src_index * 4, dst_index * 4);
|
||||
|
||||
//Debug.Log("Swap element [" + dst_index + "] with [" + src_index + "]. Vertex[" + dst_index + "] is " + vertices[dst_index * 4].z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Method to swap the vertex attributes between src and dst quads.
|
||||
/// </summary>
|
||||
/// <param name="src">Index of the first vertex attribute of the source character / quad.</param>
|
||||
/// <param name="dst">Index of the first vertex attribute of the destination character / quad.</param>
|
||||
public void SwapVertexData(int src, int dst)
|
||||
{
|
||||
int src_Index = src; // * 4;
|
||||
int dst_Index = dst; // * 4;
|
||||
|
||||
// Swap vertices
|
||||
Vector3 vertex;
|
||||
vertex = vertices[dst_Index + 0];
|
||||
vertices[dst_Index + 0] = vertices[src_Index + 0];
|
||||
vertices[src_Index + 0] = vertex;
|
||||
|
||||
vertex = vertices[dst_Index + 1];
|
||||
vertices[dst_Index + 1] = vertices[src_Index + 1];
|
||||
vertices[src_Index + 1] = vertex;
|
||||
|
||||
vertex = vertices[dst_Index + 2];
|
||||
vertices[dst_Index + 2] = vertices[src_Index + 2];
|
||||
vertices[src_Index + 2] = vertex;
|
||||
|
||||
vertex = vertices[dst_Index + 3];
|
||||
vertices[dst_Index + 3] = vertices[src_Index + 3];
|
||||
vertices[src_Index + 3] = vertex;
|
||||
|
||||
|
||||
//Swap UVs0
|
||||
Vector2 uvs;
|
||||
uvs = uvs0[dst_Index + 0];
|
||||
uvs0[dst_Index + 0] = uvs0[src_Index + 0];
|
||||
uvs0[src_Index + 0] = uvs;
|
||||
|
||||
uvs = uvs0[dst_Index + 1];
|
||||
uvs0[dst_Index + 1] = uvs0[src_Index + 1];
|
||||
uvs0[src_Index + 1] = uvs;
|
||||
|
||||
uvs = uvs0[dst_Index + 2];
|
||||
uvs0[dst_Index + 2] = uvs0[src_Index + 2];
|
||||
uvs0[src_Index + 2] = uvs;
|
||||
|
||||
uvs = uvs0[dst_Index + 3];
|
||||
uvs0[dst_Index + 3] = uvs0[src_Index + 3];
|
||||
uvs0[src_Index + 3] = uvs;
|
||||
|
||||
// Swap UVs2
|
||||
uvs = uvs2[dst_Index + 0];
|
||||
uvs2[dst_Index + 0] = uvs2[src_Index + 0];
|
||||
uvs2[src_Index + 0] = uvs;
|
||||
|
||||
uvs = uvs2[dst_Index + 1];
|
||||
uvs2[dst_Index + 1] = uvs2[src_Index + 1];
|
||||
uvs2[src_Index + 1] = uvs;
|
||||
|
||||
uvs = uvs2[dst_Index + 2];
|
||||
uvs2[dst_Index + 2] = uvs2[src_Index + 2];
|
||||
uvs2[src_Index + 2] = uvs;
|
||||
|
||||
uvs = uvs2[dst_Index + 3];
|
||||
uvs2[dst_Index + 3] = uvs2[src_Index + 3];
|
||||
uvs2[src_Index + 3] = uvs;
|
||||
|
||||
// Vertex Colors
|
||||
Color32 color;
|
||||
color = colors32[dst_Index + 0];
|
||||
colors32[dst_Index + 0] = colors32[src_Index + 0];
|
||||
colors32[src_Index + 0] = color;
|
||||
|
||||
color = colors32[dst_Index + 1];
|
||||
colors32[dst_Index + 1] = colors32[src_Index + 1];
|
||||
colors32[src_Index + 1] = color;
|
||||
|
||||
color = colors32[dst_Index + 2];
|
||||
colors32[dst_Index + 2] = colors32[src_Index + 2];
|
||||
colors32[src_Index + 2] = color;
|
||||
|
||||
color = colors32[dst_Index + 3];
|
||||
colors32[dst_Index + 3] = colors32[src_Index + 3];
|
||||
colors32[src_Index + 3] = color;
|
||||
}
|
||||
|
||||
|
||||
//int Partition (int start, int end)
|
||||
//{
|
||||
// float pivot = vertices[end].z;
|
||||
|
||||
// int partitionIndex = start;
|
||||
// for (int i = start; i < end; i++)
|
||||
// {
|
||||
// if (vertices[i].z <= pivot)
|
||||
// {
|
||||
// Swap(vertices[i], vertices[partitionIndex]);
|
||||
// partitionIndex += 1;
|
||||
// }
|
||||
// }
|
||||
// Swap(vertices[partitionIndex], vertices[end]);
|
||||
// return partitionIndex;
|
||||
//}
|
||||
|
||||
|
||||
//void Swap(Vector3 a, Vector3 b)
|
||||
//{
|
||||
// Vector3 temp = a;
|
||||
// a = b;
|
||||
// b = a;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_MeshInfo.cs.meta
Normal file
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_MeshInfo.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e21bec35f48a44298911b25ead550ce3
|
||||
timeCreated: 1462398762
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
51
Assets/TextMesh Pro/Scripts/Runtime/TMP_ObjectPool.cs
Normal file
51
Assets/TextMesh Pro/Scripts/Runtime/TMP_ObjectPool.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
|
||||
internal class TMP_ObjectPool<T> where T : new()
|
||||
{
|
||||
private readonly Stack<T> m_Stack = new Stack<T>();
|
||||
private readonly UnityAction<T> m_ActionOnGet;
|
||||
private readonly UnityAction<T> m_ActionOnRelease;
|
||||
|
||||
public int countAll { get; private set; }
|
||||
public int countActive { get { return countAll - countInactive; } }
|
||||
public int countInactive { get { return m_Stack.Count; } }
|
||||
|
||||
public TMP_ObjectPool(UnityAction<T> actionOnGet, UnityAction<T> actionOnRelease)
|
||||
{
|
||||
m_ActionOnGet = actionOnGet;
|
||||
m_ActionOnRelease = actionOnRelease;
|
||||
}
|
||||
|
||||
public T Get()
|
||||
{
|
||||
T element;
|
||||
if (m_Stack.Count == 0)
|
||||
{
|
||||
element = new T();
|
||||
countAll++;
|
||||
}
|
||||
else
|
||||
{
|
||||
element = m_Stack.Pop();
|
||||
}
|
||||
if (m_ActionOnGet != null)
|
||||
m_ActionOnGet(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
public void Release(T element)
|
||||
{
|
||||
if (m_Stack.Count > 0 && ReferenceEquals(m_Stack.Peek(), element))
|
||||
Debug.LogError("Internal error. Trying to destroy object that is already released to pool.");
|
||||
if (m_ActionOnRelease != null)
|
||||
m_ActionOnRelease(element);
|
||||
m_Stack.Push(element);
|
||||
}
|
||||
}
|
||||
}
|
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_ObjectPool.cs.meta
Normal file
12
Assets/TextMesh Pro/Scripts/Runtime/TMP_ObjectPool.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e69259f6ff914146ad610be5491eb44a
|
||||
timeCreated: 1458521389
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,31 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using System;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
|
||||
public class TMP_ScrollbarEventHandler : MonoBehaviour, IPointerClickHandler, ISelectHandler, IDeselectHandler
|
||||
{
|
||||
public bool isSelected;
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("Scrollbar click...");
|
||||
}
|
||||
|
||||
public void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
Debug.Log("Scrollbar selected");
|
||||
isSelected = true;
|
||||
}
|
||||
|
||||
public void OnDeselect(BaseEventData eventData)
|
||||
{
|
||||
Debug.Log("Scrollbar De-Selected");
|
||||
isSelected = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 34e150112c1c42ac83170b52d898e322
|
||||
timeCreated: 1484171293
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
23
Assets/TextMesh Pro/Scripts/Runtime/TMP_SelectionCaret.cs
Normal file
23
Assets/TextMesh Pro/Scripts/Runtime/TMP_SelectionCaret.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace TMPro
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple component that can be added to a newly created object where inheriting from MaskableGraphic is needed.
|
||||
/// </summary>
|
||||
public class TMP_SelectionCaret : MaskableGraphic
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Override to Cull function of MaskableGraphic to prevent Culling.
|
||||
/// </summary>
|
||||
/// <param name="clipRect"></param>
|
||||
/// <param name="validRect"></param>
|
||||
public override void Cull(Rect clipRect, bool validRect)
|
||||
{
|
||||
//base.Cull(clipRect, validRect);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ca819640f53b48919bf7774744f7f15e
|
||||
timeCreated: 1477609203
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue