- 调整项目结构以适应打包需求

- 添加控制台便于在游戏运行过程中调试各项功能
- 添加 LevelRarity 表,增加了随关卡数动态调整的商品道具品质刷新概率
This commit is contained in:
SepComet 2026-02-18 22:53:33 +08:00
parent e151619c69
commit b4bc8b0445
202 changed files with 5160 additions and 3393 deletions

3
.gitignore vendored
View File

@ -81,3 +81,6 @@ crashlytics-build.properties
/UI参考
/AGENTS.md
/bin
~$*.xlsx

View File

@ -104,7 +104,7 @@ namespace UnityGameFramework.Editor
}
EditorGUI.EndDisabledGroup();
int frameRate = EditorGUILayout.IntSlider("Frame Rate", m_FrameRate.intValue, 1, 120);
int frameRate = EditorGUILayout.IntSlider("Frame Rate", m_FrameRate.intValue, 1, 240);
if (frameRate != m_FrameRate.intValue)
{
if (EditorApplication.isPlaying)

View File

@ -66,7 +66,7 @@ namespace UnityGameFramework.Runtime
private string GetResolutionString(Resolution resolution)
{
return Utility.Text.Format("{0} x {1} @ {2}Hz", resolution.width, resolution.height, resolution.refreshRate);
return Utility.Text.Format("{0} x {1} @ {2}Hz", resolution.width, resolution.height, resolution.refreshRateRatio);
}
private string GetCutoutsString(Rect[] cutouts)

View File

@ -2,14 +2,14 @@
<UnityGameFramework>
<ResourceBuilder>
<Settings>
<InternalResourceVersion>0</InternalResourceVersion>
<Platforms>1</Platforms>
<InternalResourceVersion>1</InternalResourceVersion>
<Platforms>33</Platforms>
<AssetBundleCompression>1</AssetBundleCompression>
<CompressionHelperTypeName>UnityGameFramework.Runtime.DefaultCompressionHelper</CompressionHelperTypeName>
<AdditionalCompressionSelected>True</AdditionalCompressionSelected>
<ForceRebuildAssetBundleSelected>False</ForceRebuildAssetBundleSelected>
<BuildEventHandlerTypeName>StarForce.Editor.StarForceBuildEventHandler</BuildEventHandlerTypeName>
<OutputDirectory></OutputDirectory>
<OutputDirectory>D:/Learn/GameLearn/UnityProjects/VampireLike/bin/AssetBundles</OutputDirectory>
<OutputPackageSelected>True</OutputPackageSelected>
<OutputFullSelected>True</OutputFullSelected>
<OutputPackedSelected>True</OutputPackedSelected>

View File

@ -16,43 +16,56 @@
<Resource Name="Music/Background" FileSystem="Resources" LoadType="0" Packed="True" ResourceGroups="Music" />
<Resource Name="Music/Menu" FileSystem="Resources" LoadType="0" Packed="True" ResourceGroups="Music" />
<Resource Name="Scenes" FileSystem="Resources" LoadType="0" Packed="True" />
<Resource Name="SceneSettings" LoadType="0" Packed="False" />
<Resource Name="Sounds" FileSystem="Resources" LoadType="0" Packed="True" />
<Resource Name="Textures" FileSystem="Resources" LoadType="0" Packed="True" />
<Resource Name="UI/UIForms" FileSystem="UI" LoadType="0" Packed="True" />
<Resource Name="UI/UIItems" LoadType="0" Packed="True" />
<Resource Name="UI/UISounds" FileSystem="UI" LoadType="0" Packed="True" />
<Resource Name="UI/UISprites/Common" FileSystem="UI" LoadType="0" Packed="True" />
<Resource Name="UI/UISprites/Icons" FileSystem="UI" LoadType="0" Packed="True" />
<Resource Name="UI/UISprites/Logos" FileSystem="UI" LoadType="0" Packed="True" />
<Resource Name="UI/UISprites/SelectRoleFormRT" LoadType="0" Packed="True" />
<Resource Name="URPAssets" LoadType="0" Packed="True" />
</Resources>
<Assets>
<Asset Guid="0179316b5fc7c2946a67c5877c02fc30" ResourceName="UI/UISprites/Common" />
<Asset Guid="04d7dde7615d71b4db1a0c8d67a62e95" ResourceName="UI/UIForms" />
<Asset Guid="04dbc0581071c254ea6564b2ff06ff9b" ResourceName="Textures" />
<Asset Guid="0722cd253d6bf014eb4134a2151ec7e3" ResourceName="UI/UIItems" />
<Asset Guid="093f8873cfe371d41b854ed9fb6bff69" ResourceName="Music/About" />
<Asset Guid="0963e6c65b2b1f74d9f455e21901e2dc" ResourceName="Textures" />
<Asset Guid="0992f89f84d762f478fd32f8225168b0" ResourceName="Entities" />
<Asset Guid="09966b19e546cc94aa84d0743cb2a83d" ResourceName="UI/UIForms" />
<Asset Guid="0a65a68c01a76ea4b8b574827a6467aa" ResourceName="UI/UISprites/Common" />
<Asset Guid="0e45b8557b1831845a6e03fce7b5aa2b" ResourceName="SceneSettings" />
<Asset Guid="0ed73dc47f4cb38489020d05e9f02c99" ResourceName="Materials" />
<Asset Guid="0f995b3145e0e7247a42da6cef1dbf23" ResourceName="Materials" />
<Asset Guid="1046dcb12e547564d8b54bd15419a787" ResourceName="Entities" />
<Asset Guid="1053b0070685be347ab58587156842dc" ResourceName="Localization/Dictionaries" ResourceVariant="zh-tw" />
<Asset Guid="11e27c26ac87b40f0a62ec40d7261989" ResourceName="Entities" />
<Asset Guid="1478894bc9a1ed241b05b0862a7b8bce" ResourceName="Textures" />
<Asset Guid="14869ac0d4433f04db1704e39d03412e" ResourceName="Localization/Dictionaries" ResourceVariant="en-us" />
<Asset Guid="156d241f796508c4da4fc354a7fbf5a8" ResourceName="UI/UISprites/Common" />
<Asset Guid="160925a6fe2664f2a978566b819f0af0" ResourceName="Entities" />
<Asset Guid="185f97f18bd603a478461ce9c08bd039" ResourceName="Materials" />
<Asset Guid="18dc0cd2c080841dea60987a38ce93fa" ResourceName="URPAssets" />
<Asset Guid="1aeec1235e121cb46ba8ea88d1025009" ResourceName="Fonts" />
<Asset Guid="1b4bad6cea5a94611b21f9757fe41444" ResourceName="Materials" />
<Asset Guid="1be4472894949437694aead55c6da60f" ResourceName="Sounds" />
<Asset Guid="1be7b5c5ed8a01f49b26f30ee2146240" ResourceName="Fonts" />
<Asset Guid="1c89236d45255234ebd1d39657ff7e02" ResourceName="Textures" />
<Asset Guid="1cfe02ffd0b74854ea5bcd1a3c63ac3c" ResourceName="Materials" />
<Asset Guid="1d46a17a95a444c08830612bc1146d1d" ResourceName="Materials" />
<Asset Guid="1e0350b97c61bfb4a91c62d756d01727" ResourceName="Materials" />
<Asset Guid="1eb120084e9602c4da979658e08c63e4" ResourceName="UI/UISprites/Icons" />
<Asset Guid="20e5dc75d1c3fe74bb841127a036d69d" ResourceName="UI/UIForms" />
<Asset Guid="2257393dd6ed51a49a6c3fd178382b59" ResourceName="Materials" />
<Asset Guid="236433a27ce40a7429b87d14d8fa3035" ResourceName="UI/UISprites/Common" />
<Asset Guid="239366f83979ffa48a45dac2f0f1e8cb" ResourceName="DataTables" />
<Asset Guid="24ca310f92a6796408f1db7647ec4e55" ResourceName="UI/UISprites/Common" />
<Asset Guid="25229adaac96caa42a737b60465f3229" ResourceName="Fonts" />
<Asset Guid="2768a9a4c8d289840918dcb879705893" ResourceName="Meshes" />
<Asset Guid="28988b1366cba3e4b947bb60d6b118f9" ResourceName="DataTables" />
<Asset Guid="28c42f88cfe56e84e95c0d7545db8c1b" ResourceName="Materials" />
<Asset Guid="2cb5eef4d7d7bf6459dd13a3f8d90246" ResourceName="Textures" />
<Asset Guid="308577c72eb4cd14ca676aeee62b0ea5" ResourceName="UI/UIItems" />
<Asset Guid="312264fc6c05ca04499685cc989e533d" ResourceName="UI/UISprites/Icons" />
<Asset Guid="315e8ed2db27c254cb3366ff0793cd90" ResourceName="DataTables" />
<Asset Guid="3455fe69f7ddc4604b95bf9b0a1e88d7" ResourceName="Entities" />
<Asset Guid="352da872791696c48af3b21132e3e3c3" ResourceName="DataTables" />
@ -62,97 +75,120 @@
<Asset Guid="3dc7455402dfa462b89a4bbd513955e9" ResourceName="Sounds" />
<Asset Guid="3e504a46a8fcec34db3c4776530c6eb2" ResourceName="Textures" />
<Asset Guid="3f54fcfdac53aec42ae18a6a1c6d8cb1" ResourceName="UI/UISprites/Common" />
<Asset Guid="414af21e34e96c343a4d2a0613175657" ResourceName="DataTables" />
<Asset Guid="4209bea5e51753141ae060017f42afdc" ResourceName="UI/UIForms" />
<Asset Guid="429ed03405bf8854eab46552b7470ac0" ResourceName="Materials" />
<Asset Guid="4473d81b14ddb0143addf0e6050d8491" ResourceName="Scenes" />
<Asset Guid="44c8db52241385c45bbb14a1718f17bf" ResourceName="Configs" />
<Asset Guid="4a17d2c656f5c6b44a31e3ee547a76b0" ResourceName="DataTables" />
<Asset Guid="44cfa1c448225554c961ad6eb667d80b" ResourceName="DataTables" />
<Asset Guid="4c3865b2ac420cd46a9cde6ab468d016" ResourceName="Materials" />
<Asset Guid="4db6a299939bfe94893585eb387f577a" ResourceName="DataTables" />
<Asset Guid="4ca22ae3bc068c84eb7858d5b9bdf3e2" ResourceName="Fonts" />
<Asset Guid="4f688097e85071841a2c3ba165000c20" ResourceName="Textures" />
<Asset Guid="5282f20eba4d44213820e21af8481932" ResourceName="Meshes" />
<Asset Guid="56142b46ec15fe74b85ca4fdd3324751" ResourceName="UI/UIForms" />
<Asset Guid="56b8df63bbad60749a69e38bc687fadf" ResourceName="UI/UISprites/Common" />
<Asset Guid="578af1667322bab45b652b79a40bb4fb" ResourceName="Materials" />
<Asset Guid="583ff7026dac91849b7c7b2468ba456b" ResourceName="Materials" />
<Asset Guid="5b5a6a737c460eb4abc105d6583d405e" ResourceName="Fonts" />
<Asset Guid="5dcd89912e222bf4c87f76db4044bc5e" ResourceName="Localization/Dictionaries" ResourceVariant="ko-kr" />
<Asset Guid="62af9e5c8f39cfa49af9e10ccf42f1da" ResourceName="UI/UISprites/Common" />
<Asset Guid="638ff8ae4a0d15047839cd265d3bc296" ResourceName="Music/Background" />
<Asset Guid="63fe6ff9ab9e1433f8db4ebd940f2442" ResourceName="Materials" />
<Asset Guid="64f3bb52c6a54854688fcc656af2b1c9" ResourceName="DataTables" />
<Asset Guid="65a506fc3ca171347ac74203416a3d7f" ResourceName="UI/UISprites/Icons" />
<Asset Guid="65ffa78c2e8cbb346826cc2f3a7b6ea4" ResourceName="DataTables" />
<Asset Guid="66261723fe421be498ce5957449fc972" ResourceName="Scenes" />
<Asset Guid="6a58ea03d3bd54e428d969b85afa5680" ResourceName="Fonts" />
<Asset Guid="6cbc2c323b77f804fb958fa4eca33998" ResourceName="UI/UISprites/Common" />
<Asset Guid="6d9b42ac01f24bf4d98923573f103575" ResourceName="Textures" />
<Asset Guid="6db0c8354d868834abf29840037591b1" ResourceName="Textures" />
<Asset Guid="6de74f273735d3e48b98caf0727ceded" ResourceName="Entities" />
<Asset Guid="6e023ca4283b3a7469cd61d24c83048c" ResourceName="Textures" />
<Asset Guid="6e3730451fa077346abd4ac642ea71d8" ResourceName="Textures" />
<Asset Guid="6e5d026bf0652ed4380f6a66f4aa26c5" ResourceName="Textures" />
<Asset Guid="707360a9c581a4bd7aa53bfeb1429f71" ResourceName="URPAssets" />
<Asset Guid="71646ebaae78d43aeb8b53cacdb69671" ResourceName="Textures" />
<Asset Guid="72e76810224064300b7d32e8322a5d12" ResourceName="Sounds" />
<Asset Guid="738bdf56857a65f479c367c7b62c4ad7" ResourceName="Entities" />
<Asset Guid="74de26a1b47fa13468ea72894a720176" ResourceName="UI/UIForms" />
<Asset Guid="77cbb7c5404c10242ab59953e0746314" ResourceName="Fonts" />
<Asset Guid="7d5f7699d6d1d48e485ac71126e12061" ResourceName="Entities" />
<Asset Guid="78595a129d0438c44b2d52720e9c0edd" ResourceName="UI/UIItems" />
<Asset Guid="7b7fd9122c28c4d15b667c7040e3b3fd" ResourceName="URPAssets" />
<Asset Guid="7e6ecd46ba625fb43ab2b4bc52dcb3c1" ResourceName="DataTables" />
<Asset Guid="7e91cd9bad7babf4b975882a4b7453cb" ResourceName="Textures" />
<Asset Guid="7eae0d2701845a54aa570b07c55dab44" ResourceName="Textures" />
<Asset Guid="7f1361f834115be4ea4ec2387c67334e" ResourceName="Fonts" />
<Asset Guid="7f5aee8da226edf4991598327cb32ce0" ResourceName="UI/UISprites/Logos" />
<Asset Guid="7fd11dc5d29076d469d414dec2818f11" ResourceName="Configs" />
<Asset Guid="834bfaee90a9d4e04b1e8c1ca22cc88e" ResourceName="Entities" />
<Asset Guid="836be25be3e1e8c41ae5545bc8a9a4d7" ResourceName="Textures" />
<Asset Guid="8940b037a9b441c4cbd3d2b446838424" ResourceName="Materials" />
<Asset Guid="8b1acacd22538f34cb85287a0781ea5e" ResourceName="DataTables" />
<Asset Guid="8cf749fdfa5edc3478d16893efeaa0eb" ResourceName="Entities" />
<Asset Guid="8e114ded6a865324588170636872943c" ResourceName="DataTables" />
<Asset Guid="8e27380ee68aa4a219b4db9018e7da31" ResourceName="Materials" />
<Asset Guid="9143e2b62ad50488482f9b73672fc331" ResourceName="Entities" />
<Asset Guid="91b565625868b59428114c4a5b945e80" ResourceName="UI/UISprites/SelectRoleFormRT" />
<Asset Guid="92e207ca452785d478c7a2994d0c8351" ResourceName="UI/UISprites/Icons" />
<Asset Guid="92e9102fc83c8e949971efe6f1fa6501" ResourceName="UI/UIForms" />
<Asset Guid="955000b4d1441470e8cbf94f483228b5" ResourceName="Materials" />
<Asset Guid="97b1f8b25cca2bc458cb9d6127c8d186" ResourceName="Materials" />
<Asset Guid="97d117308cf86924289e81e7e71dd5dd" ResourceName="DataTables" />
<Asset Guid="99d811b0183246646a2ce8df996f4bca" ResourceName="Fonts" />
<Asset Guid="9afa958d6d8235941b9badb42aae4370" ResourceName="Meshes" />
<Asset Guid="9b433f0bb7fef6f4085c316a0d88c307" ResourceName="DataTables" />
<Asset Guid="9be2e1e45f4edd74c8764538ad306b78" ResourceName="Localization/Dictionaries" ResourceVariant="zh-cn" />
<Asset Guid="9c3961f379234354e813d7b38146424d" ResourceName="DataTables" />
<Asset Guid="9c3faac13c8ced84a9f3018303b7bb98" ResourceName="DataTables" />
<Asset Guid="9ddab293e2a8af3499dac05f5fd6169c" ResourceName="Meshes" />
<Asset Guid="9f5bba6d2f5c95049a59fcb56df2d38f" ResourceName="UI/UIItems" />
<Asset Guid="9f847ec5e66e03e4ead1d3c5f7b510e8" ResourceName="UI/UISprites/Common" />
<Asset Guid="a019ae3af8e864616b85773c509f5285" ResourceName="Sounds" />
<Asset Guid="a23eef5e20ff8cb46adf33491fc443fb" ResourceName="Materials" />
<Asset Guid="a33e23ae848110243820cda82120b105" ResourceName="DataTables" />
<Asset Guid="a6560a915ef98420e9faacc1c7438823" ResourceName="URPAssets" />
<Asset Guid="a6ac41115088b5946bc544429260c997" ResourceName="Entities" />
<Asset Guid="a6d58f54ce5934781962a4f887e834f3" ResourceName="Entities" />
<Asset Guid="a71f8bb1b1b2c51438e2bafc884cb02c" ResourceName="DataTables" />
<Asset Guid="a76ff56683a2bc2479ebd63dcdd658b0" ResourceName="UI/UIItems" />
<Asset Guid="a7b030cffa2dc44478c14e49a22771c2" ResourceName="Materials" />
<Asset Guid="a8c07bbe04fdaf04b80e27f651a8edd6" ResourceName="UI/UISprites/Common" />
<Asset Guid="a9be0531a19af934e97a1f3b47b78872" ResourceName="UI/UISprites/Common" />
<Asset Guid="ab1c66f8a301fe043930c9f0c23716cf" ResourceName="Fonts" />
<Asset Guid="ab45c3f613f388d43bbf43ec05eb92e2" ResourceName="UI/UISprites/Common" />
<Asset Guid="ab4774faf71b57a40a29a9e902403fe3" ResourceName="DataTables" />
<Asset Guid="abd1565e9e268f04cac3631d022b4ace" ResourceName="Entities" />
<Asset Guid="ad56aae2bb0f2ce4a86711287e14e223" ResourceName="DataTables" />
<Asset Guid="abb5b3b95f1a42c46a251da378cbeace" ResourceName="Entities" />
<Asset Guid="ae6a7f967521769458b0913fa39caaf4" ResourceName="Textures" />
<Asset Guid="afc18fc39ade3744397c0c993b57be53" ResourceName="Entities" />
<Asset Guid="b031b4f2980561542a7f7ba41391edc3" ResourceName="Scenes" />
<Asset Guid="b0c7cf51d3fecb446ab93bf854419715" ResourceName="Materials" />
<Asset Guid="b2cebe04343227945bab3729ca9a3493" ResourceName="DataTables" />
<Asset Guid="b6539f2b0fa989d4fb7e057799b9260d" ResourceName="Fonts" />
<Asset Guid="b6f06390b8e233345b9a089681f14b81" ResourceName="Entities" />
<Asset Guid="ba157ba55f72c424a9e88f3c029997c4" ResourceName="Textures" />
<Asset Guid="baedbbad82997f445a8cb4da210404e0" ResourceName="Meshes" />
<Asset Guid="bbfd75fe6fe00e1448fe988173ede7f9" ResourceName="UI/UIForms" />
<Asset Guid="bf75b984df8a84987bcf3a8bf6e2862d" ResourceName="Sounds" />
<Asset Guid="c40be3174f62c4acf8c1216858c64956" ResourceName="URPAssets" />
<Asset Guid="c49cffd4fc1dfb549b2b30448a0becda" ResourceName="UI/UISprites/Icons" />
<Asset Guid="c547624e174de984882f0a14b4bb32e1" ResourceName="Materials" />
<Asset Guid="c58c9afddbd36d14d837fa218d772996" ResourceName="Materials" />
<Asset Guid="c7d1e11dd37634b48a9dd4012b8e4306" ResourceName="UI/UISounds" />
<Asset Guid="caa829ab2ffc71340a69253afdf58365" ResourceName="Music/Menu" />
<Asset Guid="cadd0764941c8b646ae79b51d0ea8285" ResourceName="UI/UISprites/Common" />
<Asset Guid="ce8bbe245fa50b74bac0eea7bff0dc3a" ResourceName="UI/UIItems" />
<Asset Guid="cfe53cf384344bd47a8680f8c5f97a7b" ResourceName="DataTables" />
<Asset Guid="d0e2fc18fe036412f8223b3b3d9ad574" ResourceName="URPAssets" />
<Asset Guid="d5396f61766946c4db970694836a49fc" ResourceName="UI/UIItems" />
<Asset Guid="d9808401c68af274a8edfbed3d1b53c7" ResourceName="Meshes" />
<Asset Guid="db58965402f12ed47b4dad61a9e48c9d" ResourceName="UI/UISprites/Icons" />
<Asset Guid="e0792649e7774a24d8e7cceba0231c61" ResourceName="DataTables" />
<Asset Guid="e1260c1148f6143b28bae5ace5e9c5d1" ResourceName="URPAssets" />
<Asset Guid="e3616cef1ab22d642903eb59f34feea1" ResourceName="Entities" />
<Asset Guid="e5ca26c53b6ab8a46b52817008d7c7fa" ResourceName="UI/UISprites/Icons" />
<Asset Guid="e634585d5c4544dd297acaee93dc2beb" ResourceName="URPAssets" />
<Asset Guid="e82837c9099f69a48b48fc44eb8d119d" ResourceName="UI/UISprites/Common" />
<Asset Guid="e830964cdb85ff3429bca484c16bab44" ResourceName="UI/UISounds" />
<Asset Guid="e85864330b68dde498dcb6e8711815d3" ResourceName="UI/UISprites/Common" />
<Asset Guid="e8def20f1612e8844b8f0dda497fa5ba" ResourceName="DataTables" />
<Asset Guid="eabb37cb6d738b443b398b701a64cd88" ResourceName="Textures" />
<Asset Guid="f06c2627a191cc1468383483fbafca04" ResourceName="Fonts" />
<Asset Guid="f17bc7e2694233349a8b22e96c5c43de" ResourceName="Materials" />
<Asset Guid="f2f4df0b7211e4c42a5638273525d8ee" ResourceName="UI/UISprites/Common" />
<Asset Guid="f2f97a713beae744181ba934f9c4113a" ResourceName="DataTables" />
<Asset Guid="f36c72c738c55f741afcd674a0b1245f" ResourceName="Materials" />
<Asset Guid="f438a72a91e1c3c4a9ced40888ffec96" ResourceName="UI/UISprites/Icons" />
<Asset Guid="f4ec271e525e14ca9927a07e6a2e153d" ResourceName="Entities" />
<Asset Guid="f5b2cc6c7ce8cc5408ad507a4f40af49" ResourceName="Fonts" />
<Asset Guid="f6bd6a95990ae92469c5c9ab4293064f" ResourceName="UI/UIForms" />
<Asset Guid="f6db5bbdfe0e9894798706814cd6b336" ResourceName="Textures" />
<Asset Guid="f9ef7b3e3b869a348bce0a7852d93e79" ResourceName="Fonts" />
<Asset Guid="fb171366644152948b39e5c17f4b1f39" ResourceName="Fonts" />
<Asset Guid="fd3cbf51780694849b9b019b36a3938e" ResourceName="Textures" />
<Asset Guid="fdb5edd099d06b045af609ba3172400a" ResourceName="DataTables" />
<Asset Guid="fedd25a3c60e7ae499fc6efab9ee180b" ResourceName="Entities" />
</Assets>
</ResourceCollection>
</UnityGameFramework>

View File

@ -1,5 +1,5 @@
# 敌人基础属性表
# Id MaxHealth Speed CoinDrop ExpDrop DropPercent
# int int float int int float
# 实体编号 策划备注 最大生命 移动速度 金币掉落 经验掉落 掉落概率
101 近战敌人 20 3 2 1 0.3
# 敌人基础属性表
# Id MaxHealth HpAddPerLevel Speed CoinDrop ExpDrop DropPercent
# int int int float int int float
# 实体编号 策划备注 最大生命 每关卡增加生命 移动速度 金币掉落 经验掉落 掉落概率
101 近战敌人 50 50 3 5 1 0.3

View File

@ -0,0 +1,7 @@
# 关卡道具品质掉落概率表
# Id LevelMin LevelMax WhiteWeight GreenWeight BlueWeight PurpleWeight RedWeight SumWeight
# int float float float float float float float float
# 概率编号 策划备注 关卡左区间 关卡右区间 白色掉落率 绿色掉落率 蓝色掉落率 紫色掉落率 红色掉落率 总掉落率(不需要读取)
1 1 3 75 20 4 1 0 100
2 4 5 30 50 15 4 1 100
3 6 10 10 20 40 20 10 100

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0080b46050fc460cb6d6c7fc8d4e8c27
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +1,22 @@
# 道具表
# Id Title IconAssetName Modifiers
# int string string StatModifier[]
# 奖励编号 策划备注 奖励名 图标资源名 道具属性
101 测试道具 肌肉 Almighty_Icon [{"StatType":"Attack","Value":0.05,"IsPercent":true}]
102 牙齿 Almighty_Icon [{"StatType":"Attack","Value":0.05,"IsPercent":true}]
103 脑 Almighty_Icon [{"StatType":"Attack","Value":0.05,"IsPercent":true}]
104 鼻子 Almighty_Icon [{"StatType":"Attack","Value":0.05,"IsPercent":true}]
# 道具表
# Id Title IconAssetName Rarity Modifiers
# int string string RarityType StatModifier[]
# 奖励编号 策划备注 奖励名 图标资源名 道具品质 道具属性
101 测试道具 肌肉 Almighty_Icon White [{"StatType":"Attack","Value":0.05,"IsPercent":true}]
102 牙齿 Almighty_Icon White [{"StatType":"Attack","Value":0.05,"IsPercent":true}]
103 脑 Almighty_Icon White [{"StatType":"Critical","Value":0.05,"IsPercent":true}]
104 鼻子 Almighty_Icon White [{"StatType":"AbsorbRange","Value":0.05,"IsPercent":true}]
105 腿 Almighty_Icon White [{"StatType":"MovementSpeed","Value":0.05,"IsPercent":true}]
106 眼睛 Almighty_Icon White [{"StatType":"MaxHealth","Value":0.05,"IsPercent":true}]
107 肌肉 Almighty_Icon Green [{"StatType":"Attack","Value":0.15,"IsPercent":true}]
108 牙齿 Almighty_Icon Green [{"StatType":"Attack","Value":0.15,"IsPercent":true}]
109 脑 Almighty_Icon Green [{"StatType":"Critical","Value":0.15,"IsPercent":true}]
110 鼻子 Almighty_Icon Green [{"StatType":"AbsorbRange","Value":0.15,"IsPercent":true}]
111 腿 Almighty_Icon Green [{"StatType":"MovementSpeed","Value":0.15,"IsPercent":true}]
112 眼睛 Almighty_Icon Green [{"StatType":"MaxHealth","Value":0.15,"IsPercent":true}]
113 肌肉 Almighty_Icon Blue [{"StatType":"Attack","Value":0.3,"IsPercent":true}]
114 牙齿 Almighty_Icon Blue [{"StatType":"Attack","Value":0.3,"IsPercent":true}]
115 脑 Almighty_Icon Blue [{"StatType":"Critical","Value":0.3,"IsPercent":true}]
116 鼻子 Almighty_Icon Blue [{"StatType":"AbsorbRange","Value":0.3,"IsPercent":true}]
117 腿 Almighty_Icon Blue [{"StatType":"MovementSpeed","Value":0.3,"IsPercent":true}]
118 眼睛 Almighty_Icon Blue [{"StatType":"MaxHealth","Value":0.3,"IsPercent":true}]

View File

@ -2,5 +2,5 @@
# Id Title IconAssetName Rarity Price PriceRandomPercent Attack Cooldown AttackRange AttackSoundId Pramas Modifiers
# int string string RarityType int float int float float int string[] StatModifier[]
# 武器编号 策划备注 武器名 图标资源名 道具品质 武器价格 价格浮动 伤害 冷却 范围 攻击音效编号 额外参数 额外属性
201 玩家武器 小刀 Almighty_Icon White 120 0.05 100 1.5 3 10000 [] []
202 手枪 Almighty_Icon White 130 0.05 120 1 10 10000 [] []
201 玩家武器 小刀 Almighty_Icon White 120 0.05 100 1.5 5 10000 [] []
202 手枪 Almighty_Icon White 130 0.05 120 1 15 10000 [] []

View File

@ -65,7 +65,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 28c42f88cfe56e84e95c0d7545db8c1b, type: 2}
- {fileID: 2100000, guid: 83e5fce2d1e5b3e4ab6551de03cc9c22, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0

View File

@ -369,6 +369,7 @@ GameObject:
- component: {fileID: 582203051508165858}
- component: {fileID: 4988822728923805024}
- component: {fileID: 4321355627424240428}
- component: {fileID: 7894423710682551789}
m_Layer: 7
m_Name: Player
m_TagString: Player
@ -421,7 +422,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
- {fileID: 2100000, guid: c4f37184fcb9306428d7d002f7dca96d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
@ -566,3 +567,22 @@ MonoBehaviour:
- {fileID: 4149661712638700245}
- {fileID: 5429551983429523606}
- {fileID: 2395797268595685132}
--- !u!114 &7894423710682551789
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8198962528757305497}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 46f46350fed64d8389ebb4ae72b65796, type: 3}
m_Name:
m_EditorClassIdentifier:
_absorbRangeBase: 3
_absorbSpeed: 8
_collectDistance: 0.35
_maxDetectCount: 64
_detectLayerMask:
serializedVersion: 2
m_Bits: 8192

View File

@ -64,7 +64,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 2257393dd6ed51a49a6c3fd178382b59, type: 2}
- {fileID: 2100000, guid: 429ed03405bf8854eab46552b7470ac0, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d278c30ab68ad1e4b8c981c2ffe9473e
guid: 9dc75a5d11c10e94c9d5ed1176388036
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,143 @@
Shader "TextMeshPro/Bitmap Custom Atlas" {
Properties {
_MainTex ("Font Atlas", 2D) = "white" {}
_FaceTex ("Font Texture", 2D) = "white" {}
[HDR]_FaceColor ("Text Color", Color) = (1,1,1,1)
_VertexOffsetX ("Vertex OffsetX", float) = 0
_VertexOffsetY ("Vertex OffsetY", float) = 0
_MaskSoftnessX ("Mask SoftnessX", float) = 0
_MaskSoftnessY ("Mask SoftnessY", float) = 0
_ClipRect("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
_Padding ("Padding", 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
_CullMode("Cull Mode", Float) = 0
_ColorMask("Color Mask", Float) = 15
}
SubShader{
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
Stencil
{
Ref[_Stencil]
Comp[_StencilComp]
Pass[_StencilOp]
ReadMask[_StencilReadMask]
WriteMask[_StencilWriteMask]
}
Lighting Off
Cull [_CullMode]
ZTest [unity_GUIZTestMode]
ZWrite Off
Fog { Mode Off }
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 : SV_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 v)
{
float4 vert = v.vertex;
vert.x += _VertexOffsetX;
vert.y += _VertexOffsetY;
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
float4 vPosition = UnityPixelSnap(UnityObjectToClipPos(vert));
fixed4 faceColor = v.color;
faceColor *= _FaceColor;
v2f OUT;
OUT.vertex = vPosition;
OUT.color = faceColor;
OUT.texcoord0 = v.texcoord0;
OUT.texcoord1 = TRANSFORM_TEX(UnpackUV(v.texcoord1), _FaceTex);
float2 pixelSize = vPosition.w;
pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
// Clamp _ClipRect to 16bit.
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
return OUT;
}
fixed4 frag (v2f IN) : SV_Target
{
fixed4 color = tex2D(_MainTex, IN.texcoord0) * tex2D(_FaceTex, IN.texcoord1) * IN.color;
// Alternative implementation to UnityGet2DClipping with support for softness.
#if UNITY_UI_CLIP_RECT
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
color *= m.x * m.y;
#endif
#if UNITY_UI_ALPHACLIP
clip(color.a - 0.001);
#endif
return color;
}
ENDCG
}
}
CustomEditor "TMPro.EditorUtilities.TMP_BitmapShaderGUI"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b6539f2b0fa989d4fb7e057799b9260d
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,145 @@
Shader "TextMeshPro/Mobile/Bitmap" {
Properties {
_MainTex ("Font Atlas", 2D) = "white" {}
[HDR]_Color ("Text Color", Color) = (1,1,1,1)
_DiffusePower ("Diffuse Power", Range(1.0,4.0)) = 1.0
_VertexOffsetX("Vertex OffsetX", float) = 0
_VertexOffsetY("Vertex OffsetY", float) = 0
_MaskSoftnessX("Mask SoftnessX", float) = 0
_MaskSoftnessY("Mask SoftnessY", float) = 0
_ClipRect("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
_StencilComp("Stencil Comparison", Float) = 8
_Stencil("Stencil ID", Float) = 0
_StencilOp("Stencil Operation", Float) = 0
_StencilWriteMask("Stencil Write Mask", Float) = 255
_StencilReadMask("Stencil Read Mask", Float) = 255
_CullMode("Cull Mode", Float) = 0
_ColorMask("Color Mask", Float) = 15
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Stencil
{
Ref[_Stencil]
Comp[_StencilComp]
Pass[_StencilOp]
ReadMask[_StencilReadMask]
WriteMask[_StencilWriteMask]
}
Lighting Off
Cull [_CullMode]
ZTest [unity_GUIZTestMode]
ZWrite Off
Fog { Mode Off }
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 OUT;
float4 vert = v.vertex;
vert.x += _VertexOffsetX;
vert.y += _VertexOffsetY;
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
OUT.vertex = UnityPixelSnap(UnityObjectToClipPos(vert));
OUT.color = v.color;
OUT.color *= _Color;
OUT.color.rgb *= _DiffusePower;
OUT.texcoord0 = v.texcoord0;
float2 pixelSize = OUT.vertex.w;
//pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
// Clamp _ClipRect to 16bit.
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
return OUT;
}
fixed4 frag (v2f IN) : COLOR
{
fixed4 color = fixed4(IN.color.rgb, IN.color.a * tex2D(_MainTex, IN.texcoord0).a);
// Alternative implementation to UnityGet2DClipping with support for softness.
#if UNITY_UI_CLIP_RECT
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
color *= m.x * m.y;
#endif
#if UNITY_UI_ALPHACLIP
clip(color.a - 0.001);
#endif
return color;
}
ENDCG
}
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord0
}
Pass {
SetTexture [_MainTex] {
constantColor [_Color] combine constant * primary, constant * texture
}
}
}
CustomEditor "TMPro.EditorUtilities.TMP_BitmapShaderGUI"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f06c2627a191cc1468383483fbafca04
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,143 @@
Shader "TextMeshPro/Bitmap" {
Properties {
_MainTex ("Font Atlas", 2D) = "white" {}
_FaceTex ("Font Texture", 2D) = "white" {}
[HDR]_FaceColor ("Text Color", Color) = (1,1,1,1)
_VertexOffsetX ("Vertex OffsetX", float) = 0
_VertexOffsetY ("Vertex OffsetY", float) = 0
_MaskSoftnessX ("Mask SoftnessX", float) = 0
_MaskSoftnessY ("Mask SoftnessY", float) = 0
_ClipRect("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
_StencilComp("Stencil Comparison", Float) = 8
_Stencil("Stencil ID", Float) = 0
_StencilOp("Stencil Operation", Float) = 0
_StencilWriteMask("Stencil Write Mask", Float) = 255
_StencilReadMask("Stencil Read Mask", Float) = 255
_CullMode("Cull Mode", Float) = 0
_ColorMask("Color Mask", Float) = 15
}
SubShader{
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
Stencil
{
Ref[_Stencil]
Comp[_StencilComp]
Pass[_StencilOp]
ReadMask[_StencilReadMask]
WriteMask[_StencilWriteMask]
}
Lighting Off
Cull [_CullMode]
ZTest [unity_GUIZTestMode]
ZWrite Off
Fog { Mode Off }
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 : SV_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 v)
{
float4 vert = v.vertex;
vert.x += _VertexOffsetX;
vert.y += _VertexOffsetY;
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
float4 vPosition = UnityPixelSnap(UnityObjectToClipPos(vert));
fixed4 faceColor = v.color;
faceColor *= _FaceColor;
v2f OUT;
OUT.vertex = vPosition;
OUT.color = faceColor;
OUT.texcoord0 = v.texcoord0;
OUT.texcoord1 = TRANSFORM_TEX(UnpackUV(v.texcoord1), _FaceTex);
float2 pixelSize = vPosition.w;
pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
// Clamp _ClipRect to 16bit.
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
return OUT;
}
fixed4 frag (v2f IN) : SV_Target
{
fixed4 color = tex2D(_MainTex, IN.texcoord0);
color = fixed4 (tex2D(_FaceTex, IN.texcoord1).rgb * IN.color.rgb, IN.color.a * color.a);
// Alternative implementation to UnityGet2DClipping with support for softness.
#if UNITY_UI_CLIP_RECT
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
color *= m.x * m.y;
#endif
#if UNITY_UI_ALPHACLIP
clip(color.a - 0.001);
#endif
return color;
}
ENDCG
}
}
CustomEditor "TMPro.EditorUtilities.TMP_BitmapShaderGUI"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6a58ea03d3bd54e428d969b85afa5680
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,317 @@
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
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_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
[HDR]_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)
[HDR]_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
[HDR]_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
_Sharpness ("Sharpness", Range(-1,1)) = 0
_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
_CullMode ("Cull Mode", Float) = 0
_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 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 {
UNITY_VERTEX_INPUT_INSTANCE_ID
float4 position : POSITION;
float3 normal : NORMAL;
fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
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)
{
pixel_t output;
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input,output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
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 * (_Sharpness + 1);
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);
output.position = vPosition;
output.color = input.color;
output.atlas = input.texcoord0;
output.param = float4(alphaClip, scale, bias, weight);
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
output.viewDir = mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz);
#if (UNDERLAY_ON || UNDERLAY_INNER)
output.texcoord2 = float4(input.texcoord0 + bOffset, bScale, bBias);
output.underlayColor = underlayColor;
#endif
output.textures = float4(faceUV, outlineUV);
return output;
}
fixed4 PixShader(pixel_t input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
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"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1be7b5c5ed8a01f49b26f30ee2146240
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,310 @@
Shader "TextMeshPro/Distance Field SSD" {
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
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_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
[HDR]_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)
[HDR]_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
[HDR]_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
_Sharpness ("Sharpness", Range(-1,1)) = 0
_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
_CullMode ("Cull Mode", Float) = 0
_ColorMask ("Color Mask", Float) = 15
}
SubShader {
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Stencil
{
Ref[_Stencil]
Comp[_StencilComp]
Pass[_StencilOp]
ReadMask[_StencilReadMask]
WriteMask[_StencilWriteMask]
}
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 __ FORCE_LINEAR
#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 {
UNITY_VERTEX_INPUT_INSTANCE_ID
float4 position : POSITION;
float3 normal : NORMAL;
float4 color : COLOR;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
float4 position : SV_POSITION;
float4 color : COLOR;
float2 atlas : TEXCOORD0;
float weight : TEXCOORD1;
float2 mask : TEXCOORD2; // Position in object space(xy)
float3 viewDir : TEXCOORD3;
#if (UNDERLAY_ON || UNDERLAY_INNER)
float2 texcoord2 : TEXCOORD4;
float4 underlayColor : COLOR1;
#endif
float4 textures : TEXCOORD5;
};
// Used by Unity internally to handle Texture Tiling and Offset.
float4 _FaceTex_ST;
float4 _OutlineTex_ST;
float4 SRGBToLinear(float4 rgba) {
return float4(lerp(rgba.rgb / 12.92f, pow((rgba.rgb + 0.055f) / 1.055f, 2.4f), step(0.04045f, rgba.rgb)), rgba.a);
}
pixel_t VertShader(vertex_t input)
{
pixel_t output;
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input,output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float bold = step(input.texcoord1.y, 0);
float4 vert = input.position;
vert.x += _VertexOffsetX;
vert.y += _VertexOffsetY;
float4 vPosition = UnityObjectToClipPos(vert);
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
#if (UNDERLAY_ON || UNDERLAY_INNER)
float4 underlayColor = _UnderlayColor;
underlayColor.rgb *= underlayColor.a;
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);
// Support for texture tiling and offset
float2 textureUV = UnpackUV(input.texcoord1.x);
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
float4 color = input.color;
#if (FORCE_LINEAR && !UNITY_COLORSPACE_GAMMA)
color = SRGBToLinear(input.color);
#endif
output.position = vPosition;
output.color = color;
output.atlas = input.texcoord0;
output.weight = weight;
output.mask = half2(vert.xy * 2 - clampedRect.xy - clampedRect.zw);
output.viewDir = mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz);
#if (UNDERLAY_ON || UNDERLAY_INNER)
output.texcoord2 = input.texcoord0 + bOffset;
output.underlayColor = underlayColor;
#endif
output.textures = float4(faceUV, outlineUV);
return output;
}
fixed4 PixShader(pixel_t input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
float c = tex2D(_MainTex, input.atlas).a;
float2 pixelSize = float2(ddx(input.atlas.y), ddy(input.atlas.y));
pixelSize *= _TextureWidth * .75;
float scale = rsqrt(dot(pixelSize, pixelSize)) * _GradientScale * (_Sharpness + 1);
float weight = input.weight;
float bias = (.5 - weight) + (.5 / scale);
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 || UNDERLAY_INNER)
float bScale = scale;
bScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * bScale);
float bBias = (0.5 - weight) * bScale - 0.5 - ((_UnderlayDilate * _ScaleRatioC) * 0.5 * bScale);
#endif
#if UNDERLAY_ON
float d = tex2D(_MainTex, input.texcoord2.xy).a * bScale;
faceColor += input.underlayColor * saturate(d - bBias) * (1 - faceColor.a);
#endif
#if UNDERLAY_INNER
float d = tex2D(_MainTex, input.texcoord2.xy).a * bScale;
faceColor += input.underlayColor * (1 - saturate(d - bBias)) * 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
float2 maskZW = 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + (1 / scale));
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * maskZW);
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"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f9ef7b3e3b869a348bce0a7852d93e79
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,247 @@
// 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 {
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
[HDR]_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
_Sharpness ("Sharpness", Range(-1,1)) = 0
_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
_CullMode ("Cull Mode", Float) = 0
_ColorMask ("Color Mask", Float) = 15
}
SubShader {
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
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
};
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 * (_Sharpness + 1);
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
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;
#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"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 25229adaac96caa42a737b60465f3229
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,240 @@
// 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 {
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
[HDR]_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
_Sharpness ("Sharpness", Range(-1,1)) = 0
_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
_CullMode ("Cull Mode", Float) = 0
_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 {
UNITY_VERTEX_INPUT_INSTANCE_ID
float4 vertex : POSITION;
float3 normal : NORMAL;
fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
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)
{
pixel_t output;
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
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 * (_Sharpness + 1);
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);
// Populate structure for pixel shader
output.vertex = vPosition;
output.faceColor = faceColor;
output.outlineColor = outlineColor;
output.texcoord0 = float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y);
output.param = half4(scale, bias - outline, bias + outline, bias);
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
#if (UNDERLAY_ON || UNDERLAY_INNER)
output.texcoord1 = float4(input.texcoord0 + layerOffset, input.color.a, 0);
output.underlayParam = half2(layerScale, layerBias);
#endif
return output;
}
// PIXEL SHADER
fixed4 PixShader(pixel_t input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
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"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7f1361f834115be4ea4ec2387c67334e
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,106 @@
// 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 SSD" {
Properties {
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
[HDR]_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
_Sharpness ("Sharpness", Range(-1,1)) = 0
_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
_CullMode ("Cull Mode", Float) = 0
_ColorMask ("Color Mask", Float) = 15
}
SubShader {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
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"
#include "TMPro_Mobile.cginc"
ENDCG
}
}
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1aeec1235e121cb46ba8ea88d1025009
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,240 @@
// 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 {
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
[HDR]_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
_Sharpness ("Sharpness", Range(-1,1)) = 0
_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
_CullMode ("Cull Mode", Float) = 0
_ColorMask ("Color Mask", Float) = 15
}
SubShader {
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
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 {
UNITY_VERTEX_INPUT_INSTANCE_ID
float4 vertex : POSITION;
float3 normal : NORMAL;
fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
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)
{
pixel_t output;
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
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 * (_Sharpness + 1);
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);
// Populate structure for pixel shader
output.vertex = vPosition;
output.faceColor = faceColor;
output.outlineColor = outlineColor;
output.texcoord0 = float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y);
output.param = half4(scale, bias - outline, bias + outline, bias);
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
#if (UNDERLAY_ON || UNDERLAY_INNER)
output.texcoord1 = float4(input.texcoord0 + layerOffset, input.color.a, 0);
output.underlayParam = half2(layerScale, layerBias);
#endif
return output;
}
// PIXEL SHADER
fixed4 PixShader(pixel_t input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
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"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: fb171366644152948b39e5c17f4b1f39
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,138 @@
// 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" {}
[HDR]_FaceColor ("Fill Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_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
[HDR]_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
_Sharpness ("Sharpness", Range(-1,1)) = 0
_VertexOffsetX ("Vertex OffsetX", float) = 0
_VertexOffsetY ("Vertex OffsetY", float) = 0
_CullMode ("Cull Mode", 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"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4ca22ae3bc068c84eb7858d5b9bdf3e2
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,158 @@
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
[HDR]_FaceColor ("Fill Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_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)
[HDR]_SpecColor ("Specular Color", Color) = (0,0,0,1)
_FaceShininess ("Face Shininess", Range(0,1)) = 0
_OutlineShininess ("Outline Shininess", Range(0,1)) = 0
[HDR]_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
_Sharpness ("Sharpness", Range(-1,1)) = 0
_VertexOffsetX ("Vertex OffsetX", float) = 0
_VertexOffsetY ("Vertex OffsetY", float) = 0
_CullMode ("Cull Mode", 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"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f5b2cc6c7ce8cc5408ad507a4f40af49
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,317 @@
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
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_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
[HDR]_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)
[HDR]_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
[HDR]_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
_Sharpness ("Sharpness", Range(-1,1)) = 0
_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
_CullMode ("Cull Mode", Float) = 0
_ColorMask ("Color Mask", Float) = 15
}
SubShader {
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
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 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 {
UNITY_VERTEX_INPUT_INSTANCE_ID
float4 position : POSITION;
float3 normal : NORMAL;
fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
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)
{
pixel_t output;
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input,output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
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 * (_Sharpness + 1);
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);
output.position = vPosition;
output.color = input.color;
output.atlas = input.texcoord0;
output.param = float4(alphaClip, scale, bias, weight);
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
output.viewDir = mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz);
#if (UNDERLAY_ON || UNDERLAY_INNER)
output.texcoord2 = float4(input.texcoord0 + bOffset, bScale, bBias);
output.underlayColor = underlayColor;
#endif
output.textures = float4(faceUV, outlineUV);
return output;
}
fixed4 PixShader(pixel_t input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
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"
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5b5a6a737c460eb4abc105d6583d405e
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,116 @@
Shader "TextMeshPro/Sprite"
{
Properties
{
[PerRendererData] _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
_CullMode ("Cull Mode", Float) = 0
_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 [_CullMode]
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend SrcAlpha OneMinusSrcAlpha
ColorMask [_ColorMask]
Pass
{
Name "Default"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#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;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
fixed4 _Color;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
float4 _MainTex_ST;
v2f vert(appdata_t v)
{
v2f OUT;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
OUT.worldPosition = v.vertex;
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
OUT.color = v.color * _Color;
return OUT;
}
fixed4 frag(v2f IN) : SV_Target
{
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
#ifdef 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
}
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: ab1c66f8a301fe043930c9f0c23716cf
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,137 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Blue
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap:
RenderType: Opaque
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BlendOp: 0
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _FlashAmount: 0
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _SampleGI: 0
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.1, g: 1, b: 0.9, a: 1}
- _Color: {r: 0.09999997, g: 1, b: 0.9, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _FlashColor: {r: 1, g: 1, b: 1, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
--- !u!114 &4582237545370899445
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 7

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: 94ca859a535c2074392c01285b2754e0
guid: c4f37184fcb9306428d7d002f7dca96d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,7 +7,7 @@ Material:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Green
m_Name: InstancingGreen
m_Shader: {fileID: 4800000, guid: f17bc7e2694233349a8b22e96c5c43de, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0

View File

@ -0,0 +1,136 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: InstancingGrey
m_Shader: {fileID: 4800000, guid: f17bc7e2694233349a8b22e96c5c43de, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _AlphaClip: 0
- _AlphaToMask: 0
- _Blend: 0
- _BlendModePreserveSpecular: 1
- _BlendOp: 0
- _BumpScale: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlendAlpha: 0
- _EnvironmentReflections: 1
- _FlashAmount: 0
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _SampleGI: 0
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SrcBlendAlpha: 1
- _Surface: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- _Color: {r: 1, g: 0.29245266, b: 0.29245266, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _FlashColor: {r: 1, g: 1, b: 1, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
--- !u!114 &4582237545370899445
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 7

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: bd0dcd203508e774b84313644b9fad2c
guid: 83e5fce2d1e5b3e4ab6551de03cc9c22
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4890085278179872738
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,7 +7,7 @@ Material:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Red
m_Name: InstancingRed
m_Shader: {fileID: 4800000, guid: f17bc7e2694233349a8b22e96c5c43de, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0

View File

@ -7,7 +7,7 @@ Material:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Yellow
m_Name: InstancingYellow
m_Shader: {fileID: 4800000, guid: f17bc7e2694233349a8b22e96c5c43de, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 051868bff0e1df3498c100dc5a9f027d
guid: 1e2a290aa42884640815cb6fd552deac
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -96,7 +96,8 @@ LightmapSettings:
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingDataAsset: {fileID: 112000000, guid: fb9bd70ff25fcde4e954a6f3ec6ca2cd,
type: 2}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fb9bd70ff25fcde4e954a6f3ec6ca2cd
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 112000000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,127 @@
fileFormatVersion: 2
guid: 0e45b8557b1831845a6e03fce7b5aa2b
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 1
seamlessCubemap: 1
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 2
aniso: 0
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 2
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 100
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,66 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!850595691 &4890085278179872738
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: MainSettings
serializedVersion: 6
m_GIWorkflowMode: 1
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 0
m_BakeBackend: 0
m_LightmapMaxSize: 1024
m_BakeResolution: 50
m_Padding: 2
m_LightmapCompression: 0
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 0
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 1
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 1
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 1024
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVREnvironmentSampleCount: 512
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRMinBounces: 2
m_PVREnvironmentImportanceSampling: 0
m_PVRFilteringMode: 0
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_PVRTiledBaking: 0
m_NumRaysToShootPerTexel: -1
m_RespectSceneVisibilityWhenBakingGI: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 29930de0f940628418fed89e3808746f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6756a079a4ef9c6428b0209b454e1241
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 112000000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,104 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-32820517437979890
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3}
m_Name: Bloom
m_EditorClassIdentifier:
active: 1
skipIterations:
m_OverrideState: 0
m_Value: 1
threshold:
m_OverrideState: 0
m_Value: 0.9
intensity:
m_OverrideState: 1
m_Value: 1
scatter:
m_OverrideState: 0
m_Value: 0.7
clamp:
m_OverrideState: 0
m_Value: 65472
tint:
m_OverrideState: 0
m_Value: {r: 1, g: 1, b: 1, a: 1}
highQualityFiltering:
m_OverrideState: 0
m_Value: 0
downscale:
m_OverrideState: 0
m_Value: 0
maxIterations:
m_OverrideState: 0
m_Value: 6
dirtTexture:
m_OverrideState: 0
m_Value: {fileID: 0}
dimension: 1
dirtIntensity:
m_OverrideState: 0
m_Value: 0
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: GlobalVolumeProfile
m_EditorClassIdentifier:
components:
- {fileID: 1881579288749618558}
- {fileID: -32820517437979890}
--- !u!114 &1881579288749618558
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 97c23e3b12dc18c42a140437e53d3951, type: 3}
m_Name: Tonemapping
m_EditorClassIdentifier:
active: 1
mode:
m_OverrideState: 1
m_Value: 1
neutralHDRRangeReductionMode:
m_OverrideState: 0
m_Value: 2
acesPreset:
m_OverrideState: 0
m_Value: 3
hueShiftAmount:
m_OverrideState: 0
m_Value: 0
detectPaperWhite:
m_OverrideState: 0
m_Value: 0
paperWhite:
m_OverrideState: 0
m_Value: 300
detectBrightnessLimits:
m_OverrideState: 0
m_Value: 1
minNits:
m_OverrideState: 0
m_Value: 0.005
maxNits:
m_OverrideState: 0
m_Value: 1000

View File

@ -18,6 +18,11 @@ public partial class GameEntry : MonoBehaviour
public static BuiltinDataComponent BuiltinData { get; private set; }
public static HPBarComponent HPBar { get; private set; }
public static DamageTextComponent DamageText { get; private set; }
#if UNITY_EDITOR || DEVELOPMENT_BUILD
public static RuntimeDebugPanelComponent RuntimeDebugPanel { get; private set; }
#endif
public static EnemyManagerComponent EnemyManager { get; private set; }
@ -29,6 +34,18 @@ public partial class GameEntry : MonoBehaviour
{
BuiltinData = UnityGameFramework.Runtime.GameEntry.GetComponent<BuiltinDataComponent>();
HPBar = UnityGameFramework.Runtime.GameEntry.GetComponent<HPBarComponent>();
DamageText = UnityGameFramework.Runtime.GameEntry.GetComponent<DamageTextComponent>();
if (DamageText == null && Base != null)
{
DamageText = Base.gameObject.AddComponent<DamageTextComponent>();
}
#if UNITY_EDITOR || DEVELOPMENT_BUILD
RuntimeDebugPanel = UnityGameFramework.Runtime.GameEntry.GetComponent<RuntimeDebugPanelComponent>();
if (RuntimeDebugPanel == null && Base != null)
{
RuntimeDebugPanel = Base.gameObject.AddComponent<RuntimeDebugPanelComponent>();
}
#endif
EnemyManager = UnityGameFramework.Runtime.GameEntry.GetComponent<EnemyManagerComponent>();
SpriteCache = UnityGameFramework.Runtime.GameEntry.GetComponent<SpriteCacheComponent>();
UIRouter = UnityGameFramework.Runtime.GameEntry.GetComponent<UIRouterComponent>();

View File

@ -0,0 +1,101 @@
using System;
using Definition.DataStruct;
using Definition.Enum;
using Entity;
using UnityEngine;
namespace Components
{
public class AbsorbComponent : MonoBehaviour
{
[SerializeField] private float _absorbRangeBase = 3f;
[SerializeField] private float _absorbSpeed = 15f;
[SerializeField] private float _collectDistance = 0.35f;
[SerializeField] private int _maxDetectCount = 64;
[SerializeField] private LayerMask _detectLayerMask = ~0;
private Player _player;
private Transform _target;
private StatComponent _statComponent;
private Collider[] _buffer;
private StatProperty _absorbRangeStat;
private Action<StatModifier, bool> _absorbRangeStatCallback;
private float AbsorbRange => Mathf.Max(0f, (_absorbRangeBase + _absorbRangeStat.Value) * _absorbRangeStat.Percent);
public void OnInit(Player player, StatComponent statComponent = null)
{
_player = player;
_target = player != null ? player.CachedTransform : null;
_statComponent = statComponent;
_buffer = new Collider[Mathf.Max(1, _maxDetectCount)];
if (_statComponent != null)
{
_absorbRangeStat = _statComponent.GetStat(StatType.AbsorbRange);
_absorbRangeStatCallback = (modifier, isApply) =>
_statComponent.UpdateStat(_absorbRangeStat, modifier, isApply);
_statComponent.Subscribe(StatType.AbsorbRange, _absorbRangeStatCallback);
}
else
{
_absorbRangeStat = new StatProperty();
}
}
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
{
if (_player == null || !_player.Available || _target == null || _buffer == null) return;
int hitCount = Physics.OverlapSphereNonAlloc(
_target.position,
AbsorbRange,
_buffer,
_detectLayerMask,
QueryTriggerInteraction.Collide
);
for (int i = 0; i < hitCount; i++)
{
Collider hit = _buffer[i];
if (hit == null) continue;
CoinEntity coin = hit.GetComponent<CoinEntity>();
if (coin != null && coin.Available)
{
AbsorbDrop(coin.CachedTransform, elapseSeconds);
coin.TryCollect(_player, _collectDistance);
continue;
}
ExpEntity exp = hit.GetComponent<ExpEntity>();
if (exp != null && exp.Available)
{
AbsorbDrop(exp.CachedTransform, elapseSeconds);
exp.TryCollect(_player, _collectDistance);
}
}
}
public void OnReset()
{
if (_statComponent != null)
{
_statComponent.Unsubscribe(StatType.AbsorbRange, _absorbRangeStatCallback);
_absorbRangeStatCallback = null;
}
_statComponent = null;
_target = null;
_player = null;
_buffer = null;
}
private void AbsorbDrop(Transform drop, float deltaTime)
{
if (drop == null || _target == null) return;
drop.position = Vector3.MoveTowards(drop.position, _target.position, _absorbSpeed * deltaTime);
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 40941eb45ca7d284f8a806370b88fa78
guid: 46f46350fed64d8389ebb4ae72b65796
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,4 +1,4 @@
using System;
using System;
using CustomEvent;
using Definition.DataStruct;
using Definition.Enum;
@ -119,7 +119,9 @@ namespace Components
private void CauseDamage(int damage)
{
//TODO:受击效果:跳字、粒子
if (damage <= 0 || GameEntry.DamageText == null) return;
GameEntry.DamageText.ShowDamage(transform.position + Vector3.up * 1.1f, damage);
}
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6befdfdd5f3e430a864a90bf445000e8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,67 @@
using System.Collections.Generic;
using GameFramework.ObjectPool;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityGameFramework.Runtime;
namespace CustomComponent
{
public class DamageTextComponent : GameFrameworkComponent
{
[SerializeField] private int _instancePoolCapacity = 32;
[SerializeField] private string _poolName = "DamageTextItem";
[SerializeField] private RectTransform _instanceRoot;
[SerializeField] private Canvas _canvas;
[SerializeField] private GameObject _damageTextItemPrefab;
private IObjectPool<DamageTextItemObject> _damageTextItemPool;
private readonly List<DamageTextItem> _activeDamageTextItems = new();
private void Start()
{
_damageTextItemPool =
GameEntry.ObjectPool.CreateSingleSpawnObjectPool<DamageTextItemObject>(_poolName,
_instancePoolCapacity);
}
public void ShowDamage(Vector3 worldPosition, int damage)
{
if (damage <= 0 || _damageTextItemPool == null || _canvas == null) return;
DamageTextItem item = CreateDamageTextItem();
if (item == null) return;
item.Show(worldPosition, damage, _canvas, OnItemComplete);
_activeDamageTextItems.Add(item);
}
private DamageTextItem CreateDamageTextItem()
{
DamageTextItemObject itemObject = _damageTextItemPool.Spawn();
if (itemObject != null)
{
return (DamageTextItem)itemObject.Target;
}
GameObject itemGo = Instantiate(_damageTextItemPrefab, _instanceRoot, false);
DamageTextItem item = itemGo.GetComponent<DamageTextItem>();
_damageTextItemPool.Register(DamageTextItemObject.Create(item), true);
return item;
}
private void OnItemComplete(DamageTextItem item)
{
if (item == null) return;
item.ResetItem();
_activeDamageTextItems.Remove(item);
_damageTextItemPool.Unspawn(item);
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: f91ec109eb6c73a408325960701b4c94
guid: 366eb88b821a4048891b7fb01a1b8d42
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,80 @@
using System;
using DG.Tweening;
using TMPro;
using UnityEngine;
namespace CustomComponent
{
public class DamageTextItem : MonoBehaviour
{
private const float RiseDistance = 80f;
private const float RiseDuration = 0.55f;
private const float FadeDelay = 0.2f;
private const float FadeDuration = 0.35f;
private static readonly Color NormalColor = new Color(1f, 0.32f, 0.23f, 1f);
[SerializeField] private RectTransform _cachedTransform;
[SerializeField] private CanvasGroup _canvasGroup;
[SerializeField] private TMP_Text _text;
private Sequence _sequence;
private Action<DamageTextItem> _onComplete;
private void Awake()
{
if (_cachedTransform == null) _cachedTransform = GetComponent<RectTransform>();
if (_canvasGroup == null) _canvasGroup = GetComponent<CanvasGroup>();
if (_text == null) _text = GetComponent<TMP_Text>();
}
public void Show(Vector3 worldPosition, int damage, Canvas canvas, Action<DamageTextItem> onComplete)
{
if (canvas == null || GameEntry.Scene.MainCamera == null) return;
_onComplete = onComplete;
gameObject.SetActive(true);
KillSequence();
_canvasGroup.alpha = 1f;
_cachedTransform.localScale = Vector3.one;
_text.color = NormalColor;
_text.text = damage.ToString();
Vector3 screenPos = GameEntry.Scene.MainCamera.WorldToScreenPoint(worldPosition);
RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)canvas.transform, screenPos,
canvas.worldCamera, out Vector2 localPos);
localPos.x += UnityEngine.Random.Range(-24f, 24f);
_cachedTransform.anchoredPosition = localPos;
_sequence = DOTween.Sequence();
_sequence.Append(_cachedTransform.DOAnchorPosY(localPos.y + RiseDistance, RiseDuration)
.SetEase(Ease.OutQuad));
_sequence.Join(_cachedTransform.DOPunchScale(new Vector3(0.15f, 0.15f, 0f), 0.18f, 6, 0.75f));
_sequence.Join(_canvasGroup.DOFade(0f, FadeDuration).SetDelay(FadeDelay));
_sequence.OnComplete(() => _onComplete?.Invoke(this));
}
public void ResetItem()
{
KillSequence();
_onComplete = null;
_canvasGroup.alpha = 1f;
_text.text = string.Empty;
gameObject.SetActive(false);
}
private void OnDestroy()
{
KillSequence();
}
private void KillSequence()
{
if (_sequence == null) return;
_sequence.Kill();
_sequence = null;
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 7ddc8f13b2516c643a67d92a319dbf72
guid: 501e678f9cb14af6ac45e8d2050388d3
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,23 @@
using GameFramework;
using GameFramework.ObjectPool;
using UnityEngine;
namespace CustomComponent
{
public class DamageTextItemObject : ObjectBase
{
public static DamageTextItemObject Create(object target)
{
DamageTextItemObject itemObject = ReferencePool.Acquire<DamageTextItemObject>();
itemObject.Initialize(target);
return itemObject;
}
protected override void Release(bool isShutdown)
{
DamageTextItem item = (DamageTextItem)Target;
if (item == null) return;
Object.Destroy(item.gameObject);
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 00bc8bc968fa2134095a36a43f326d56
guid: 4aba1230dece448eba1fa7579ca7a13d
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a11ef2e359b24bfdb6c9120cc2ec81b8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,349 @@
#if UNITY_EDITOR || DEVELOPMENT_BUILD
using System;
using System.Linq;
using DataTable;
using Definition.DataStruct;
using Entity;
using Game.Utility;
using UnityEngine;
using UnityGameFramework.Runtime;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
namespace CustomComponent
{
public class RuntimeDebugPanelComponent : GameFrameworkComponent
{
private const float MinSpawnRate = 0.1f;
private const float CornerTapWindow = 0.6f;
private const int RequiredCornerTapCount = 3;
private Rect _windowRect = new Rect(20f, 60f, 460f, 620f);
private bool _isPanelVisible;
private int _windowId;
private string _searchText = string.Empty;
private int _selectedIndex;
private int _addCount = 1;
private Vector2 _buffScroll;
private float _spawnRateScaleInput = 1f;
private float _extendDurationSeconds = 30f;
private DRProp[] _allProps = Array.Empty<DRProp>();
private DRProp[] _filteredProps = Array.Empty<DRProp>();
private string[] _displayNames = Array.Empty<string>();
private int _cornerTapCount;
private float _lastCornerTapTime = -10f;
protected override void Awake()
{
base.Awake();
_windowId = GetInstanceID();
}
private void Update()
{
if (IsTogglePressed())
{
_isPanelVisible = !_isPanelVisible;
}
HandleCornerTapGesture();
}
private void OnGUI()
{
DrawToggleButton();
if (!_isPanelVisible) return;
_windowRect = GUI.Window(_windowId, _windowRect, DrawWindow, "Runtime Debug Panel");
}
private void DrawToggleButton()
{
const float width = 64f;
const float height = 30f;
Rect buttonRect = new Rect(Screen.width - width - 12f, 10f, width, height);
if (GUI.Button(buttonRect, "DEBUG"))
{
_isPanelVisible = !_isPanelVisible;
}
}
private void DrawWindow(int windowId)
{
EnsurePropList();
GUILayout.BeginVertical();
DrawBuffSection();
GUILayout.Space(8f);
GUILayout.Label(string.Empty, GUI.skin.horizontalSlider);
GUILayout.Space(8f);
DrawBattleSection();
GUILayout.Space(8f);
GUILayout.Label("Tips: press `F8` or tap top-left corner 3 times to toggle.", GUILayout.Height(20f));
GUILayout.EndVertical();
GUI.DragWindow(new Rect(0, 0, 10000, 22));
}
private void DrawBuffSection()
{
GUILayout.Label("Buff Debug");
GUILayout.BeginHorizontal();
GUILayout.Label("Search", GUILayout.Width(52f));
_searchText = GUILayout.TextField(_searchText);
if (GUILayout.Button("Refresh", GUILayout.Width(80f)))
{
EnsurePropList(true);
}
GUILayout.EndHorizontal();
ApplyFilter(_searchText);
if (_displayNames.Length == 0)
{
GUILayout.Label("No Buff data. Enter battle and try again.");
return;
}
_selectedIndex = Mathf.Clamp(_selectedIndex, 0, _displayNames.Length - 1);
_buffScroll = GUILayout.BeginScrollView(_buffScroll, GUILayout.Height(120f));
_selectedIndex = GUILayout.SelectionGrid(_selectedIndex, _displayNames, 1);
GUILayout.EndScrollView();
DRProp selectedProp = GetSelectedProp();
if (selectedProp == null) return;
GUILayout.Label($"Selected: {selectedProp.Title} ({selectedProp.Rarity})");
GUILayout.Label(ItemDescUtility.CreatePropDescription(selectedProp.Modifiers), GUILayout.Height(40f));
GUILayout.BeginHorizontal();
GUILayout.Label("Count", GUILayout.Width(52f));
string addCountText = GUILayout.TextField(_addCount.ToString(), GUILayout.Width(60f));
if (!int.TryParse(addCountText, out _addCount)) _addCount = 1;
_addCount = Mathf.Clamp(_addCount, 1, 99);
if (GUILayout.Button("Add Buff To Player", GUILayout.Height(24f)))
{
AddSelectedBuffToPlayer(selectedProp, _addCount);
}
GUILayout.EndHorizontal();
}
private void DrawBattleSection()
{
GUILayout.Label("Battle Debug");
EnemyManagerComponent enemyManager = GameEntry.EnemyManager;
Player player = FindPlayer();
if (enemyManager == null)
{
GUILayout.Label("EnemyManager unavailable.");
return;
}
GUILayout.Label($"Spawn Rate: {enemyManager.SpawnRateScale:F2}");
GUILayout.Label($"Battle Time: {enemyManager.ElapsedBattleTime:F1}s / {enemyManager.BattleDuration:F1}s");
GUILayout.BeginHorizontal();
GUILayout.Label("Rate", GUILayout.Width(52f));
string rateText = GUILayout.TextField(_spawnRateScaleInput.ToString("F2"), GUILayout.Width(60f));
if (float.TryParse(rateText, out float parsedRate))
{
_spawnRateScaleInput = Mathf.Clamp(parsedRate, MinSpawnRate, 50f);
}
if (GUILayout.Button("Apply", GUILayout.Width(70f)))
{
enemyManager.SetSpawnRateScale(_spawnRateScaleInput);
}
if (GUILayout.Button("x0.5", GUILayout.Width(60f)))
{
_spawnRateScaleInput = Mathf.Max(MinSpawnRate, enemyManager.SpawnRateScale * 0.5f);
enemyManager.SetSpawnRateScale(_spawnRateScaleInput);
}
if (GUILayout.Button("x2", GUILayout.Width(60f)))
{
_spawnRateScaleInput = enemyManager.SpawnRateScale * 2f;
enemyManager.SetSpawnRateScale(_spawnRateScaleInput);
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Add Sec", GUILayout.Width(52f));
string durationText = GUILayout.TextField(_extendDurationSeconds.ToString("F0"), GUILayout.Width(60f));
if (float.TryParse(durationText, out float parsedDuration))
{
_extendDurationSeconds = Mathf.Clamp(parsedDuration, 1f, 3600f);
}
if (GUILayout.Button("Extend Battle", GUILayout.Height(24f)))
{
enemyManager.AddBattleDuration(_extendDurationSeconds);
}
GUILayout.EndHorizontal();
GUILayout.Label($"Player Weapon: {(player == null ? "Player not found" : (player.WeaponEnabled ? "Enabled" : "Disabled"))}");
GUILayout.BeginHorizontal();
GUI.enabled = player != null;
if (GUILayout.Button("Disable Weapons", GUILayout.Height(24f)))
{
player.SetWeaponEnabled(false);
}
if (GUILayout.Button("Enable Weapons", GUILayout.Height(24f)))
{
player.SetWeaponEnabled(true);
}
GUI.enabled = true;
GUILayout.EndHorizontal();
}
private void EnsurePropList(bool force = false)
{
if (!force && _allProps != null && _allProps.Length > 0) return;
if (GameEntry.DataTable == null)
{
_allProps = Array.Empty<DRProp>();
_filteredProps = Array.Empty<DRProp>();
_displayNames = Array.Empty<string>();
return;
}
var table = GameEntry.DataTable.GetDataTable<DRProp>();
_allProps = table != null ? table.ToArray() : Array.Empty<DRProp>();
_selectedIndex = Mathf.Clamp(_selectedIndex, 0, Mathf.Max(0, _allProps.Length - 1));
ApplyFilter(_searchText);
}
private void ApplyFilter(string keyword)
{
if (_allProps == null || _allProps.Length == 0)
{
_filteredProps = Array.Empty<DRProp>();
_displayNames = Array.Empty<string>();
return;
}
if (string.IsNullOrWhiteSpace(keyword))
{
_filteredProps = _allProps;
}
else
{
string search = keyword.Trim();
_filteredProps = _allProps.Where(p =>
p != null &&
(p.Title?.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 ||
p.Id.ToString().Contains(search))).ToArray();
}
_displayNames = _filteredProps.Select(p => $"[{p.Id}] {p.Title} ({p.Rarity})").ToArray();
if (_displayNames.Length == 0) _selectedIndex = 0;
else _selectedIndex = Mathf.Clamp(_selectedIndex, 0, _displayNames.Length - 1);
}
private DRProp GetSelectedProp()
{
if (_filteredProps == null || _filteredProps.Length == 0) return null;
_selectedIndex = Mathf.Clamp(_selectedIndex, 0, _filteredProps.Length - 1);
return _filteredProps[_selectedIndex];
}
private static Player FindPlayer()
{
return UnityEngine.Object.FindObjectOfType<Player>();
}
private static void AddSelectedBuffToPlayer(DRProp prop, int count)
{
Player player = FindPlayer();
if (player == null || prop == null || prop.Modifiers == null) return;
int applyCount = Mathf.Clamp(count, 1, 99);
for (int i = 0; i < applyCount; i++)
{
player.AddProp(new PropItem(prop.Modifiers, prop.Rarity, prop.Title, prop.IconAssetName));
}
}
private void HandleCornerTapGesture()
{
if (!TryGetTouchReleased(out Vector2 touchPosition)) return;
if (touchPosition.x > 80f || touchPosition.y < Screen.height - 80f) return;
float now = Time.unscaledTime;
if (now - _lastCornerTapTime > CornerTapWindow)
{
_cornerTapCount = 0;
}
_lastCornerTapTime = now;
_cornerTapCount++;
if (_cornerTapCount >= RequiredCornerTapCount)
{
_cornerTapCount = 0;
_isPanelVisible = !_isPanelVisible;
}
}
private static bool IsTogglePressed()
{
#if ENABLE_INPUT_SYSTEM
Keyboard keyboard = Keyboard.current;
if (keyboard == null) return false;
return keyboard.backquoteKey.wasPressedThisFrame || keyboard.f8Key.wasPressedThisFrame;
#else
return Input.GetKeyDown(KeyCode.BackQuote) || Input.GetKeyDown(KeyCode.F8);
#endif
}
private static bool TryGetTouchReleased(out Vector2 touchPosition)
{
#if ENABLE_INPUT_SYSTEM
Touchscreen touchscreen = Touchscreen.current;
if (touchscreen == null)
{
touchPosition = default;
return false;
}
var touch = touchscreen.primaryTouch;
if (!touch.press.wasReleasedThisFrame)
{
touchPosition = default;
return false;
}
touchPosition = touch.position.ReadValue();
return true;
#else
if (Input.touchCount <= 0)
{
touchPosition = default;
return false;
}
Touch touch = Input.GetTouch(0);
if (touch.phase != TouchPhase.Ended)
{
touchPosition = default;
return false;
}
touchPosition = touch.position;
return true;
#endif
}
}
}
#endif

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d8ada5157a04921a6e543a040e57960
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -13,6 +13,8 @@ namespace CustomComponent
{
public class EnemyManagerComponent : GameFrameworkComponent
{
private const float MinSpawnRateScale = 0.1f;
private EntityComponent _entity;
private List<EntityBase> _enemies;
@ -20,23 +22,35 @@ namespace CustomComponent
public List<EntityBase> Enemies => _enemies;
private float _spawnEnemyTimer;
private int _spawnEnemyMaxCount = 5000;
private int _currentEnemyCount;
private int _spawnDistanceFromPlayer = 20;
private int _currentSpawnEnemyId;
private int _currentLevel;
private float[] _baseSpawnEnemyIntervals;
private float[] _spawnEnemyIntervals;
private int[] _spawnEnemyIds;
private int[] _spawnEnemyCounts;
private float _duration;
private float _baseDuration;
private float[] _nextSpawnTimes;
private float _spawnRateScale = 1f;
private Transform _player;
private GameStateBattle _battle;
public float SpawnRateScale => _spawnRateScale;
public float BattleDuration => _duration;
public float ElapsedBattleTime => _spawnEnemyTimer;
#region FSM
private void Start()
@ -64,12 +78,14 @@ namespace CustomComponent
_currentLevel = level;
DRLevel levelData = GameEntry.DataTable.GetDataTableRow<DRLevel>(_currentLevel);
_spawnEnemyIntervals = levelData.Intervals;
_baseSpawnEnemyIntervals = (float[])levelData.Intervals.Clone();
_spawnEnemyIntervals = (float[])_baseSpawnEnemyIntervals.Clone();
_spawnEnemyIds = levelData.EntityIds;
_spawnEnemyCounts = levelData.EntityCounts;
_duration = levelData.Duration;
_baseDuration = levelData.Duration;
_duration = _baseDuration;
_nextSpawnTimes = (float[])_spawnEnemyIntervals.Clone();
SetSpawnRateScale(_spawnRateScale);
_currentSpawnEnemyId = 0;
}
@ -77,10 +93,7 @@ namespace CustomComponent
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
{
_spawnEnemyTimer += elapseSeconds;
// if (_spawnEnemyTimer < _spawnEnemyInterval) return;
// SpawnEnemy();
// _spawnEnemyTimer = 0;
// _spawnEnemyInterval = Mathf.Max(0.1f, _spawnEnemyInterval - _spawnEnemyAccelerate);
if (_spawnEnemyTimer > _duration)
{
_battle.LevelOver();
@ -108,9 +121,11 @@ namespace CustomComponent
_currentSpawnEnemyId = 0;
_currentLevel = 0;
_baseSpawnEnemyIntervals = null;
_spawnEnemyIntervals = null;
_spawnEnemyIds = null;
_spawnEnemyCounts = null;
_baseDuration = 0;
_duration = 0;
_nextSpawnTimes = null;
@ -120,6 +135,57 @@ namespace CustomComponent
ClearEnemies();
}
public void SetSpawnRateScale(float scale)
{
float newScale = Mathf.Max(MinSpawnRateScale, scale);
if (_baseSpawnEnemyIntervals == null || _baseSpawnEnemyIntervals.Length == 0)
{
_spawnRateScale = newScale;
return;
}
bool hasRuntimeState = _nextSpawnTimes != null && _spawnEnemyIntervals != null &&
_nextSpawnTimes.Length == _baseSpawnEnemyIntervals.Length &&
_spawnEnemyIntervals.Length == _baseSpawnEnemyIntervals.Length;
float oldScale = _spawnRateScale;
_spawnRateScale = newScale;
if (!hasRuntimeState)
{
for (int i = 0; i < _baseSpawnEnemyIntervals.Length; i++)
{
_spawnEnemyIntervals[i] = GetScaledInterval(_baseSpawnEnemyIntervals[i], _spawnRateScale);
}
_nextSpawnTimes = (float[])_spawnEnemyIntervals.Clone();
return;
}
for (int i = 0; i < _baseSpawnEnemyIntervals.Length; i++)
{
float oldInterval = GetScaledInterval(_baseSpawnEnemyIntervals[i], oldScale);
float newInterval = GetScaledInterval(_baseSpawnEnemyIntervals[i], _spawnRateScale);
float remainTime = Mathf.Max(0f, _nextSpawnTimes[i] - _spawnEnemyTimer);
float remainRatio = oldInterval > Mathf.Epsilon ? Mathf.Clamp01(remainTime / oldInterval) : 0f;
_spawnEnemyIntervals[i] = newInterval;
_nextSpawnTimes[i] = _spawnEnemyTimer + newInterval * remainRatio;
}
}
public void AddBattleDuration(float seconds)
{
if (seconds <= 0f) return;
_duration += seconds;
}
private static float GetScaledInterval(float baseInterval, float scale)
{
float safeScale = Mathf.Max(MinSpawnRateScale, scale);
return baseInterval / safeScale;
}
#endregion
private void SpawnEnemy(int entityId)
@ -128,7 +194,7 @@ namespace CustomComponent
if (_currentEnemyCount >= _spawnEnemyMaxCount) return;
int entityPoolId = _currentSpawnEnemyId % _spawnEnemyMaxCount;
var enemyData = new EnemyData(entityPoolId, entityId)
var enemyData = new EnemyData(entityPoolId, entityId, _currentLevel)
{
Position = GetRandomPosition()
};
@ -187,4 +253,4 @@ namespace CustomComponent
#endregion
}
}
}

View File

@ -17,14 +17,11 @@ namespace CustomComponent
{
public class HPBarComponent : GameFrameworkComponent
{
[FormerlySerializedAs("m_HPBarItemTemplate")] [SerializeField]
private HPBarItem _hpBarItemTemplate = null;
[SerializeField] private HPBarItem _hpBarItemTemplate = null;
[FormerlySerializedAs("m_HPBarInstanceRoot")] [SerializeField]
private Transform _hpBarInstanceRoot = null;
[SerializeField] private Transform _hpBarInstanceRoot = null;
[FormerlySerializedAs("m_InstancePoolCapacity")] [SerializeField]
private int _instancePoolCapacity = 16;
[SerializeField] private int _instancePoolCapacity = 16;
private IObjectPool<HPBarItemObject> _hpBarItemObjectPool = null;
private List<HPBarItem> _activeHPBarItems = null;
@ -39,7 +36,8 @@ namespace CustomComponent
}
_cachedCanvas = _hpBarInstanceRoot.GetComponent<Canvas>();
_hpBarItemObjectPool = GameEntry.ObjectPool.CreateSingleSpawnObjectPool<HPBarItemObject>("HPBarItem", _instancePoolCapacity);
_hpBarItemObjectPool =
GameEntry.ObjectPool.CreateSingleSpawnObjectPool<HPBarItemObject>("HPBarItem", _instancePoolCapacity);
_activeHPBarItems = new List<HPBarItem>();
}
@ -124,4 +122,4 @@ namespace CustomComponent
return hpBarItem;
}
}
}
}

View File

@ -7,6 +7,7 @@ namespace DataTable
private int m_id;
public override int Id => m_id;
public int MaxHealth { get; private set; }
public int HpAddPerLevel { get; private set; }
public float Speed { get; private set; }
public int DropCoin { get; private set; }
public int DropExp { get; private set; }
@ -21,6 +22,7 @@ namespace DataTable
m_id = int.Parse(columnStrings[index++]);
index++;
MaxHealth = int.Parse(columnStrings[index++]);
HpAddPerLevel = int.Parse(columnStrings[index++]);
Speed = float.Parse(columnStrings[index++]);
DropCoin = int.Parse(columnStrings[index++]);
DropExp = int.Parse(columnStrings[index++]);
@ -29,4 +31,4 @@ namespace DataTable
return true;
}
}
}
}

View File

@ -0,0 +1,39 @@
using UnityGameFramework.Runtime;
namespace DataTable
{
public class DRLevelRarity : DataRowBase
{
private int m_Id;
public override int Id => m_Id;
public int LevelMin { get; private set; }
public int LevelMax { get; private set; }
public int WhiteWeight { get; private set; }
public int GreenWeight { get; private set; }
public int BlueWeight { get; private set; }
public int PurpleWeight { get; private set; }
public int RedWeight { get; private set; }
public override bool ParseDataRow(string dataRowString, object userData)
{
string[] fields = dataRowString.Split(DataTableExtension.DataSplitSeparators);
int index = 0;
index++;
m_Id = int.Parse(fields[index++]);
index++;
LevelMin = int.Parse(fields[index++]);
LevelMax = int.Parse(fields[index++]);
WhiteWeight = int.Parse(fields[index++]);
GreenWeight = int.Parse(fields[index++]);
BlueWeight = int.Parse(fields[index++]);
PurpleWeight = int.Parse(fields[index++]);
RedWeight = int.Parse(fields[index++]);
return true;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2be3a3c9896a441496abfb07467e9e19
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,7 @@
using Definition.DataStruct;
using Definition.Enum;
using Newtonsoft.Json;
using StarForce;
using UnityGameFramework.Runtime;
namespace DataTable
@ -13,6 +15,8 @@ namespace DataTable
public string Title { get; private set; }
public string IconAssetName { get; private set; }
public ItemRarity Rarity { get; private set; }
public StatModifier[] Modifiers { get; private set; }
@ -26,6 +30,7 @@ namespace DataTable
index++;
Title = fields[index++];
IconAssetName = fields[index++];
Rarity = EnumUtility<ItemRarity>.Get(fields[index++]);
Modifiers = JsonConvert.DeserializeObject<StatModifier[]>(fields[index++]);
return true;

View File

@ -16,6 +16,7 @@ namespace Definition.DataStruct
// Critical = 6,
// CriticalDamage = 7,
// Dodge = 8,
// AbsorbRange = 9
private readonly string[] _statTypeNames =
{
@ -27,7 +28,8 @@ namespace Definition.DataStruct
"冷却",
"暴击率",
"暴击伤害",
"闪避"
"闪避",
"金币/经验吸收范围"
};
public StatType StatType;

View File

@ -3,7 +3,7 @@ namespace Definition.Enum
public enum StatType
{
None = 0,
MaxHealth = 1,
MovementSpeed = 2,
Attack = 3,
@ -12,5 +12,6 @@ namespace Definition.Enum
Critical = 6,
CriticalDamage = 7,
Dodge = 8,
AbsorbRange = 9,
}
}
}

View File

@ -1,13 +0,0 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System.Text;
namespace StarForce.Editor.DataTableTools
{
public delegate void DataTableCodeGenerator(DataTableProcessor dataTableProcessor, StringBuilder codeContent, object userData);
}

View File

@ -1,412 +0,0 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using GameFramework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
namespace StarForce.Editor.DataTableTools
{
public sealed class DataTableGenerator
{
private const string DataTablePath = "Assets/GameMain/DataTables";
private const string CSharpCodePath = "Assets/GameMain/Scripts/DataTable";
private const string CSharpCodeTemplateFileName = "Assets/GameMain/Configs/DataTableCodeTemplate.txt";
private static readonly Regex EndWithNumberRegex = new Regex(@"\d+$");
private static readonly Regex NameRegex = new Regex(@"^[A-Z][A-Za-z0-9_]*$");
public static DataTableProcessor CreateDataTableProcessor(string dataTableName)
{
return new DataTableProcessor(Utility.Path.GetRegularPath(Path.Combine(DataTablePath, dataTableName + ".txt")), Encoding.GetEncoding("GB2312"), 1, 2, null, 3, 4, 1);
}
public static bool CheckRawData(DataTableProcessor dataTableProcessor, string dataTableName)
{
for (int i = 0; i < dataTableProcessor.RawColumnCount; i++)
{
string name = dataTableProcessor.GetName(i);
if (string.IsNullOrEmpty(name) || name == "#")
{
continue;
}
if (!NameRegex.IsMatch(name))
{
Debug.LogWarning(Utility.Text.Format("Check raw data failure. DataTableName='{0}' Name='{1}'", dataTableName, name));
return false;
}
}
return true;
}
public static void GenerateDataFile(DataTableProcessor dataTableProcessor, string dataTableName)
{
string binaryDataFileName = Utility.Path.GetRegularPath(Path.Combine(DataTablePath, dataTableName + ".bytes"));
if (!dataTableProcessor.GenerateDataFile(binaryDataFileName) && File.Exists(binaryDataFileName))
{
File.Delete(binaryDataFileName);
}
}
public static void GenerateCodeFile(DataTableProcessor dataTableProcessor, string dataTableName)
{
dataTableProcessor.SetCodeTemplate(CSharpCodeTemplateFileName, Encoding.UTF8);
dataTableProcessor.SetCodeGenerator(DataTableCodeGenerator);
string csharpCodeFileName = Utility.Path.GetRegularPath(Path.Combine(CSharpCodePath, "DR" + dataTableName + ".cs"));
if (!dataTableProcessor.GenerateCodeFile(csharpCodeFileName, Encoding.UTF8, dataTableName) && File.Exists(csharpCodeFileName))
{
File.Delete(csharpCodeFileName);
}
}
private static void DataTableCodeGenerator(DataTableProcessor dataTableProcessor, StringBuilder codeContent, object userData)
{
string dataTableName = (string)userData;
codeContent.Replace("__DATA_TABLE_CREATE_TIME__", DateTime.UtcNow.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss.fff"));
codeContent.Replace("__DATA_TABLE_NAME_SPACE__", "StarForce");
codeContent.Replace("__DATA_TABLE_CLASS_NAME__", "DR" + dataTableName);
codeContent.Replace("__DATA_TABLE_COMMENT__", dataTableProcessor.GetValue(0, 1) + "。");
codeContent.Replace("__DATA_TABLE_ID_COMMENT__", "获取" + dataTableProcessor.GetComment(dataTableProcessor.IdColumn) + "。");
codeContent.Replace("__DATA_TABLE_PROPERTIES__", GenerateDataTableProperties(dataTableProcessor));
codeContent.Replace("__DATA_TABLE_PARSER__", GenerateDataTableParser(dataTableProcessor));
codeContent.Replace("__DATA_TABLE_PROPERTY_ARRAY__", GenerateDataTablePropertyArray(dataTableProcessor));
}
private static string GenerateDataTableProperties(DataTableProcessor dataTableProcessor)
{
StringBuilder stringBuilder = new StringBuilder();
bool firstProperty = true;
for (int i = 0; i < dataTableProcessor.RawColumnCount; i++)
{
if (dataTableProcessor.IsCommentColumn(i))
{
// 注释列
continue;
}
if (dataTableProcessor.IsIdColumn(i))
{
// 编号列
continue;
}
if (firstProperty)
{
firstProperty = false;
}
else
{
stringBuilder.AppendLine().AppendLine();
}
stringBuilder
.AppendLine(" /// <summary>")
.AppendFormat(" /// 获取{0}。", dataTableProcessor.GetComment(i)).AppendLine()
.AppendLine(" /// </summary>")
.AppendFormat(" public {0} {1}", dataTableProcessor.GetLanguageKeyword(i), dataTableProcessor.GetName(i)).AppendLine()
.AppendLine(" {")
.AppendLine(" get;")
.AppendLine(" private set;")
.Append(" }");
}
return stringBuilder.ToString();
}
private static string GenerateDataTableParser(DataTableProcessor dataTableProcessor)
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder
.AppendLine(" public override bool ParseDataRow(string dataRowString, object userData)")
.AppendLine(" {")
.AppendLine(" string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);")
.AppendLine(" for (int i = 0; i < columnStrings.Length; i++)")
.AppendLine(" {")
.AppendLine(" columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);")
.AppendLine(" }")
.AppendLine()
.AppendLine(" int index = 0;");
for (int i = 0; i < dataTableProcessor.RawColumnCount; i++)
{
if (dataTableProcessor.IsCommentColumn(i))
{
// 注释列
stringBuilder.AppendLine(" index++;");
continue;
}
if (dataTableProcessor.IsIdColumn(i))
{
// 编号列
stringBuilder.AppendLine(" m_Id = int.Parse(columnStrings[index++]);");
continue;
}
if (dataTableProcessor.IsSystem(i))
{
string languageKeyword = dataTableProcessor.GetLanguageKeyword(i);
if (languageKeyword == "string")
{
stringBuilder.AppendFormat(" {0} = columnStrings[index++];", dataTableProcessor.GetName(i)).AppendLine();
}
else
{
stringBuilder.AppendFormat(" {0} = {1}.Parse(columnStrings[index++]);", dataTableProcessor.GetName(i), languageKeyword).AppendLine();
}
}
else
{
stringBuilder.AppendFormat(" {0} = DataTableExtension.Parse{1}(columnStrings[index++]);", dataTableProcessor.GetName(i), dataTableProcessor.GetType(i).Name).AppendLine();
}
}
stringBuilder.AppendLine()
.AppendLine(" GeneratePropertyArray();")
.AppendLine(" return true;")
.AppendLine(" }")
.AppendLine()
.AppendLine(" public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)")
.AppendLine(" {")
.AppendLine(" using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))")
.AppendLine(" {")
.AppendLine(" using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))")
.AppendLine(" {");
for (int i = 0; i < dataTableProcessor.RawColumnCount; i++)
{
if (dataTableProcessor.IsCommentColumn(i))
{
// 注释列
continue;
}
if (dataTableProcessor.IsIdColumn(i))
{
// 编号列
stringBuilder.AppendLine(" m_Id = binaryReader.Read7BitEncodedInt32();");
continue;
}
string languageKeyword = dataTableProcessor.GetLanguageKeyword(i);
if (languageKeyword == "int" || languageKeyword == "uint" || languageKeyword == "long" || languageKeyword == "ulong")
{
stringBuilder.AppendFormat(" {0} = binaryReader.Read7BitEncoded{1}();", dataTableProcessor.GetName(i), dataTableProcessor.GetType(i).Name).AppendLine();
}
else
{
stringBuilder.AppendFormat(" {0} = binaryReader.Read{1}();", dataTableProcessor.GetName(i), dataTableProcessor.GetType(i).Name).AppendLine();
}
}
stringBuilder
.AppendLine(" }")
.AppendLine(" }")
.AppendLine()
.AppendLine(" GeneratePropertyArray();")
.AppendLine(" return true;")
.Append(" }");
return stringBuilder.ToString();
}
private static string GenerateDataTablePropertyArray(DataTableProcessor dataTableProcessor)
{
List<PropertyCollection> propertyCollections = new List<PropertyCollection>();
for (int i = 0; i < dataTableProcessor.RawColumnCount; i++)
{
if (dataTableProcessor.IsCommentColumn(i))
{
// 注释列
continue;
}
if (dataTableProcessor.IsIdColumn(i))
{
// 编号列
continue;
}
string name = dataTableProcessor.GetName(i);
if (!EndWithNumberRegex.IsMatch(name))
{
continue;
}
string propertyCollectionName = EndWithNumberRegex.Replace(name, string.Empty);
int id = int.Parse(EndWithNumberRegex.Match(name).Value);
PropertyCollection propertyCollection = null;
foreach (PropertyCollection pc in propertyCollections)
{
if (pc.Name == propertyCollectionName)
{
propertyCollection = pc;
break;
}
}
if (propertyCollection == null)
{
propertyCollection = new PropertyCollection(propertyCollectionName, dataTableProcessor.GetLanguageKeyword(i));
propertyCollections.Add(propertyCollection);
}
propertyCollection.AddItem(id, name);
}
StringBuilder stringBuilder = new StringBuilder();
bool firstProperty = true;
foreach (PropertyCollection propertyCollection in propertyCollections)
{
if (firstProperty)
{
firstProperty = false;
}
else
{
stringBuilder.AppendLine().AppendLine();
}
stringBuilder
.AppendFormat(" private KeyValuePair<int, {1}>[] m_{0} = null;", propertyCollection.Name, propertyCollection.LanguageKeyword).AppendLine()
.AppendLine()
.AppendFormat(" public int {0}Count", propertyCollection.Name).AppendLine()
.AppendLine(" {")
.AppendLine(" get")
.AppendLine(" {")
.AppendFormat(" return m_{0}.Length;", propertyCollection.Name).AppendLine()
.AppendLine(" }")
.AppendLine(" }")
.AppendLine()
.AppendFormat(" public {1} Get{0}(int id)", propertyCollection.Name, propertyCollection.LanguageKeyword).AppendLine()
.AppendLine(" {")
.AppendFormat(" foreach (KeyValuePair<int, {1}> i in m_{0})", propertyCollection.Name, propertyCollection.LanguageKeyword).AppendLine()
.AppendLine(" {")
.AppendLine(" if (i.Key == id)")
.AppendLine(" {")
.AppendLine(" return i.Value;")
.AppendLine(" }")
.AppendLine(" }")
.AppendLine()
.AppendFormat(" throw new GameFrameworkException(Utility.Text.Format(\"Get{0} with invalid id '{{0}}'.\", id));", propertyCollection.Name).AppendLine()
.AppendLine(" }")
.AppendLine()
.AppendFormat(" public {1} Get{0}At(int index)", propertyCollection.Name, propertyCollection.LanguageKeyword).AppendLine()
.AppendLine(" {")
.AppendFormat(" if (index < 0 || index >= m_{0}.Length)", propertyCollection.Name).AppendLine()
.AppendLine(" {")
.AppendFormat(" throw new GameFrameworkException(Utility.Text.Format(\"Get{0}At with invalid index '{{0}}'.\", index));", propertyCollection.Name).AppendLine()
.AppendLine(" }")
.AppendLine()
.AppendFormat(" return m_{0}[index].Value;", propertyCollection.Name).AppendLine()
.Append(" }");
}
if (propertyCollections.Count > 0)
{
stringBuilder.AppendLine().AppendLine();
}
stringBuilder
.AppendLine(" private void GeneratePropertyArray()")
.AppendLine(" {");
firstProperty = true;
foreach (PropertyCollection propertyCollection in propertyCollections)
{
if (firstProperty)
{
firstProperty = false;
}
else
{
stringBuilder.AppendLine().AppendLine();
}
stringBuilder
.AppendFormat(" m_{0} = new KeyValuePair<int, {1}>[]", propertyCollection.Name, propertyCollection.LanguageKeyword).AppendLine()
.AppendLine(" {");
int itemCount = propertyCollection.ItemCount;
for (int i = 0; i < itemCount; i++)
{
KeyValuePair<int, string> item = propertyCollection.GetItem(i);
stringBuilder.AppendFormat(" new KeyValuePair<int, {0}>({1}, {2}),", propertyCollection.LanguageKeyword, item.Key.ToString(), item.Value).AppendLine();
}
stringBuilder.Append(" };");
}
stringBuilder
.AppendLine()
.Append(" }");
return stringBuilder.ToString();
}
private sealed class PropertyCollection
{
private readonly string m_Name;
private readonly string m_LanguageKeyword;
private readonly List<KeyValuePair<int, string>> m_Items;
public PropertyCollection(string name, string languageKeyword)
{
m_Name = name;
m_LanguageKeyword = languageKeyword;
m_Items = new List<KeyValuePair<int, string>>();
}
public string Name
{
get
{
return m_Name;
}
}
public string LanguageKeyword
{
get
{
return m_LanguageKeyword;
}
}
public int ItemCount
{
get
{
return m_Items.Count;
}
}
public KeyValuePair<int, string> GetItem(int index)
{
if (index < 0 || index >= m_Items.Count)
{
throw new GameFrameworkException(Utility.Text.Format("GetItem with invalid index '{0}'.", index));
}
return m_Items[index];
}
public void AddItem(int id, string propertyName)
{
m_Items.Add(new KeyValuePair<int, string>(id, propertyName));
}
}
}
}

View File

@ -1,36 +0,0 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using GameFramework;
using Procedure;
using UnityEditor;
using UnityEngine;
namespace StarForce.Editor.DataTableTools
{
public sealed class DataTableGeneratorMenu
{
[MenuItem("Star Force/Generate DataTables")]
private static void GenerateDataTables()
{
foreach (string dataTableName in ProcedurePreload.DataTableNames)
{
DataTableProcessor dataTableProcessor = DataTableGenerator.CreateDataTableProcessor(dataTableName);
if (!DataTableGenerator.CheckRawData(dataTableProcessor, dataTableName))
{
Debug.LogError(Utility.Text.Format("Check raw data failure. DataTableName='{0}'", dataTableName));
break;
}
DataTableGenerator.GenerateDataFile(dataTableProcessor, dataTableName);
DataTableGenerator.GenerateCodeFile(dataTableProcessor, dataTableName);
}
AssetDatabase.Refresh();
}
}
}

View File

@ -1,53 +0,0 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System.IO;
namespace StarForce.Editor.DataTableTools
{
public sealed partial class DataTableProcessor
{
private sealed class BooleanProcessor : GenericDataProcessor<bool>
{
public override bool IsSystem
{
get
{
return true;
}
}
public override string LanguageKeyword
{
get
{
return "bool";
}
}
public override string[] GetTypeStrings()
{
return new string[]
{
"bool",
"boolean",
"system.boolean"
};
}
public override bool Parse(string value)
{
return bool.Parse(value);
}
public override void WriteToStream(DataTableProcessor dataTableProcessor, BinaryWriter binaryWriter, string value)
{
binaryWriter.Write(Parse(value));
}
}
}
}

View File

@ -1,52 +0,0 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System.IO;
namespace StarForce.Editor.DataTableTools
{
public sealed partial class DataTableProcessor
{
private sealed class ByteProcessor : GenericDataProcessor<byte>
{
public override bool IsSystem
{
get
{
return true;
}
}
public override string LanguageKeyword
{
get
{
return "byte";
}
}
public override string[] GetTypeStrings()
{
return new string[]
{
"byte",
"system.byte"
};
}
public override byte Parse(string value)
{
return byte.Parse(value);
}
public override void WriteToStream(DataTableProcessor dataTableProcessor, BinaryWriter binaryWriter, string value)
{
binaryWriter.Write(Parse(value));
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 11199a40fe5a3ef49a3c3d1ae670ac97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,52 +0,0 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System.IO;
namespace StarForce.Editor.DataTableTools
{
public sealed partial class DataTableProcessor
{
private sealed class CharProcessor : GenericDataProcessor<char>
{
public override bool IsSystem
{
get
{
return true;
}
}
public override string LanguageKeyword
{
get
{
return "char";
}
}
public override string[] GetTypeStrings()
{
return new string[]
{
"char",
"system.char"
};
}
public override char Parse(string value)
{
return char.Parse(value);
}
public override void WriteToStream(DataTableProcessor dataTableProcessor, BinaryWriter binaryWriter, string value)
{
binaryWriter.Write(Parse(value));
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 37f1181bc8fb29742b06ec3f42f652b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,58 +0,0 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System.IO;
using UnityEngine;
namespace StarForce.Editor.DataTableTools
{
public sealed partial class DataTableProcessor
{
private sealed class Color32Processor : GenericDataProcessor<Color32>
{
public override bool IsSystem
{
get
{
return false;
}
}
public override string LanguageKeyword
{
get
{
return "Color32";
}
}
public override string[] GetTypeStrings()
{
return new string[]
{
"color32",
"unityengine.color32"
};
}
public override Color32 Parse(string value)
{
string[] splitedValue = value.Split(',');
return new Color32(byte.Parse(splitedValue[0]), byte.Parse(splitedValue[1]), byte.Parse(splitedValue[2]), byte.Parse(splitedValue[3]));
}
public override void WriteToStream(DataTableProcessor dataTableProcessor, BinaryWriter binaryWriter, string value)
{
Color32 color32 = Parse(value);
binaryWriter.Write(color32.r);
binaryWriter.Write(color32.g);
binaryWriter.Write(color32.b);
binaryWriter.Write(color32.a);
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 2a9b916d7c8e446439b74c27340be473
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,58 +0,0 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System.IO;
using UnityEngine;
namespace StarForce.Editor.DataTableTools
{
public sealed partial class DataTableProcessor
{
private sealed class ColorProcessor : GenericDataProcessor<Color>
{
public override bool IsSystem
{
get
{
return false;
}
}
public override string LanguageKeyword
{
get
{
return "Color";
}
}
public override string[] GetTypeStrings()
{
return new string[]
{
"color",
"unityengine.color"
};
}
public override Color Parse(string value)
{
string[] splitedValue = value.Split(',');
return new Color(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]), float.Parse(splitedValue[2]), float.Parse(splitedValue[3]));
}
public override void WriteToStream(DataTableProcessor dataTableProcessor, BinaryWriter binaryWriter, string value)
{
Color color = Parse(value);
binaryWriter.Write(color.r);
binaryWriter.Write(color.g);
binaryWriter.Write(color.b);
binaryWriter.Write(color.a);
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f4583af9902c99a4fad14d732796117e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,71 +0,0 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System.IO;
namespace StarForce.Editor.DataTableTools
{
public sealed partial class DataTableProcessor
{
private sealed class CommentProcessor : DataProcessor
{
public override System.Type Type
{
get
{
return null;
}
}
public override bool IsId
{
get
{
return false;
}
}
public override bool IsComment
{
get
{
return true;
}
}
public override bool IsSystem
{
get
{
return false;
}
}
public override string LanguageKeyword
{
get
{
return null;
}
}
public override string[] GetTypeStrings()
{
return new string[]
{
string.Empty,
"#",
"comment"
};
}
public override void WriteToStream(DataTableProcessor dataTableProcessor, BinaryWriter binaryWriter, string value)
{
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 2ece238877c1e9344a50ce47697a93ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,46 +0,0 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System.IO;
namespace StarForce.Editor.DataTableTools
{
public sealed partial class DataTableProcessor
{
public abstract class DataProcessor
{
public abstract System.Type Type
{
get;
}
public abstract bool IsId
{
get;
}
public abstract bool IsComment
{
get;
}
public abstract bool IsSystem
{
get;
}
public abstract string LanguageKeyword
{
get;
}
public abstract string[] GetTypeStrings();
public abstract void WriteToStream(DataTableProcessor dataTableProcessor, BinaryWriter binaryWriter, string value);
}
}
}

Some files were not shown because too many files have changed in this diff Show More