Compare commits

..
Author SHA1 Message Date
Jiaqi Liu 7727a55366 Upgrade Unity version 2024-04-25 17:59:14 -07:00
Jiaqi Liu 795fb3d576 WIP 2024-04-25 02:50:11 -07:00
222 changed files with 2104 additions and 50477 deletions

No files matched your search

@@ -21,11 +21,11 @@ jobs:
large-packages: true
docker-images: true
swap-storage: true
- uses: actions/checkout@v4.2.1
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v4.1.1
- uses: actions/cache@v4.0.2
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
@@ -39,7 +39,7 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3
versioning: Semantic
- uses: actions/upload-artifact@v4.4.3
- uses: actions/upload-artifact@v4.3.2
with:
name: PAL3-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
+2 -2
View File
@@ -12,11 +12,11 @@ jobs:
targetPlatform:
- iOS # Build an iOS player.
steps:
- uses: actions/checkout@v4.2.1
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v4.1.1
- uses: actions/cache@v4.0.2
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
+3 -3
View File
@@ -12,11 +12,11 @@ jobs:
targetPlatform:
- StandaloneLinux64 # Build a Linux 64-bit standalone.
steps:
- uses: actions/checkout@v4.2.1
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v4.1.1
- uses: actions/cache@v4.0.2
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
@@ -30,7 +30,7 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3
versioning: Semantic
- uses: actions/upload-artifact@v4.4.3
- uses: actions/upload-artifact@v4.3.2
with:
name: PAL3-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
+3 -3
View File
@@ -12,11 +12,11 @@ jobs:
targetPlatform:
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
steps:
- uses: actions/checkout@v4.2.1
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v4.1.1
- uses: actions/cache@v4.0.2
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
@@ -30,7 +30,7 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3
versioning: Semantic
- uses: actions/upload-artifact@v4.4.3
- uses: actions/upload-artifact@v4.3.2
with:
name: PAL3-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
@@ -13,11 +13,11 @@ jobs:
- StandaloneWindows # Build a Windows standalone.
- StandaloneWindows64 # Build a Windows 64-bit standalone.
steps:
- uses: actions/checkout@v4.2.1
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v4.1.1
- uses: actions/cache@v4.0.2
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
@@ -31,7 +31,7 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3
versioning: Semantic
- uses: actions/upload-artifact@v4.4.3
- uses: actions/upload-artifact@v4.3.2
with:
name: PAL3-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
@@ -21,7 +21,7 @@ jobs:
large-packages: true
docker-images: true
swap-storage: true
- uses: actions/checkout@v4.2.1
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0
lfs: true
@@ -37,7 +37,7 @@ jobs:
find: "6b32649dccc45df4ebe8e3f8eccee249"
replace: "d03d417e5660d5849939c8fe43732dbd"
include: "**ProjectSettings.asset"
- uses: actions/cache@v4.1.1
- uses: actions/cache@v4.0.2
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
@@ -52,7 +52,7 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3A
versioning: Semantic
- uses: actions/upload-artifact@v4.4.3
- uses: actions/upload-artifact@v4.3.2
with:
name: PAL3A-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
+2 -2
View File
@@ -12,7 +12,7 @@ jobs:
targetPlatform:
- iOS # Build an iOS player.
steps:
- uses: actions/checkout@v4.2.1
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0
lfs: true
@@ -28,7 +28,7 @@ jobs:
find: "6b32649dccc45df4ebe8e3f8eccee249"
replace: "d03d417e5660d5849939c8fe43732dbd"
include: "**ProjectSettings.asset"
- uses: actions/cache@v4.1.1
- uses: actions/cache@v4.0.2
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
+3 -3
View File
@@ -12,7 +12,7 @@ jobs:
targetPlatform:
- StandaloneLinux64 # Build a Linux 64-bit standalone.
steps:
- uses: actions/checkout@v4.2.1
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0
lfs: true
@@ -28,7 +28,7 @@ jobs:
find: "6b32649dccc45df4ebe8e3f8eccee249"
replace: "d03d417e5660d5849939c8fe43732dbd"
include: "**ProjectSettings.asset"
- uses: actions/cache@v4.1.1
- uses: actions/cache@v4.0.2
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
@@ -43,7 +43,7 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3A
versioning: Semantic
- uses: actions/upload-artifact@v4.4.3
- uses: actions/upload-artifact@v4.3.2
with:
name: PAL3A-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
+3 -3
View File
@@ -12,7 +12,7 @@ jobs:
targetPlatform:
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
steps:
- uses: actions/checkout@v4.2.1
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0
lfs: true
@@ -28,7 +28,7 @@ jobs:
find: "6b32649dccc45df4ebe8e3f8eccee249"
replace: "d03d417e5660d5849939c8fe43732dbd"
include: "**ProjectSettings.asset"
- uses: actions/cache@v4.1.1
- uses: actions/cache@v4.0.2
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
@@ -43,7 +43,7 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3A
versioning: Semantic
- uses: actions/upload-artifact@v4.4.3
- uses: actions/upload-artifact@v4.3.2
with:
name: PAL3A-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
@@ -13,7 +13,7 @@ jobs:
- StandaloneWindows # Build a Windows standalone.
- StandaloneWindows64 # Build a Windows 64-bit standalone.
steps:
- uses: actions/checkout@v4.2.1
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0
lfs: true
@@ -29,7 +29,7 @@ jobs:
find: "6b32649dccc45df4ebe8e3f8eccee249"
replace: "d03d417e5660d5849939c8fe43732dbd"
include: "**ProjectSettings.asset"
- uses: actions/cache@v4.1.1
- uses: actions/cache@v4.0.2
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
@@ -44,7 +44,7 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3A
versioning: Semantic
- uses: actions/upload-artifact@v4.4.3
- uses: actions/upload-artifact@v4.3.2
with:
name: PAL3A-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
-3
View File
@@ -67,9 +67,6 @@ crashlytics-build.properties
# MacOS generated files
.DS_Store
# Unity CMake tmp files
.utmp
# Unity StreamingAssets folder
/Assets/StreamingAssets
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c94022471fa0dc1458e85b14d0c0dbd8
guid: bed3e3b7fed51194da24fb7fb8c0a316
DefaultImporter:
externalObjects: {}
userData:
@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>Newtonsoft.Json</id>
<version>13.0.3</version>
<title>Json.NET</title>
<authors>James Newton-King</authors>
<license type="expression">MIT</license>
<licenseUrl>https://licenses.nuget.org/MIT</licenseUrl>
<icon>packageIcon.png</icon>
<readme>README.md</readme>
<projectUrl>https://www.newtonsoft.com/json</projectUrl>
<iconUrl>https://www.newtonsoft.com/content/images/nugeticon.png</iconUrl>
<description>Json.NET is a popular high-performance JSON framework for .NET</description>
<copyright>Copyright © James Newton-King 2008</copyright>
<tags>json</tags>
<repository type="git" url="https://github.com/JamesNK/Newtonsoft.Json" commit="0a2e291c0d9c0c7675d445703e51750363a549ef" />
<dependencies>
<group targetFramework=".NETFramework2.0" />
<group targetFramework=".NETFramework3.5" />
<group targetFramework=".NETFramework4.0" />
<group targetFramework=".NETFramework4.5" />
<group targetFramework=".NETStandard1.0">
<dependency id="Microsoft.CSharp" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="NETStandard.Library" version="1.6.1" exclude="Build,Analyzers" />
<dependency id="System.ComponentModel.TypeConverter" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="System.Runtime.Serialization.Primitives" version="4.3.0" exclude="Build,Analyzers" />
</group>
<group targetFramework=".NETStandard1.3">
<dependency id="Microsoft.CSharp" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="NETStandard.Library" version="1.6.1" exclude="Build,Analyzers" />
<dependency id="System.ComponentModel.TypeConverter" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="System.Runtime.Serialization.Formatters" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="System.Runtime.Serialization.Primitives" version="4.3.0" exclude="Build,Analyzers" />
<dependency id="System.Xml.XmlDocument" version="4.3.0" exclude="Build,Analyzers" />
</group>
<group targetFramework="net6.0" />
<group targetFramework=".NETStandard2.0" />
</dependencies>
</metadata>
</package>
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 3d4c838ee303a814f829ff91259ec31a
guid: 284597a55e57c044bb7e9b4d3071e02d
DefaultImporter:
externalObjects: {}
userData:
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>ini-parser-netstandard</id>
<version>2.5.2</version>
<authors>Ricardo Amores Hernández</authors>
<owners>Ricardo Amores Hernández</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>https://github.com/rickyah/ini-parser/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/rickyah/ini-parser</projectUrl>
<description>A .NET, Mono and Unity3d compatible(*) library for reading/writing INI data from IO streams, file streams, and strings written in C#.
Also implements merging operations, both for complete ini files, sections, or even just a subset of the keys contained by the files.
(*) This library is 100% .NET code and does not have any dependencies on Windows API calls in order to be portable.</description>
<tags>ini</tags>
<dependencies>
<group targetFramework=".NETFramework2.0" />
<group targetFramework=".NETStandard2.0" />
</dependencies>
</metadata>
</package>
@@ -2,20 +2,24 @@
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2180264
Material:
serializedVersion: 6
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: LiberationSans SDF Material
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
m_ShaderKeywords:
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
@@ -67,6 +71,7 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _Ambient: 0.5
- _Bevel: 0.5
@@ -107,9 +112,9 @@ Material:
- _Parallax: 0.02
- _PerspectiveFilter: 0.875
- _Reflectivity: 10
- _ScaleRatioA: 0.90909094
- _ScaleRatioA: 0.9
- _ScaleRatioB: 0.73125
- _ScaleRatioC: 0.7386364
- _ScaleRatioC: 0.73125
- _ScaleX: 1
- _ScaleY: 1
- _ShaderFlags: 0
@@ -148,6 +153,7 @@ Material:
- _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
m_BuildTextureStacks: []
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -160,18 +166,21 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 71c1514a6bd24e1e882cebbe1904ce04, type: 3}
m_Name: LiberationSans SDF - Fallback
m_EditorClassIdentifier:
hashCode: -1699145518
material: {fileID: 2180264}
materialHashCode: 462855346
m_Version: 1.1.0
m_Material: {fileID: 2180264}
m_SourceFontFileGUID: e3265ab4bf004d28a9537516768c1c75
m_SourceFontFile_EditorRef: {fileID: 12800000, guid: e3265ab4bf004d28a9537516768c1c75, type: 3}
m_SourceFontFile: {fileID: 12800000, guid: e3265ab4bf004d28a9537516768c1c75, type: 3}
m_AtlasPopulationMode: 1
InternalDynamicOS: 0
m_FaceInfo:
m_FaceIndex: 0
m_FamilyName: Liberation Sans
m_StyleName: Regular
m_PointSize: 86
m_Scale: 1
m_UnitsPerEM: 0
m_LineHeight: 98.8916
m_AscentLine: 77.853516
m_CapLine: 59
@@ -192,7 +201,7 @@ MonoBehaviour:
m_AtlasTextures:
- {fileID: 28268798066460806}
m_AtlasTextureIndex: 0
m_IsMultiAtlasTexturesEnabled: 1
m_IsMultiAtlasTexturesEnabled: 0
m_ClearDynamicDataOnBuild: 1
m_UsedGlyphRects: []
m_FreeGlyphRects:
@@ -231,21 +240,15 @@ MonoBehaviour:
m_KerningTable:
kerningPairs: []
m_FontFeatureTable:
m_MultipleSubstitutionRecords: []
m_LigatureSubstitutionRecords: []
m_GlyphPairAdjustmentRecords: []
m_MarkToBaseAdjustmentRecords: []
m_MarkToMarkAdjustmentRecords: []
fallbackFontAssets: []
m_FallbackFontAssetTable: []
m_CreationSettings:
sourceFontFileName:
sourceFontFileGUID: e3265ab4bf004d28a9537516768c1c75
faceIndex: 0
pointSizeSamplingMode: 0
pointSize: 86
padding: 9
paddingMode: 0
packingMode: 4
atlasWidth: 512
atlasHeight: 512
@@ -317,15 +320,21 @@ Texture2D:
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_IsAlphaChannelOptional: 0
serializedVersion: 2
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_MipsStripped: 0
m_TextureFormat: 1
m_MipCount: 1
m_IsReadable: 1
m_IsPreProcessed: 0
m_IgnoreMipmapLimit: 0
m_MipmapLimitGroupName:
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_VTOnly: 0
m_AlphaIsTransparency: 0
m_ImageCount: 1
m_TextureDimension: 2
@@ -339,9 +348,11 @@ Texture2D:
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
m_PlatformBlob:
image data: 0
_typelessdata:
m_StreamData:
serializedVersion: 2
offset: 0
size: 0
path:
@@ -9,7 +9,7 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: LiberationSans SDF Material
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
m_ShaderKeywords:
m_ShaderKeywords: OUTLINE_ON
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
@@ -23,8 +23,10 @@ Material:
m_Texture: {fileID: 28684132378477856}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _ColorMask: 15
- _CullMode: 0
- _FaceDilate: 0
- _GradientScale: 10
- _MaskSoftnessX: 0
@@ -59,6 +61,7 @@ Material:
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
m_BuildTextureStacks: []
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -73,14 +76,14 @@ MonoBehaviour:
m_EditorClassIdentifier:
hashCode: 231247347
material: {fileID: 2180264}
materialHashCode: -1183942120
materialHashCode: 198912371
m_Version: 1.1.0
m_SourceFontFileGUID: e3265ab4bf004d28a9537516768c1c75
m_SourceFontFile_EditorRef: {fileID: 12800000, guid: e3265ab4bf004d28a9537516768c1c75,
type: 3}
m_SourceFontFile_EditorRef: {fileID: 12800000, guid: e3265ab4bf004d28a9537516768c1c75, type: 3}
m_SourceFontFile: {fileID: 0}
m_AtlasPopulationMode: 0
m_FaceInfo:
m_FaceIndex: 0
m_FamilyName: Liberation Sans
m_StyleName: Regular
m_PointSize: 86
@@ -4605,6 +4608,8 @@ MonoBehaviour:
m_AtlasTextures:
- {fileID: 28684132378477856}
m_AtlasTextureIndex: 0
m_IsMultiAtlasTexturesEnabled: 0
m_ClearDynamicDataOnBuild: 0
m_UsedGlyphRects:
- m_X: 0
m_Y: 0
@@ -7791,15 +7796,20 @@ Texture2D:
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_IsAlphaChannelOptional: 0
serializedVersion: 2
m_Width: 1024
m_Height: 1024
m_CompleteImageSize: 1048576
m_MipsStripped: 0
m_TextureFormat: 1
m_MipCount: 1
m_IsReadable: 0
m_IsPreProcessed: 0
m_IgnoreMasterTextureLimit: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: -92
m_VTOnly: 0
m_AlphaIsTransparency: 0
m_ImageCount: 1
m_TextureDimension: 2
@@ -7813,9 +7823,11 @@ Texture2D:
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
m_PlatformBlob:
image data: 1048576
_typelessdata: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040607090b0d0f101112121313131212100f0e0c0a08060603000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000407090a1313131313131313130e0d0b08030000000000000000000000000000000000000002070a0c0d1313131313131313130b0a0805000000000000000000000000000000000000000000000000000000000000050a0d0f10131313131313130e0d0b0803000000000000000000000000000000000000000000000004080a0a13131313131313131313131313131313131313131313131313131313131313131313131313131313130a09070400000000000000000000000000000000000000000006060606060600000000000000000000000000000000000000000000020507080c0f1112131211100c080806020000000000000000000000030607090d1011121312110e0a070604010000000000000000000000000000000000000000000000000000000000000000000000000606060606060000000000000000000000000000000000000000000000000000000000010507070c0f1112131312100c08080602000000000000000000000000000000000000000000000000000000000000000000030608091313131313120707050100000000000000000000000000000000000000000000000000000000000105070713131313130c0b09060100000000000000000000000000000000000000000000000000000000000306080913131313131207070501000000000000000000000000000000000000000000000000000000000105070713131313130c0b09060100000000000000000000000000000000000004080a0a0b0b0b0b0b0b0b07060401000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030607090b0d0f1111121313121211100f0d0a0807050200000000000000000000000000000000000000000000000000000000000000000003080c0e0e131313131313130f0e0c09040000000000000000000000000000000000000000000000000000000000000003070b0d0e131313131313130e0e0c0803000000000000000000000003080c0e0e131313131313130f0e0c09040000000000000000000000000000000000000000000000000000000000000003070b0d0e131313131313130e0e0c080300000000000000000000000000000000000000000000040613131313131313131312110e09040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000205070c10131315171a1c1d1e1e1f20201f1f1e1d1c1b19171513120f0b06060401000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050b101316172020202020202020201b1a18140f080100000000000000000000000000000000070e1317191a202020202020202020181715110c060000000000000000000000000000000000000000000000000000030a10161a1c1d202020202020201b1a18140f080100000000000000000000000000000000000000050b101416172020202020202020202020202020202020202020202020202020202020202020202020202020202020171614100b0500000000000000000000000000000106090b0c131313131313080705020000000000000000000000000000000002090e111414181c1e1f201f1e1c191514120e090300000000000000060b101213161a1d1e1f201e1d1b171413110d0701000000000000000000000000000000000000000000000000000000000000030608091313131313130b0a08050000000000000000000000Line truncated
m_StreamData:
offset: 0
serializedVersion: 2
offset: 2176340
size: 0
path:
@@ -3,9 +3,8 @@
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
@@ -13,12 +12,6 @@ MonoBehaviour:
m_Name: Default Style Sheet
m_EditorClassIdentifier:
m_StyleList:
- m_Name: Normal
m_HashCode: -1183493901
m_OpeningDefinition:
m_ClosingDefinition:
m_OpeningTagArray:
m_ClosingTagArray:
- m_Name: H1
m_HashCode: 2425
m_OpeningDefinition: <size=2em><b><#40ff80>*
@@ -26,25 +19,19 @@ MonoBehaviour:
m_OpeningTagArray: 3c00000073000000690000007a000000650000003d00000032000000650000006d0000003e0000003c000000620000003e0000003c000000230000003400000030000000660000006600000038000000300000003e0000002a000000
m_ClosingTagArray: 2a0000003c0000002f00000073000000690000007a000000650000003e0000003c0000002f000000620000003e0000003c0000002f000000630000006f0000006c0000006f000000720000003e000000
- m_Name: Quote
m_HashCode: 93368250
m_HashCode: 92254330
m_OpeningDefinition: <i><size=75%><margin=10%>
m_ClosingDefinition: </i></size></width></margin>
m_OpeningTagArray: 3c000000690000003e0000003c00000073000000690000007a000000650000003d0000003700000035000000250000003e0000003c0000006d000000610000007200000067000000690000006e0000003d0000003100000030000000250000003e000000
m_ClosingTagArray: 3c0000002f000000690000003e0000003c0000002f00000073000000690000007a000000650000003e0000003c0000002f00000077000000690000006400000074000000680000003e0000003c0000002f0000006d000000610000007200000067000000690000006e0000003e000000
- m_Name: A
m_HashCode: 65
m_OpeningDefinition: <color=#40a0ff><u>
m_ClosingDefinition: </u></color>
m_OpeningTagArray: 3c000000630000006f0000006c0000006f000000720000003d000000230000003400000030000000610000003000000066000000660000003e0000003c000000750000003e000000
m_ClosingTagArray: 3c0000002f000000750000003e0000003c0000002f000000630000006f0000006c0000006f000000720000003e000000
- m_Name: Link
m_HashCode: 2656128
m_HashCode: 2687968
m_OpeningDefinition: <u><#40a0ff><link="ID_01">
m_ClosingDefinition: </u></color></link>
m_OpeningTagArray: 3c000000750000003e0000003c000000230000003400000030000000610000003000000066000000660000003e0000003c0000006c000000690000006e0000006b0000003d0000002200000049000000440000005f0000003000000031000000220000003e000000
m_ClosingTagArray: 3c0000002f000000750000003e0000003c0000002f000000630000006f0000006c0000006f000000720000003e0000003c0000002f0000006c000000690000006e0000006b0000003e000000
- m_Name: Title
m_HashCode: 97690656
m_HashCode: 98732960
m_OpeningDefinition: <size=125%><b><align=center>
m_ClosingDefinition: </size></b></align>
m_OpeningTagArray: 3c00000073000000690000007a000000650000003d000000310000003200000035000000250000003e0000003c000000620000003e0000003c000000610000006c00000069000000670000006e0000003d00000063000000650000006e0000007400000065000000720000003e000000
@@ -12,17 +12,14 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2705215ac5b84b70bacc50632be6e391, type: 3}
m_Name: TMP Settings
m_EditorClassIdentifier:
assetVersion: 2
m_TextWrappingMode: 1
m_enableWordWrapping: 1
m_enableKerning: 1
m_ActiveFontFeatures: 00000000
m_enableExtraPadding: 0
m_enableTintAllSprites: 0
m_enableParseEscapeCharacters: 1
m_EnableRaycastTarget: 1
m_GetFontFeaturesAtRuntime: 1
m_missingGlyphCharacter: 0
m_ClearDynamicDataOnBuild: 1
m_warningsDisabled: 0
m_defaultFontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_defaultFontAssetPath: Fonts & Materials/
@@ -32,16 +29,13 @@ MonoBehaviour:
m_defaultTextMeshProTextContainerSize: {x: 20, y: 5}
m_defaultTextMeshProUITextContainerSize: {x: 200, y: 50}
m_autoSizeTextContainer: 0
m_IsTextObjectScaleStatic: 0
m_fallbackFontAssets: []
m_matchMaterialPreset: 1
m_HideSubTextObjects: 0
m_defaultSpriteAsset: {fileID: 11400000, guid: c41005c129ba4d66911b75229fd70b45,
type: 2}
m_defaultSpriteAssetPath: Sprite Assets/
m_enableEmojiSupport: 1
m_MissingCharacterSpriteUnicode: 0
m_EmojiFallbackTextAssets: []
m_defaultColorGradientPresetsPath: Color Gradient Presets/
m_defaultStyleSheet: {fileID: 11400000, guid: f952c082cb03451daed3ee968ac6c63e,
type: 2}
@@ -1,178 +0,0 @@
float2 UnpackUV(float uv)
{
float2 output;
output.x = floor(uv / 4096.0);
output.y = uv - 4096.0 * output.x;
return output * 0.001953125;
}
float4 BlendARGB(float4 overlying, float4 underlying)
{
overlying.rgb *= overlying.a;
underlying.rgb *= underlying.a;
float3 blended = overlying.rgb + ((1 - overlying.a) * underlying.rgb);
float alpha = underlying.a + (1 - underlying.a) * overlying.a;
return float4(blended / alpha, alpha);
}
float3 GetSpecular(float3 n, float3 l)
{
float spec = pow(max(0.0, dot(n, l)), _Reflectivity);
return _SpecularColor.rgb * spec * _SpecularPower;
}
void GetSurfaceNormal_float(texture2D atlas, float textureWidth, float textureHeight, float2 uv, bool isFront, out float3 nornmal)
{
float3 delta = float3(1.0 / textureWidth, 1.0 / textureHeight, 0.0);
// Read "height field"
float4 h = float4(
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv - delta.xz).a,
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv + delta.xz).a,
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv - delta.zy).a,
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv + delta.zy).a);
bool raisedBevel = _BevelType;
h += _BevelOffset;
float bevelWidth = max(.01, _BevelWidth);
// Track outline
h -= .5;
h /= bevelWidth;
h = saturate(h + .5);
if (raisedBevel) h = 1 - abs(h * 2.0 - 1.0);
h = lerp(h, sin(h * 3.141592 / 2.0), float4(_BevelRoundness, _BevelRoundness, _BevelRoundness, _BevelRoundness));
h = min(h, 1.0 - float4(_BevelClamp, _BevelClamp, _BevelClamp, _BevelClamp));
h *= _BevelAmount * bevelWidth * _GradientScale * -2.0;
float3 va = normalize(float3(-1.0, 0.0, h.y - h.x));
float3 vb = normalize(float3(0.0, 1.0, h.w - h.z));
float3 f = float3(1, 1, 1);
if (isFront) f = float3(1, 1, -1);
nornmal = cross(va, vb) * f;
}
void EvaluateLight_float(float4 faceColor, float3 n, out float4 color)
{
n.z = abs(n.z);
float3 light = normalize(float3(sin(_LightAngle), cos(_LightAngle), 1.0));
float3 col = max(faceColor.rgb, 0) + GetSpecular(n, light)* faceColor.a;
//faceColor.rgb += col * faceColor.a;
col *= 1 - (dot(n, light) * _Diffuse);
col *= 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;
color = float4(col, faceColor.a);
}
// Add custom function to handle time in HDRP
//
void GenerateUV_float(float2 inUV, float4 transform, float2 animSpeed, out float2 outUV)
{
outUV = inUV * transform.xy + transform.zw + (animSpeed * _Time.y);
}
void ComputeUVOffset_float(float texWidth, float texHeight, float2 offset, float SDR, out float2 uvOffset)
{
uvOffset = float2(-offset.x * SDR / texWidth, -offset.y * SDR / texHeight);
}
void ScreenSpaceRatio2_float(float4x4 projection, float4 position, float2 objectScale, float screenWidth, float screenHeight, float fontScale, out float SSR)
{
float2 pixelSize = position.w;
pixelSize /= (objectScale * mul((float2x2)projection, float2(screenWidth, screenHeight)));
SSR = rsqrt(dot(pixelSize, pixelSize)*2) * fontScale;
}
// UV : Texture coordinate of the source distance field texture
// TextureSize : Size of the source distance field texture
// Filter : Enable perspective filter (soften)
void ScreenSpaceRatio_float(float2 UV, float TextureSize, bool Filter, out float SSR)
{
if(Filter)
{
float2 a = float2(ddx(UV.x), ddy(UV.x));
float2 b = float2(ddx(UV.y), ddy(UV.y));
float s = lerp(dot(a,a), dot(b,b), 0.5);
SSR = rsqrt(s) / TextureSize;
}
else
{
float s = rsqrt(abs(ddx(UV.x) * ddy(UV.y) - ddy(UV.x) * ddx(UV.y)));
SSR = s / TextureSize;
}
}
// SSR : Screen Space Ratio
// SD : Signed Distance (encoded : Distance / SDR + .5)
// SDR : Signed Distance Ratio
//
// IsoPerimeter : Dilate / Contract the shape
void ComputeSDF_float(float SSR, float SD, float SDR, float isoPerimeter, float softness, out float outAlpha)
{
softness *= SSR * SDR;
float d = (SD - 0.5) * SDR; // Signed distance to edge, in Texture space
outAlpha = saturate((d * 2.0 * SSR + 0.5 + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness)); // Screen pixel coverage (alpha)
}
void ComputeSDF2_float(float SSR, float SD, float SDR, float2 isoPerimeter, float2 softness, out float2 outAlpha)
{
softness *= SSR * SDR;
float d = (SD - 0.5f) * SDR;
outAlpha = saturate((d * 2.0f * SSR + 0.5f + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness));
}
void ComputeSDF4_float(float SSR, float SD, float SDR, float4 isoPerimeter, float4 softness, out float4 outAlpha)
{
softness *= SSR * SDR;
float d = (SD - 0.5f) * SDR;
outAlpha = saturate((d * 2.0f * SSR + 0.5f + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness));
}
void ComputeSDF44_float(float SSR, float4 SD, float SDR, float4 isoPerimeter, float4 softness, bool outline, out float4 outAlpha)
{
softness *= SSR * SDR;
float4 d = (SD - 0.5f) * SDR;
if(outline) d.w = max(max(d.x, d.y), d.z);
outAlpha = saturate((d * 2.0f * SSR + 0.5f + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness));
}
void Composite_float(float4 overlying, float4 underlying, out float4 outColor)
{
outColor = BlendARGB(overlying, underlying);
}
// Face only
void Layer1_float(float alpha, float4 color0, out float4 outColor)
{
color0.a *= alpha;
outColor = color0;
}
// Face + 1 Outline
void Layer2_float(float2 alpha, float4 color0, float4 color1, out float4 outColor)
{
color1.a *= alpha.y;
color0.rgb *= color0.a; color1.rgb *= color1.a;
outColor = lerp(color1, color0, alpha.x);
outColor.rgb /= outColor.a;
}
// Face + 3 Outline
void Layer4_float(float4 alpha, float4 color0, float4 color1, float4 color2, float4 color3, out float4 outColor)
{
color3.a *= alpha.w;
color0.rgb *= color0.a; color1.rgb *= color1.a; color2.rgb *= color2.a; color3.rgb *= color3.a;
outColor = lerp(lerp(lerp(color3, color2, alpha.z), color1, alpha.y), color0, alpha.x);
outColor.rgb /= outColor.a;
}
@@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: 96de908384869cd409c75efa351d5edf
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -1,26 +1,26 @@
Shader "TextMeshPro/Bitmap Custom Atlas" {
Properties {
_MainTex ("Font Atlas", 2D) = "white" {}
_FaceTex ("Font Texture", 2D) = "white" {}
_FaceColor ("Text Color", Color) = (1,1,1,1)
_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
_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
_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
_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
_CullMode("Cull Mode", Float) = 0
_ColorMask("Color Mask", Float) = 15
}
SubShader{
@@ -55,18 +55,15 @@ SubShader{
#include "UnityCG.cginc"
#include "UnityUI.cginc"
struct appdata_t
{
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float4 texcoord0 : TEXCOORD0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct v2f
{
struct v2f {
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0;
@@ -84,9 +81,15 @@ SubShader{
uniform float4 _ClipRect;
uniform float _MaskSoftnessX;
uniform float _MaskSoftnessY;
uniform float _UIMaskSoftnessX;
uniform float _UIMaskSoftnessY;
uniform int _UIVertexColorAlwaysGammaSpace;
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)
{
@@ -98,10 +101,6 @@ SubShader{
float4 vPosition = UnityPixelSnap(UnityObjectToClipPos(vert));
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
{
v.color.rgb = UIGammaToLinear(v.color.rgb);
}
fixed4 faceColor = v.color;
faceColor *= _FaceColor;
@@ -109,14 +108,13 @@ SubShader{
OUT.vertex = vPosition;
OUT.color = faceColor;
OUT.texcoord0 = v.texcoord0;
OUT.texcoord1 = TRANSFORM_TEX(v.texcoord1, _FaceTex);
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.
const float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
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;
}
@@ -1,25 +1,25 @@
Shader "TextMeshPro/Mobile/Bitmap" {
Properties {
_MainTex ("Font Atlas", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
_DiffusePower ("Diffuse Power", Range(1.0,4.0)) = 1.0
_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
_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)
_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
_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
_CullMode("Cull Mode", Float) = 0
_ColorMask("Color Mask", Float) = 15
}
SubShader {
@@ -55,18 +55,15 @@ SubShader {
#include "UnityCG.cginc"
#include "UnityUI.cginc"
struct appdata_t
{
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct v2f
{
struct v2f {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0;
@@ -82,9 +79,6 @@ SubShader {
uniform float4 _ClipRect;
uniform float _MaskSoftnessX;
uniform float _MaskSoftnessY;
uniform float _UIMaskSoftnessX;
uniform float _UIMaskSoftnessY;
uniform int _UIVertexColorAlwaysGammaSpace;
v2f vert (appdata_t v)
{
@@ -94,11 +88,8 @@ SubShader {
vert.y += _VertexOffsetY;
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
{
v.color.rgb = UIGammaToLinear(v.color.rgb);
}
OUT.vertex = UnityPixelSnap(UnityObjectToClipPos(vert));
OUT.vertex = UnityPixelSnap(UnityObjectToClipPos(vert));
OUT.color = v.color;
OUT.color *= _Color;
OUT.color.rgb *= _DiffusePower;
@@ -108,9 +99,8 @@ SubShader {
//pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
// Clamp _ClipRect to 16bit.
const float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
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;
}
@@ -1,25 +1,25 @@
Shader "TextMeshPro/Bitmap" {
Properties {
_MainTex ("Font Atlas", 2D) = "white" {}
_FaceTex ("Font Texture", 2D) = "white" {}
_FaceColor ("Text Color", Color) = (1,1,1,1)
_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
_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)
_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
_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
_CullMode("Cull Mode", Float) = 0
_ColorMask("Color Mask", Float) = 15
}
SubShader{
@@ -54,18 +54,15 @@ SubShader{
#include "UnityCG.cginc"
#include "UnityUI.cginc"
struct appdata_t
{
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float4 texcoord0 : TEXCOORD0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct v2f
{
struct v2f {
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0;
@@ -83,9 +80,15 @@ SubShader{
uniform float4 _ClipRect;
uniform float _MaskSoftnessX;
uniform float _MaskSoftnessY;
uniform float _UIMaskSoftnessX;
uniform float _UIMaskSoftnessY;
uniform int _UIVertexColorAlwaysGammaSpace;
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)
{
@@ -97,10 +100,6 @@ SubShader{
float4 vPosition = UnityPixelSnap(UnityObjectToClipPos(vert));
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
{
v.color.rgb = UIGammaToLinear(v.color.rgb);
}
fixed4 faceColor = v.color;
faceColor *= _FaceColor;
@@ -108,14 +107,13 @@ SubShader{
OUT.vertex = vPosition;
OUT.color = faceColor;
OUT.texcoord0 = v.texcoord0;
OUT.texcoord1 = TRANSFORM_TEX(v.texcoord1, _FaceTex);
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.
const float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
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;
}
@@ -4,10 +4,10 @@ Properties {
_FaceTex ("Face Texture", 2D) = "white" {}
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
_FaceColor ("Face Color", Color) = (1,1,1,1)
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
[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
@@ -21,7 +21,7 @@ Properties {
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
_LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416
_SpecularColor ("Specular", Color) = (1,1,1,1)
[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
@@ -37,13 +37,13 @@ Properties {
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
[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
_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
[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
@@ -127,18 +127,17 @@ SubShader {
#include "TMPro_Properties.cginc"
#include "TMPro.cginc"
struct vertex_t
{
struct vertex_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
float4 position : POSITION;
float3 normal : NORMAL;
fixed4 color : COLOR;
float4 texcoord0 : TEXCOORD0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t
{
struct pixel_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
float4 position : SV_POSITION;
@@ -148,20 +147,16 @@ SubShader {
float4 mask : TEXCOORD2; // Position in object space(xy), pixel Size(zw)
float3 viewDir : TEXCOORD3;
#if (UNDERLAY_ON || UNDERLAY_INNER)
#if (UNDERLAY_ON || UNDERLAY_INNER)
float4 texcoord2 : TEXCOORD4; // u,v, scale, bias
fixed4 underlayColor : COLOR1;
#endif
#endif
float4 textures : TEXCOORD5;
};
// Used by Unity internally to handle Texture Tiling and Offset.
uniform float4 _FaceTex_ST;
uniform float4 _OutlineTex_ST;
uniform float _UIMaskSoftnessX;
uniform float _UIMaskSoftnessY;
uniform int _UIVertexColorAlwaysGammaSpace;
float4 _FaceTex_ST;
float4 _OutlineTex_ST;
pixel_t VertShader(vertex_t input)
{
@@ -172,7 +167,7 @@ SubShader {
UNITY_TRANSFER_INSTANCE_ID(input,output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float bold = step(input.texcoord0.w, 0);
float bold = step(input.texcoord1.y, 0);
float4 vert = input.position;
vert.x += _VertexOffsetX;
@@ -183,7 +178,7 @@ SubShader {
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.texcoord0.w) * _GradientScale * (_Sharpness + 1);
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;
@@ -193,13 +188,13 @@ SubShader {
float alphaClip = (1.0 - _OutlineWidth*_ScaleRatioA - _OutlineSoftness*_ScaleRatioA);
#if GLOW_ON
#if GLOW_ON
alphaClip = min(alphaClip, 1.0 - _GlowOffset * _ScaleRatioB - _GlowOuter * _ScaleRatioB);
#endif
#endif
alphaClip = alphaClip / 2.0 - ( .5 / scale) - weight;
#if (UNDERLAY_ON || UNDERLAY_INNER)
#if (UNDERLAY_ON || UNDERLAY_INNER)
float4 underlayColor = _UnderlayColor;
underlayColor.rgb *= underlayColor.a;
@@ -210,28 +205,23 @@ SubShader {
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
float2 bOffset = float2(x, y);
#endif
#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 = input.texcoord1;
float2 textureUV = UnpackUV(input.texcoord1.x);
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
{
input.color.rgb = UIGammaToLinear(input.color.rgb);
}
output.position = vPosition;
output.color = input.color;
output.atlas = input.texcoord0;
output.param = float4(alphaClip, scale, bias, weight);
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
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);
@@ -249,9 +239,9 @@ SubShader {
float c = tex2D(_MainTex, input.atlas).a;
#ifndef UNDERLAY_ON
#ifndef UNDERLAY_ON
clip(c - input.param.x);
#endif
#endif
float scale = input.param.y;
float bias = input.param.z;
@@ -271,7 +261,7 @@ SubShader {
faceColor = GetColor(sd, faceColor, outlineColor, outline, softness);
#if BEVEL_ON
#if BEVEL_ON
float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0);
float3 n = GetSurfaceNormal(input.atlas, weight, dxy);
@@ -288,35 +278,36 @@ SubShader {
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
#endif
#if UNDERLAY_ON
#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
#endif
#if UNDERLAY_INNER
#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
#endif
#if GLOW_ON
#if GLOW_ON
float4 glowColor = GetGlowColor(sd, scale);
faceColor.rgb += glowColor.rgb * glowColor.a;
#endif
#endif
// Alternative implementation to UnityGet2DClipping with support for softness.
#if UNITY_UI_CLIP_RECT
// 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
#endif
#if UNITY_UI_ALPHACLIP
#if UNITY_UI_ALPHACLIP
clip(faceColor.a - 0.001);
#endif
#endif
return faceColor * input.color.a;
}
ENDCG
}
}
@@ -4,10 +4,10 @@ Properties {
_FaceTex ("Face Texture", 2D) = "white" {}
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
_FaceColor ("Face Color", Color) = (1,1,1,1)
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
[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
@@ -21,7 +21,7 @@ Properties {
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
_LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416
_SpecularColor ("Specular", Color) = (1,1,1,1)
[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
@@ -37,13 +37,13 @@ Properties {
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
[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
_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
[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
@@ -109,8 +109,7 @@ SubShader {
Blend One OneMinusSrcAlpha
ColorMask[_ColorMask]
Pass
{
Pass {
CGPROGRAM
#pragma target 3.0
#pragma vertex VertShader
@@ -128,18 +127,17 @@ SubShader {
#include "TMPro_Properties.cginc"
#include "TMPro.cginc"
struct vertex_t
{
struct vertex_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
float4 position : POSITION;
float3 normal : NORMAL;
float4 color : COLOR;
float4 texcoord0 : TEXCOORD0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t
{
struct pixel_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
float4 position : SV_POSITION;
@@ -149,23 +147,18 @@ SubShader {
float2 mask : TEXCOORD2; // Position in object space(xy)
float3 viewDir : TEXCOORD3;
#if (UNDERLAY_ON || UNDERLAY_INNER)
#if (UNDERLAY_ON || UNDERLAY_INNER)
float2 texcoord2 : TEXCOORD4;
float4 underlayColor : COLOR1;
#endif
#endif
float4 textures : TEXCOORD5;
};
// Used by Unity internally to handle Texture Tiling and Offset.
float4 _FaceTex_ST;
float4 _OutlineTex_ST;
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
int _UIVertexColorAlwaysGammaSpace;
float4 SRGBToLinear(float4 rgba)
{
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);
}
@@ -178,7 +171,7 @@ SubShader {
UNITY_TRANSFER_INSTANCE_ID(input,output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float bold = step(input.texcoord0.w, 0);
float bold = step(input.texcoord1.y, 0);
float4 vert = input.position;
vert.x += _VertexOffsetX;
@@ -189,31 +182,27 @@ SubShader {
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
#if (UNDERLAY_ON || UNDERLAY_INNER)
#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
#endif
// Generate UV for the Masking Texture
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
// Support for texture tiling and offset
float2 textureUV = input.texcoord1;
float2 textureUV = UnpackUV(input.texcoord1.x);
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
{
input.color.rgb = UIGammaToLinear(input.color.rgb);
}
float4 color = input.color;
#if (FORCE_LINEAR && !UNITY_COLORSPACE_GAMMA)
#if (FORCE_LINEAR && !UNITY_COLORSPACE_GAMMA)
color = SRGBToLinear(input.color);
#endif
#endif
output.position = vPosition;
output.color = color;
@@ -221,10 +210,10 @@ SubShader {
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)
#if (UNDERLAY_ON || UNDERLAY_INNER)
output.texcoord2 = input.texcoord0 + bOffset;
output.underlayColor = underlayColor;
#endif
#endif
output.textures = float4(faceUV, outlineUV);
return output;
@@ -237,9 +226,9 @@ SubShader {
float c = tex2D(_MainTex, input.atlas).a;
float pixelSize = abs(ddx(input.atlas.y)) + abs(ddy(input.atlas.y));
pixelSize *= _TextureHeight * 0.75;
float scale = 1 / pixelSize * _GradientScale * (_Sharpness + 1);
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);
@@ -258,7 +247,7 @@ SubShader {
faceColor = GetColor(sd, faceColor, outlineColor, outline, softness);
#if BEVEL_ON
#if BEVEL_ON
float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0);
float3 n = GetSurfaceNormal(input.atlas, weight, dxy);
@@ -275,45 +264,45 @@ SubShader {
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
#endif
#if (UNDERLAY_ON || UNDERLAY_INNER)
#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
#endif
#if UNDERLAY_ON
#if UNDERLAY_ON
float d = tex2D(_MainTex, input.texcoord2.xy).a * bScale;
faceColor += input.underlayColor * saturate(d - bBias) * (1 - faceColor.a);
#endif
#endif
#if UNDERLAY_INNER
#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
#endif
#if GLOW_ON
#if GLOW_ON
float4 glowColor = GetGlowColor(sd, scale);
faceColor.rgb += glowColor.rgb * glowColor.a;
#endif
#endif
// Alternative implementation to UnityGet2DClipping with support for softness.
#if UNITY_UI_CLIP_RECT
half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
float2 maskZW = 0.25 / (0.25 * maskSoftness + 1 / scale);
#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
#endif
#if UNITY_UI_ALPHACLIP
#if UNITY_UI_ALPHACLIP
clip(faceColor.a - 0.001);
#endif
#endif
return faceColor * input.color.a;
}
ENDCG
}
ENDCG
}
}
Fallback "TextMeshPro/Mobile/Distance Field"
File diff suppressed because it is too large. Load diff
@@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: ca2ed216f98028c4dae6c5224a952b3c
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
File diff suppressed because it is too large. Load diff
@@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: f63d574838ccfb44f84acc05fed0af48
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
@@ -6,14 +6,14 @@
Shader "TextMeshPro/Mobile/Distance Field - Masking" {
Properties {
_FaceColor ("Face Color", Color) = (1,1,1,1)
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
[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
@@ -99,41 +99,35 @@ SubShader {
#include "UnityUI.cginc"
#include "TMPro_Properties.cginc"
struct vertex_t
{
struct vertex_t {
float4 vertex : POSITION;
float3 normal : NORMAL;
fixed4 color : COLOR;
float4 texcoord0 : TEXCOORD0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t
{
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)
#if (UNDERLAY_ON | UNDERLAY_INNER)
float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved
half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y)
#endif
#endif
};
float _MaskWipeControl;
float _MaskEdgeSoftness;
fixed4 _MaskEdgeColor;
bool _MaskInverse;
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
int _UIVertexColorAlwaysGammaSpace;
pixel_t VertShader(vertex_t input)
{
float bold = step(input.texcoord0.w, 0);
float bold = step(input.texcoord1.y, 0);
float4 vert = input.vertex;
vert.x += _VertexOffsetX;
@@ -144,7 +138,7 @@ SubShader {
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float scale = rsqrt(dot(pixelSize, pixelSize));
scale *= abs(input.texcoord0.w) * _GradientScale * (_Sharpness + 1);
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;
@@ -156,10 +150,6 @@ SubShader {
float bias = (0.5 - weight) * scale - 0.5;
float outline = _OutlineWidth * _ScaleRatioA * 0.5 * scale;
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
{
input.color.rgb = UIGammaToLinear(input.color.rgb);
}
float opacity = input.color.a;
#if (UNDERLAY_ON | UNDERLAY_INNER)
opacity = 1.0;
@@ -173,7 +163,7 @@ SubShader {
outlineColor.rgb *= outlineColor.a;
outlineColor = lerp(faceColor, outlineColor, sqrt(min(1.0, (outline * 2))));
#if (UNDERLAY_ON | UNDERLAY_INNER)
#if (UNDERLAY_ON | UNDERLAY_INNER)
layerScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * layerScale);
float layerBias = (.5 - weight) * layerScale - .5 - ((_UnderlayDilate * _ScaleRatioC) * .5 * layerScale);
@@ -181,12 +171,11 @@ SubShader {
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
float2 layerOffset = float2(x, y);
#endif
#endif
// Generate UV for the Masking Texture
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
// Structure for pixel shader
pixel_t output = {
@@ -195,11 +184,11 @@ SubShader {
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 * maskSoftness + pixelSize.xy)),
#if (UNDERLAY_ON | UNDERLAY_INNER)
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
#endif
};
return output;
@@ -212,41 +201,41 @@ SubShader {
half d = tex2D(_MainTex, input.texcoord0.xy).a * input.param.x;
half4 c = input.faceColor * saturate(d - input.param.w);
#ifdef OUTLINE_ON
#ifdef OUTLINE_ON
c = lerp(input.outlineColor, input.faceColor, saturate(d - input.param.z));
c *= saturate(d - input.param.y);
#endif
#endif
#if UNDERLAY_ON
#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
#endif
#if UNDERLAY_INNER
#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
#endif
// Alternative implementation to UnityGet2DClipping with support for softness.
//#if UNITY_UI_CLIP_RECT
// 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
//#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;
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)
#if (UNDERLAY_ON | UNDERLAY_INNER)
c *= input.texcoord1.z;
#endif
#endif
#if UNITY_UI_ALPHACLIP
#if UNITY_UI_ALPHACLIP
clip(c.a - 0.001);
#endif
#endif
return c;
}
@@ -6,14 +6,14 @@
Shader "TextMeshPro/Mobile/Distance Field Overlay" {
Properties {
_FaceColor ("Face Color", Color) = (1,1,1,1)
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
[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
@@ -93,18 +93,16 @@ SubShader {
#include "UnityUI.cginc"
#include "TMPro_Properties.cginc"
struct vertex_t
{
struct vertex_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
float4 vertex : POSITION;
float3 normal : NORMAL;
fixed4 color : COLOR;
float4 texcoord0 : TEXCOORD0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t
{
struct pixel_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
float4 vertex : SV_POSITION;
@@ -113,17 +111,12 @@ SubShader {
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)
#if (UNDERLAY_ON | UNDERLAY_INNER)
float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved
half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y)
#endif
#endif
};
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
int _UIVertexColorAlwaysGammaSpace;
pixel_t VertShader(vertex_t input)
{
@@ -134,7 +127,7 @@ SubShader {
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float bold = step(input.texcoord0.w, 0);
float bold = step(input.texcoord1.y, 0);
float4 vert = input.vertex;
vert.x += _VertexOffsetX;
@@ -145,7 +138,7 @@ SubShader {
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float scale = rsqrt(dot(pixelSize, pixelSize));
scale *= abs(input.texcoord0.w) * _GradientScale * (_Sharpness + 1);
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;
@@ -157,14 +150,10 @@ SubShader {
float bias = (0.5 - weight) * scale - 0.5;
float outline = _OutlineWidth * _ScaleRatioA * 0.5 * scale;
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
{
input.color.rgb = UIGammaToLinear(input.color.rgb);
}
float opacity = input.color.a;
#if (UNDERLAY_ON | UNDERLAY_INNER)
#if (UNDERLAY_ON | UNDERLAY_INNER)
opacity = 1.0;
#endif
#endif
fixed4 faceColor = fixed4(input.color.rgb, opacity) * _FaceColor;
faceColor.rgb *= faceColor.a;
@@ -174,14 +163,14 @@ SubShader {
outlineColor.rgb *= outlineColor.a;
outlineColor = lerp(faceColor, outlineColor, sqrt(min(1.0, (outline * 2))));
#if (UNDERLAY_ON | UNDERLAY_INNER)
#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
#endif
// Generate UV for the Masking Texture
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
@@ -193,8 +182,7 @@ SubShader {
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);
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
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);
@@ -212,35 +200,35 @@ SubShader {
half d = tex2D(_MainTex, input.texcoord0.xy).a * input.param.x;
half4 c = input.faceColor * saturate(d - input.param.w);
#ifdef OUTLINE_ON
#ifdef OUTLINE_ON
c = lerp(input.outlineColor, input.faceColor, saturate(d - input.param.z));
c *= saturate(d - input.param.y);
#endif
#endif
#if UNDERLAY_ON
#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
#endif
#if UNDERLAY_INNER
#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
#endif
// Alternative implementation to UnityGet2DClipping with support for softness.
#if UNITY_UI_CLIP_RECT
// 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
#endif
#if (UNDERLAY_ON | UNDERLAY_INNER)
#if (UNDERLAY_ON | UNDERLAY_INNER)
c *= input.texcoord1.z;
#endif
#endif
#if UNITY_UI_ALPHACLIP
#if UNITY_UI_ALPHACLIP
clip(c.a - 0.001);
#endif
#endif
return c;
}
@@ -6,14 +6,14 @@
Shader "TextMeshPro/Mobile/Distance Field SSD" {
Properties {
_FaceColor ("Face Color", Color) = (1,1,1,1)
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
[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
@@ -1,389 +0,0 @@
// 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 - 2 Pass" {
Properties {
_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
_WeightNormal ("Weight Normal", float) = 0
_WeightBold ("Weight Bold", float) = .5
_ShaderFlags ("Flags", float) = 0
_ScaleRatioA ("Scale RatioA", float) = 1
_ScaleRatioB ("Scale RatioB", float) = 1
_ScaleRatioC ("Scale RatioC", float) = 1
_MainTex ("Font Atlas", 2D) = "white" {}
_TextureWidth ("Texture Width", float) = 512
_TextureHeight ("Texture Height", float) = 512
_GradientScale ("Gradient Scale", float) = 5
_ScaleX ("Scale X", float) = 1
_ScaleY ("Scale Y", float) = 1
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
_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 {
// Draw Outline and Underlay
Name "Outline"
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;
float4 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
};
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
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);
const float bold = step(input.texcoord0.w, 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.texcoord0.w) * _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;
const 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);
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + 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 = half4(0, 0, 0, 0);
#if OUTLINE_ON
c = input.outlineColor * 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
}
// Draw face
Name "Face"
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 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;
float4 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
float4 vertex : SV_POSITION;
fixed4 faceColor : COLOR;
float4 texcoord0 : TEXCOORD0; // Texture UV, Mask UV
half2 param : TEXCOORD1; // Scale(x), BiasIn(y), BiasOut(z), Bias(w)
half4 mask : TEXCOORD2; // Position in clip space(xy), Softness(zw)
};
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
int _UIVertexColorAlwaysGammaSpace;
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);
const float bold = step(input.texcoord0.w, 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.texcoord0.w) * _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;
scale /= 1 + (_OutlineSoftness * _ScaleRatioA * scale);
float bias = (0.5 - weight) * scale - 0.5;
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
{
input.color.rgb = UIGammaToLinear(input.color.rgb);
}
float opacity = input.color.a;
fixed4 faceColor = fixed4(input.color.rgb, opacity) * _FaceColor;
faceColor.rgb *= faceColor.a;
// 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.texcoord0 = float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y);
output.param = half2(scale, bias);
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
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.y);
// Alternative implementation to UnityGet2DClipping with support for softness.
#if UNITY_UI_CLIP_RECT
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
c *= m.x * m.y;
#endif
#if UNITY_UI_ALPHACLIP
clip(c.a - 0.001);
#endif
return c;
}
ENDCG
}
}
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
}
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 0178fcb869bafef4690d177d31d17db8
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -6,14 +6,14 @@
Shader "TextMeshPro/Mobile/Distance Field" {
Properties {
_FaceColor ("Face Color", Color) = (1,1,1,1)
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
[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
@@ -81,7 +81,6 @@ SubShader {
Pass {
CGPROGRAM
#pragma enable_d3d11_debug_symbols
#pragma vertex VertShader
#pragma fragment PixShader
#pragma shader_feature __ OUTLINE_ON
@@ -99,7 +98,7 @@ SubShader {
float4 vertex : POSITION;
float3 normal : NORMAL;
fixed4 color : COLOR;
float4 texcoord0 : TEXCOORD0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
@@ -118,9 +117,6 @@ SubShader {
#endif
};
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
int _UIVertexColorAlwaysGammaSpace;
pixel_t VertShader(vertex_t input)
{
@@ -131,7 +127,7 @@ SubShader {
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float bold = step(input.texcoord0.w, 0);
float bold = step(input.texcoord1.y, 0);
float4 vert = input.vertex;
vert.x += _VertexOffsetX;
@@ -142,7 +138,7 @@ SubShader {
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float scale = rsqrt(dot(pixelSize, pixelSize));
scale *= abs(input.texcoord0.w) * _GradientScale * (_Sharpness + 1);
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;
@@ -154,11 +150,7 @@ SubShader {
float bias = (0.5 - weight) * scale - 0.5;
float outline = _OutlineWidth * _ScaleRatioA * 0.5 * scale;
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
{
input.color.rgb = UIGammaToLinear(input.color.rgb);
}
float opacity = input.color.a;
float opacity = input.color.a;
#if (UNDERLAY_ON | UNDERLAY_INNER)
opacity = 1.0;
#endif
@@ -190,9 +182,7 @@ SubShader {
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);
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
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);
@@ -7,15 +7,15 @@ Shader "TextMeshPro/Mobile/Distance Field (Surface)" {
Properties {
_FaceTex ("Fill Texture", 2D) = "white" {}
_FaceColor ("Fill Color", Color) = (1,1,1,1)
[HDR]_FaceColor ("Fill Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
[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
_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
[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
@@ -99,8 +99,7 @@ SubShader {
#pragma multi_compile_shadowcaster
#include "UnityCG.cginc"
struct v2f
{
struct v2f {
V2F_SHADOW_CASTER;
float2 uv : TEXCOORD1;
float2 uv2 : TEXCOORD3;
@@ -4,10 +4,10 @@ Properties {
_FaceTex ("Fill Texture", 2D) = "white" {}
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
_FaceColor ("Fill Color", Color) = (1,1,1,1)
[HDR]_FaceColor ("Fill Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
[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
@@ -28,12 +28,12 @@ Properties {
_ReflectOutlineColor ("Outline Color", Color) = (0,0,0,1)
_Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ }
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
_SpecColor ("Specular Color", Color) = (0,0,0,1)
[HDR]_SpecColor ("Specular Color", Color) = (0,0,0,1)
_FaceShininess ("Face Shininess", Range(0,1)) = 0
_OutlineShininess ("Outline Shininess", Range(0,1)) = 0
_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
[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
@@ -118,8 +118,7 @@ SubShader {
#pragma multi_compile_shadowcaster
#include "UnityCG.cginc"
struct v2f
{
struct v2f {
V2F_SHADOW_CASTER;
float2 uv : TEXCOORD1;
float2 uv2 : TEXCOORD3;
File diff suppressed because it is too large. Load diff
@@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: a3d800b099a06e0478fb790c5e79057a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
File diff suppressed because it is too large. Load diff
@@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: 124c112a6e8f1a54e8b0870e881b56d8
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
@@ -4,10 +4,10 @@ Properties {
_FaceTex ("Face Texture", 2D) = "white" {}
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
_FaceColor ("Face Color", Color) = (1,1,1,1)
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
[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
@@ -21,7 +21,7 @@ Properties {
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
_LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416
_SpecularColor ("Specular", Color) = (1,1,1,1)
[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
@@ -37,13 +37,13 @@ Properties {
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
[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
_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
[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
@@ -127,18 +127,17 @@ SubShader {
#include "TMPro_Properties.cginc"
#include "TMPro.cginc"
struct vertex_t
{
struct vertex_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
float4 position : POSITION;
float3 normal : NORMAL;
fixed4 color : COLOR;
float4 texcoord0 : TEXCOORD0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t
{
struct pixel_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
float4 position : SV_POSITION;
@@ -148,20 +147,16 @@ SubShader {
float4 mask : TEXCOORD2; // Position in object space(xy), pixel Size(zw)
float3 viewDir : TEXCOORD3;
#if (UNDERLAY_ON || UNDERLAY_INNER)
#if (UNDERLAY_ON || UNDERLAY_INNER)
float4 texcoord2 : TEXCOORD4; // u,v, scale, bias
fixed4 underlayColor : COLOR1;
#endif
float4 textures : TEXCOORD5;
#endif
float4 textures : TEXCOORD5;
};
// Used by Unity internally to handle Texture Tiling and Offset.
float4 _FaceTex_ST;
float4 _OutlineTex_ST;
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
int _UIVertexColorAlwaysGammaSpace;
pixel_t VertShader(vertex_t input)
{
@@ -172,7 +167,7 @@ SubShader {
UNITY_TRANSFER_INSTANCE_ID(input,output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float bold = step(input.texcoord0.w, 0);
float bold = step(input.texcoord1.y, 0);
float4 vert = input.position;
vert.x += _VertexOffsetX;
@@ -183,7 +178,7 @@ SubShader {
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.texcoord0.w) * _GradientScale * (_Sharpness + 1);
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;
@@ -193,13 +188,13 @@ SubShader {
float alphaClip = (1.0 - _OutlineWidth * _ScaleRatioA - _OutlineSoftness * _ScaleRatioA);
#if GLOW_ON
#if GLOW_ON
alphaClip = min(alphaClip, 1.0 - _GlowOffset * _ScaleRatioB - _GlowOuter * _ScaleRatioB);
#endif
#endif
alphaClip = alphaClip / 2.0 - ( .5 / scale) - weight;
#if (UNDERLAY_ON || UNDERLAY_INNER)
#if (UNDERLAY_ON || UNDERLAY_INNER)
float4 underlayColor = _UnderlayColor;
underlayColor.rgb *= underlayColor.a;
@@ -210,28 +205,23 @@ SubShader {
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
float2 bOffset = float2(x, y);
#endif
#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 = input.texcoord1;
float2 textureUV = UnpackUV(input.texcoord1.x);
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
{
input.color.rgb = UIGammaToLinear(input.color.rgb);
}
output.position = vPosition;
output.color = input.color;
output.atlas = input.texcoord0;
output.param = float4(alphaClip, scale, bias, weight);
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
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);
@@ -249,9 +239,9 @@ SubShader {
float c = tex2D(_MainTex, input.atlas).a;
#ifndef UNDERLAY_ON
#ifndef UNDERLAY_ON
clip(c - input.param.x);
#endif
#endif
float scale = input.param.y;
float bias = input.param.z;
@@ -271,7 +261,7 @@ SubShader {
faceColor = GetColor(sd, faceColor, outlineColor, outline, softness);
#if BEVEL_ON
#if BEVEL_ON
float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0);
float3 n = GetSurfaceNormal(input.atlas, weight, dxy);
@@ -288,35 +278,36 @@ SubShader {
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
#endif
#if UNDERLAY_ON
#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
#endif
#if UNDERLAY_INNER
#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
#endif
#if GLOW_ON
#if GLOW_ON
float4 glowColor = GetGlowColor(sd, scale);
faceColor.rgb += glowColor.rgb * glowColor.a;
#endif
#endif
// Alternative implementation to UnityGet2DClipping with support for softness.
#if UNITY_UI_CLIP_RECT
#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
#endif
#if UNITY_UI_ALPHACLIP
#if UNITY_UI_ALPHACLIP
clip(faceColor.a - 0.001);
#endif
#endif
return faceColor * input.color.a;
return faceColor * input.color.a;
}
ENDCG
}
}
@@ -2,18 +2,18 @@ Shader "TextMeshPro/Sprite"
{
Properties
{
_MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_CullMode ("Cull Mode", Float) = 0
_ColorMask ("Color Mask", Float) = 15
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
[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
}
@@ -21,19 +21,19 @@ Shader "TextMeshPro/Sprite"
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
@@ -58,7 +58,7 @@ Shader "TextMeshPro/Sprite"
#pragma multi_compile __ UNITY_UI_CLIP_RECT
#pragma multi_compile __ UNITY_UI_ALPHACLIP
struct appdata_t
{
float4 vertex : POSITION;
@@ -69,43 +69,29 @@ Shader "TextMeshPro/Sprite"
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
float4 mask : TEXCOORD2;
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;
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
int _UIVertexColorAlwaysGammaSpace;
v2f vert(appdata_t v)
{
v2f OUT;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
float4 vPosition = UnityObjectToClipPos(v.vertex);
OUT.worldPosition = v.vertex;
OUT.vertex = vPosition;
OUT.worldPosition = v.vertex;
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
float2 pixelSize = vPosition.w;
pixelSize /= abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
OUT.mask = half4(v.vertex.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_UIMaskSoftnessX, _UIMaskSoftnessY) + abs(pixelSize.xy)));
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
{
v.color.rgb = UIGammaToLinear(v.color.rgb);
}
OUT.color = v.color * _Color;
return OUT;
}
@@ -113,10 +99,9 @@ Shader "TextMeshPro/Sprite"
fixed4 frag(v2f IN) : SV_Target
{
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
#if UNITY_UI_CLIP_RECT
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
color *= m.x * m.y;
#ifdef UNITY_UI_CLIP_RECT
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
#endif
#ifdef UNITY_UI_ALPHACLIP
@@ -125,7 +110,7 @@ Shader "TextMeshPro/Sprite"
return color;
}
ENDCG
ENDCG
}
}
}
@@ -4,6 +4,6 @@ ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData: Version 2.0
userData:
assetBundleName:
assetBundleVariant:
@@ -1,22 +1,20 @@
struct vertex_t
{
struct vertex_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
float4 position : POSITION;
float3 normal : NORMAL;
float4 color : COLOR;
float4 texcoord0 : TEXCOORD0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct pixel_t
{
struct pixel_t {
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
float4 position : SV_POSITION;
float4 faceColor : COLOR;
float4 outlineColor : COLOR1;
float4 texcoord0 : TEXCOORD0;
float4 param : TEXCOORD1; // x = weight, y = no longer used
float4 param : TEXCOORD1; // weight, scaleRatio
float2 mask : TEXCOORD2;
#if (UNDERLAY_ON || UNDERLAY_INNER)
float4 texcoord2 : TEXCOORD3;
@@ -24,14 +22,10 @@ struct pixel_t
#endif
};
float4 SRGBToLinear(float4 rgba)
{
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);
}
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
pixel_t VertShader(vertex_t input)
{
pixel_t output;
@@ -41,7 +35,7 @@ pixel_t VertShader(vertex_t input)
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float bold = step(input.texcoord0.w, 0);
float bold = step(input.texcoord1.y, 0);
float4 vert = input.position;
vert.x += _VertexOffsetX;
@@ -77,7 +71,7 @@ pixel_t VertShader(vertex_t input)
output.faceColor = faceColor;
output.outlineColor = outlineColor;
output.texcoord0 = float4(input.texcoord0.xy, maskUV.xy);
output.param = float4(0.5 - weight, 0, _OutlineWidth * _ScaleRatioA * 0.5, 0);
output.param = float4(0.5 - weight, 1.3333 * _GradientScale * (_Sharpness + 1) / _TextureWidth, _OutlineWidth * _ScaleRatioA * 0.5, 0);
float2 mask = float2(0, 0);
#if UNITY_UI_CLIP_RECT
@@ -105,9 +99,8 @@ float4 PixShader(pixel_t input) : SV_Target
float d = tex2D(_MainTex, input.texcoord0.xy).a;
float pixelSize = abs(ddx(input.texcoord0.y)) + abs(ddy(input.texcoord0.y));
pixelSize *= _TextureHeight * 0.75;
float scale = 1 / pixelSize * _GradientScale * (_Sharpness + 1);
float2 UV = input.texcoord0.xy;
float scale = rsqrt(abs(ddx(UV.x) * ddy(UV.y) - ddy(UV.x) * ddx(UV.y))) * input.param.y;
#if (UNDERLAY_ON | UNDERLAY_INNER)
float layerScale = scale;
@@ -119,7 +112,7 @@ float4 PixShader(pixel_t input) : SV_Target
float4 faceColor = input.faceColor * saturate((d - input.param.x) * scale + 0.5);
#if OUTLINE_ON
#ifdef OUTLINE_ON
float4 outlineColor = lerp(input.faceColor, input.outlineColor, sqrt(min(1.0, input.param.z * scale * 2)));
faceColor = lerp(outlineColor, input.faceColor, saturate((d - input.param.x - input.param.z) * scale + 0.5));
faceColor *= saturate((d - input.param.x + input.param.z) * scale + 0.5);
@@ -137,7 +130,7 @@ float4 PixShader(pixel_t input) : SV_Target
faceColor += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * (1 - saturate(d - layerBias)) * sd * (1 - faceColor.a);
#endif
#if MASKING
#ifdef MASKING
float a = abs(_MaskInverse - tex2D(_MaskTex, input.texcoord0.zw).a);
float t = a + (1 - _MaskWipeControl) * _MaskEdgeSoftness - _MaskWipeControl;
a = saturate(t / _MaskEdgeSoftness);
@@ -147,8 +140,7 @@ float4 PixShader(pixel_t input) : SV_Target
// Alternative implementation to UnityGet2DClipping with support for softness
#if UNITY_UI_CLIP_RECT
half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
float2 maskZW = 0.25 / (0.25 * maskSoftness + 1 / scale);
float2 maskZW = 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + (1 / scale));
float2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * maskZW);
faceColor *= m.x * m.y;
#endif
@@ -66,6 +66,11 @@ uniform float _MaskID;
uniform sampler2D _MaskTex;
uniform float4 _MaskCoord;
uniform float4 _ClipRect; // bottom left(x,y) : top right(z,w)
//uniform float _MaskWipeControl;
//uniform float _MaskEdgeSoftness;
//uniform fixed4 _MaskEdgeColor;
//uniform bool _MaskInverse;
uniform float _MaskSoftnessX;
uniform float _MaskSoftnessY;
@@ -5,7 +5,7 @@ void VertShader(inout appdata_full v, out Input data)
UNITY_INITIALIZE_OUTPUT(Input, data);
float bold = step(v.texcoord.w, 0);
float bold = step(v.texcoord1.y, 0);
// Generate normal for backface
float3 view = ObjSpaceViewDir(v.vertex);
@@ -20,12 +20,14 @@ void VertShader(inout appdata_full v, out Input data)
pixelSize /= float2(_ScaleX, _ScaleY) * mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy);
float scale = rsqrt(dot(pixelSize, pixelSize));
scale *= abs(v.texcoord.w) * _GradientScale * (_Sharpness + 1);
scale *= abs(v.texcoord1.y) * _GradientScale * (_Sharpness + 1);
scale = lerp(scale * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(v.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
data.param.y = scale;
#endif
data.param.x = (lerp(_WeightNormal, _WeightBold, bold) / 4.0 + _FaceDilate) * _ScaleRatioA * 0.5; //
data.param.x = (lerp(_WeightNormal, _WeightBold, bold) / 4.0 + _FaceDilate) * _ScaleRatioA * 0.5; //
v.texcoord1.xy = UnpackUV(v.texcoord1.x);
data.viewDirEnv = mul((float3x3)_EnvMatrix, WorldSpaceViewDir(v.vertex));
}
@@ -80,7 +82,7 @@ void PixShader(Input input, inout SurfaceOutput o)
float3 n = float3(0, 0, -1);
float3 emission = float3(0, 0, 0);
#endif
#if GLOW_ON
float4 glowColor = GetGlowColor(sd, scale);
glowColor.a *= input.color.a;
@@ -10,8 +10,10 @@ RenderTexture:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_IsAlphaChannelOptional: 0
serializedVersion: 6
serializedVersion: 5
m_Width: 800
m_Height: 448
m_AntiAliasing: 1
@@ -22,7 +24,6 @@ RenderTexture:
m_GenerateMips: 1
m_SRGB: 0
m_UseDynamicScale: 0
m_UseDynamicScaleExplicit: 0
m_BindMS: 0
m_EnableCompatibleFormat: 1
m_EnableRandomWrite: 0
+18 -24
View File
@@ -34,9 +34,9 @@ namespace Editor
#elif PAL3A
[MenuItem("PAL3A/Switch Variant/PAL3", true)]
#endif
public static bool ValidateSwitchToPal3()
static bool ValidateSwitchToPal3()
{
return !SymbolsHelper.IsSymbolDefined("PAL3");
return !SymbolsHelper.HasSymbol("PAL3");
}
#if PAL3
@@ -59,9 +59,9 @@ namespace Editor
#elif PAL3A
[MenuItem("PAL3A/Switch Variant/PAL3A", true)]
#endif
public static bool ValidateSwitchToPal3A()
static bool ValidateSwitchToPal3A()
{
return !SymbolsHelper.IsSymbolDefined("PAL3A");
return !SymbolsHelper.HasSymbol("PAL3A");
}
private static void ApplyPlayerSettingsForVariant(string appName)
@@ -69,39 +69,33 @@ namespace Editor
PlayerSettings.productName = appName;
PlayerSettings.companyName = GameConstants.CompanyName;
string gameIconPath = $"UI/game-icon-{appName}";
Texture2D gameIcon = Resources.Load<Texture2D>(gameIconPath);
foreach (BuildTargetGroup targetGroup in SymbolsHelper.GetAllSupportedTargetGroups())
{
PlayerSettings.SetApplicationIdentifier(targetGroup,
$"{GameConstants.AppIdentifierPrefix}.{appName}");
}
var gameIconPath = $"UI/game-icon-{appName}";
var gameIcon = Resources.Load<Texture2D>(gameIconPath);
if (gameIcon == null) throw new Exception($"Game icon not found: {gameIconPath}");
// Set app icons for all supported build targets
foreach (NamedBuildTarget target in SymbolsHelper.GetAllSupportedBuildTargets())
foreach (NamedBuildTarget buildTarget in SymbolsHelper.GetAllSupportedNamedBuildTargets())
{
PlayerSettings.SetApplicationIdentifier(target,
$"{GameConstants.AppIdentifierPrefix}.{appName}");
// Set app icon
int[] iconSizes = PlayerSettings.GetIconSizes(target, IconKind.Application);
PlayerSettings.SetIcons(target,
var iconSizes = PlayerSettings.GetIconSizes(buildTarget, IconKind.Application);
PlayerSettings.SetIcons(buildTarget,
Enumerable.Repeat(gameIcon, iconSizes.Length).ToArray(),
IconKind.Application);
// Set iOS store icon which is required for store publishing or TestFlight
if (target == NamedBuildTarget.iOS)
if (buildTarget == NamedBuildTarget.iOS)
{
PlayerSettings.SetIcons(target,
PlayerSettings.SetIcons(buildTarget,
Enumerable.Repeat(gameIcon,
PlayerSettings.GetIconSizes(target, IconKind.Store).Length).ToArray(),
PlayerSettings.GetIconSizes(buildTarget, IconKind.Store).Length).ToArray(),
IconKind.Store);
}
}
// Set default app icon (I don't know why Unity decided to use NamedBuildTarget.Unknown here but it is what it is)
{
int[] iconSizes = PlayerSettings.GetIconSizes(NamedBuildTarget.Unknown, IconKind.Application);
PlayerSettings.SetIcons(NamedBuildTarget.Unknown,
Enumerable.Repeat(gameIcon, iconSizes.Length).ToArray(),
IconKind.Application);
}
}
}
}
+44 -82
View File
@@ -15,16 +15,19 @@ namespace Editor
using UnityEditor.Build.Reporting;
using UnityEngine;
#if UNITY_2020_2_OR_NEWER && UNITY_STANDALONE_OSX
using UnityEditor.OSXStandalone;
#endif
[Flags]
public enum Pal3BuildTarget
{
Windows_arm64 = 1 << 0,
Windows_x86 = 1 << 1,
Windows_x64 = 1 << 2,
Linux_x86_x64 = 1 << 3,
macOS_arm64_x64 = 1 << 4,
Android = 1 << 5,
iOS = 1 << 6,
Windows_x86 = 1 << 0,
Windows_x64 = 1 << 1,
Linux_x86_x64 = 1 << 2,
macOS_arm64_x64 = 1 << 3,
Android = 1 << 4,
iOS = 1 << 5,
}
public static class ReleaseBuildPipeline
@@ -32,17 +35,7 @@ namespace Editor
private static readonly string[] BuildLevels = { "Assets/Scenes/Game.unity" };
private static readonly char DirSeparator = Path.DirectorySeparatorChar;
#if PAL3
[MenuItem("PAL3/Build Pipelines/Build [Windows_arm64] IL2CPP Release Executable")]
#elif PAL3A
[MenuItem("PAL3A/Build Pipelines/Build [Windows_arm64] IL2CPP Release Executable")]
#endif
public static void Build_Windows_arm64()
{
BuildGame(Pal3BuildTarget.Windows_arm64);
}
#if PAL3
[MenuItem("PAL3/Build Pipelines/Build [Windows_x86] IL2CPP Release Executable")]
#elif PAL3A
@@ -110,8 +103,7 @@ namespace Editor
#endif
public static void BuildAll()
{
BuildGame(Pal3BuildTarget.Windows_arm64 |
Pal3BuildTarget.Windows_x86 |
BuildGame(Pal3BuildTarget.Windows_x86 |
Pal3BuildTarget.Windows_x64 |
Pal3BuildTarget.Linux_x86_x64 |
Pal3BuildTarget.macOS_arm64_x64 |
@@ -141,98 +133,69 @@ namespace Editor
var buildConfigurations = new[]
{
new { Target = Pal3BuildTarget.Windows_x86, Extension = ".exe", NamedTarget = NamedBuildTarget.Standalone },
new { Target = Pal3BuildTarget.Windows_x64, Extension = ".exe", NamedTarget = NamedBuildTarget.Standalone },
new { Target = Pal3BuildTarget.Windows_arm64, Extension = ".exe", NamedTarget = NamedBuildTarget.Standalone },
new { Target = Pal3BuildTarget.Linux_x86_x64, Extension = "", NamedTarget = NamedBuildTarget.Standalone},
new { Target = Pal3BuildTarget.macOS_arm64_x64, Extension = "", NamedTarget = NamedBuildTarget.Standalone },
new { Target = Pal3BuildTarget.Android, Extension = ".apk", NamedTarget = NamedBuildTarget.Android },
new { Target = Pal3BuildTarget.iOS, Extension = "", NamedTarget = NamedBuildTarget.iOS },
new { Platform = Pal3BuildTarget.Windows_x86, Extension = ".exe", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneWindows },
new { Platform = Pal3BuildTarget.Windows_x64, Extension = ".exe", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneWindows64 },
new { Platform = Pal3BuildTarget.Linux_x86_x64, Extension = "", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneLinux64 },
new { Platform = Pal3BuildTarget.macOS_arm64_x64, Extension = "", Group = BuildTargetGroup.Standalone, Target = BuildTarget.StandaloneOSX },
new { Platform = Pal3BuildTarget.Android, Extension = ".apk", Group = BuildTargetGroup.Android, Target = BuildTarget.Android },
new { Platform = Pal3BuildTarget.iOS, Extension = "", Group = BuildTargetGroup.iOS, Target = BuildTarget.iOS },
};
List<Action> logActions = new();
List<Action> logActions = new List<Action>();
foreach (var config in buildConfigurations)
{
if (buildTarget.HasFlag(config.Target))
if (buildTarget.HasFlag(config.Platform))
{
Build(config.Target,
Build(config.Platform.ToString(),
config.Extension,
config.NamedTarget,
config.Group,
config.Target,
buildOutputPath,
logActions);
}
}
// Restore build target settings
EditorUserBuildSettings.SwitchActiveBuildTarget(targetGroupBeforeBuild, targetBeforeBuild);
// Execute report log actions
logActions.ForEach(action => action.Invoke());
Debug.Log($"[{nameof(ReleaseBuildPipeline)}] Build for version {PlayerSettings.bundleVersion} complete! Output path: " +
$"{buildOutputPath}{GameConstants.AppName}");
// Restore build target settings
EditorUserBuildSettings.SwitchActiveBuildTargetAsync(targetGroupBeforeBuild, targetBeforeBuild);
}
private static void Build(Pal3BuildTarget target,
private static void Build(string folderName,
string extension,
NamedBuildTarget namedBuildTarget,
BuildTargetGroup buildTargetGroup,
BuildTarget buildTarget,
string buildOutputPath,
List<Action> logActions,
bool deletePdbFiles = true)
{
string outputFolder = buildOutputPath + $"{GameConstants.AppName}{DirSeparator}" +
$"{target.ToString()}{DirSeparator}";
$"{folderName}{DirSeparator}";
BuildTarget buildTarget = BuildTarget.NoTarget;
switch (target)
if (buildTarget is BuildTarget.StandaloneWindows
or BuildTarget.StandaloneWindows64
or BuildTarget.StandaloneLinux64)
{
case Pal3BuildTarget.Windows_arm64:
buildTarget = BuildTarget.StandaloneWindows64;
outputFolder += $"{GameConstants.AppName}{DirSeparator}";
#if UNITY_2020_2_OR_NEWER && UNITY_EDITOR_WIN
UnityEditor.WindowsStandalone.UserBuildSettings.architecture = OSArchitecture.ARM64;
#endif
break;
case Pal3BuildTarget.Windows_x86:
buildTarget = BuildTarget.StandaloneWindows;
outputFolder += $"{GameConstants.AppName}{DirSeparator}";
#if UNITY_2020_2_OR_NEWER && UNITY_EDITOR_WIN
UnityEditor.WindowsStandalone.UserBuildSettings.architecture = OSArchitecture.x86;
#endif
break;
case Pal3BuildTarget.Windows_x64:
buildTarget = BuildTarget.StandaloneWindows64;
outputFolder += $"{GameConstants.AppName}{DirSeparator}";
#if UNITY_2020_2_OR_NEWER && UNITY_EDITOR_WIN
UnityEditor.WindowsStandalone.UserBuildSettings.architecture = OSArchitecture.x64;
#endif
break;
case Pal3BuildTarget.Linux_x86_x64:
buildTarget = BuildTarget.StandaloneLinux64;
outputFolder += $"{GameConstants.AppName}{DirSeparator}";
break;
case Pal3BuildTarget.macOS_arm64_x64:
buildTarget = BuildTarget.StandaloneOSX;
#if UNITY_2020_2_OR_NEWER && UNITY_EDITOR_OSX
UnityEditor.OSXStandalone.UserBuildSettings.architecture = OSArchitecture.x64ARM64;
UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject = true;
#endif
break;
case Pal3BuildTarget.Android:
buildTarget = BuildTarget.Android;
break;
case Pal3BuildTarget.iOS:
buildTarget = BuildTarget.iOS;
break;
outputFolder += $"{GameConstants.AppName}{DirSeparator}";
}
else if (buildTarget is BuildTarget.StandaloneOSX)
{
#if UNITY_2020_2_OR_NEWER && UNITY_STANDALONE_OSX
UserBuildSettings.architecture = OSArchitecture.x64ARM64;
UserBuildSettings.createXcodeProject = true;
#endif
}
string outputPath = outputFolder + $"{GameConstants.AppName}{extension}";
PlayerSettings.SetScriptingBackend(namedBuildTarget, ScriptingImplementation.IL2CPP);
PlayerSettings.SetScriptingBackend(buildTargetGroup, ScriptingImplementation.IL2CPP);
BuildReport report = BuildPipeline.BuildPlayer(BuildLevels, outputPath, buildTarget, BuildOptions.CleanBuildCache);
BuildReport report = BuildPipeline.BuildPlayer(BuildLevels, outputPath, buildTarget, BuildOptions.None);
if (deletePdbFiles)
{
@@ -287,7 +250,6 @@ namespace Editor
List<(string FolderPath, Pal3BuildTarget Target)> buildTargets = new()
{
($"{GameConstants.AppName}{DirSeparator}{Pal3BuildTarget.Android.ToString()}{DirSeparator}{GameConstants.AppName}.apk", Pal3BuildTarget.Android),
($"{GameConstants.AppName}{DirSeparator}{Pal3BuildTarget.Windows_arm64.ToString()}", Pal3BuildTarget.Windows_arm64),
($"{GameConstants.AppName}{DirSeparator}{Pal3BuildTarget.Windows_x86.ToString()}", Pal3BuildTarget.Windows_x86),
($"{GameConstants.AppName}{DirSeparator}{Pal3BuildTarget.Windows_x64.ToString()}", Pal3BuildTarget.Windows_x64),
($"{GameConstants.AppName}{DirSeparator}{Pal3BuildTarget.Linux_x86_x64.ToString()}", Pal3BuildTarget.Linux_x86_x64)
@@ -52,9 +52,9 @@ namespace Editor.SourceGenerator.Base
private void WriteIndentInternal()
{
for (int i = 0; i < _indentLevel; i++)
for (var i = 0; i < _indentLevel; i++)
{
for (int j = 0; j < SpacesPerIndentLevel; j++)
for (var j = 0; j < SpacesPerIndentLevel; j++)
{
Buffer.Append(' ');
}
@@ -63,7 +63,7 @@ namespace Editor.SourceGenerator.Base
public void WriteIndent()
{
for (int i = 0; i < SpacesPerIndentLevel; i++) Buffer.Append(' ');
for (var i = 0; i < SpacesPerIndentLevel; i++) Buffer.Append(' ');
}
}
}
@@ -16,7 +16,7 @@ namespace Editor.SourceGenerator.Base
public static string GetMethodArgumentDefinitionListAsString(PropertyInfo[] properties)
{
StringBuilder argListStrBuilder = new ();
for (int i = 0; i < properties.Length; i++)
for (var i = 0; i < properties.Length; i++)
{
argListStrBuilder.Append(properties[i].PropertyType);
argListStrBuilder.Append(" ");
@@ -29,7 +29,7 @@ namespace Editor.SourceGenerator.Base
public static string GetMethodArgumentListAsString(PropertyInfo[] properties)
{
StringBuilder argListStrBuilder = new ();
for (int i = 0; i < properties.Length; i++)
for (var i = 0; i < properties.Length; i++)
{
argListStrBuilder.Append(ToLowerFirstChar(properties[i].Name));
if (i < properties.Length - 1) argListStrBuilder.Append(", ");
@@ -52,7 +52,7 @@ namespace Editor.SourceGenerator
Debug.Log($"[{nameof(ConsoleCommandsAutoGen<TCommand>)}] Found {commands.Length} available console commands");
for (int i = 0; i < commands.Length; i++)
for (var i = 0; i < commands.Length; i++)
{
string commandName = commands[i].Name.Replace("Command", string.Empty);
PropertyInfo[] properties = commands[i].GetProperties();
@@ -15,16 +15,12 @@ namespace Editor
public static class SourceGeneratorEditorOptions
{
private const string NameSpace = "Pal3.Game.Command";
private const string ClassName = "ConsoleCommands";
private const string OutputFolderPath = "Assets/Scripts/Pal3.Game/Command/";
#if PAL3
private const string GAME_VARIANT_SYMBOL = "PAL3";
private const string OutputFileName = "ConsoleCommands.PAL3.g.cs";
private static string OutputFileName = "ConsoleCommands.PAL3.g.cs";
#elif PAL3A
private const string GAME_VARIANT_SYMBOL = "PAL3A";
private const string OutputFileName = "ConsoleCommands.PAL3A.g.cs";
private static string OutputFileName = "ConsoleCommands.PAL3A.g.cs";
#endif
#if PAL3
@@ -34,9 +30,11 @@ namespace Editor
#endif
public static void GenerateConsoleCommands()
{
string writePath = $"{OutputFolderPath}{OutputFileName}";
var writePath = $"Assets/Scripts/Pal3.Game/Command/{OutputFileName}";
var nameSpace = "Pal3.Game.Command";
var className = "ConsoleCommands";
ISourceGenerator sourceGenerator = new ConsoleCommandsAutoGen<ICommand>();
GenerateSourceInternal(OutputFileName, writePath, ClassName, NameSpace, sourceGenerator, true);
GenerateSourceInternal(OutputFileName, writePath, className, nameSpace, sourceGenerator, true);
}
private static void GenerateSourceInternal(string fileName,
@@ -54,7 +52,7 @@ namespace Editor
Debug.Log($"[{nameof(SourceGeneratorEditorOptions)}] Generating source file: " + writePath);
CodeWriter writer = new()
var writer = new CodeWriter
{
Buffer = new StringBuilder(),
SpacesPerIndentLevel = 4,
@@ -63,10 +61,10 @@ namespace Editor
sourceGenerator.GenerateSourceClass(writer, className, nameSpace);
// Final output string
string output = $"#if {GAME_VARIANT_SYMBOL}\n\n{writer.Buffer}\n#endif";
var output = $"#if {GAME_VARIANT_SYMBOL}\n\n{writer.Buffer}\n#endif";
// Write to file
using StreamWriter sw = new(writePath);
using StreamWriter sw = new StreamWriter(writePath);
sw.Write(output);
Debug.Log($"[{nameof(SourceGeneratorEditorOptions)}] {fileName} generated.");
+37 -16
View File
@@ -6,13 +6,31 @@
namespace Editor
{
using System.Linq;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Build;
public static class SymbolsHelper
{
public static NamedBuildTarget[] GetAllSupportedBuildTargets()
public static BuildTargetGroup[] GetAllSupportedTargetGroups()
{
return new[]
{
BuildTargetGroup.Android,
BuildTargetGroup.Standalone,
BuildTargetGroup.iOS,
BuildTargetGroup.WSA,
BuildTargetGroup.PS4,
BuildTargetGroup.PS5,
BuildTargetGroup.XboxOne,
BuildTargetGroup.tvOS,
BuildTargetGroup.Switch,
BuildTargetGroup.GameCoreXboxOne,
BuildTargetGroup.GameCoreXboxSeries,
//BuildTargetGroup.VisionOS,
};
}
public static NamedBuildTarget[] GetAllSupportedNamedBuildTargets()
{
return new[]
{
@@ -24,42 +42,45 @@ namespace Editor
NamedBuildTarget.tvOS,
NamedBuildTarget.NintendoSwitch,
NamedBuildTarget.WindowsStoreApps,
NamedBuildTarget.VisionOS,
//NamedBuildTarget.VisionOS,
};
}
public static bool IsSymbolDefined(string symbol)
public static bool HasSymbol(string symbol)
{
return GetAllSupportedBuildTargets()
.Select(PlayerSettings.GetScriptingDefineSymbols)
return GetAllSupportedTargetGroups()
.Select(PlayerSettings.GetScriptingDefineSymbolsForGroup)
.Select(defines => defines.Split(';').ToList())
.All(allDefines => allDefines.Contains(symbol));
}
public static void AddSymbol(string symbolToAdd)
{
foreach (NamedBuildTarget target in GetAllSupportedBuildTargets())
foreach (BuildTargetGroup targetGroup in GetAllSupportedTargetGroups())
{
string defines = PlayerSettings.GetScriptingDefineSymbols(target);
List<string> allDefines = defines.Split(';').ToList();
if (!allDefines.Contains(symbolToAdd))
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
var allDefines = defines.Split(';').ToList();
if (!allDefines.Any(_ => string.Equals(_, symbolToAdd)))
{
allDefines.Add(symbolToAdd);
}
allDefines.Sort();
PlayerSettings.SetScriptingDefineSymbols(target, string.Join(";", allDefines));
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup,
string.Join(";", allDefines.ToArray()));
}
}
public static void RemoveSymbol(string symbolToDelete)
{
foreach (NamedBuildTarget target in GetAllSupportedBuildTargets())
foreach (BuildTargetGroup targetGroup in GetAllSupportedTargetGroups())
{
string defines = PlayerSettings.GetScriptingDefineSymbols(target);
List<string> allDefines = defines.Split(';').ToList();
List<string> newDefines = allDefines.Where(d => !string.Equals(d, symbolToDelete)).ToList();
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
var allDefines = defines.Split(';').ToList();
var newDefines = allDefines
.Where(_ => !string.Equals(_, symbolToDelete)).ToList();
newDefines.Sort();
PlayerSettings.SetScriptingDefineSymbols(target, string.Join(";", newDefines));
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup,
string.Join(";", newDefines.ToArray()));
}
}
}
@@ -71,10 +71,10 @@ namespace Engine.Animation
yield break;
}
float timePast = 0f;
var timePast = 0f;
while (timePast < duration && !cancellationToken.IsCancellationRequested)
{
float newValue = Lerp(from, to, GetInterpolationRatio(timePast / duration, curveType));
var newValue = Lerp(from, to, GetInterpolationRatio(timePast / duration, curveType));
onValueChanged?.Invoke(newValue);
timePast += GameTimeProvider.Instance.DeltaTime;
yield return null;
@@ -95,7 +95,7 @@ namespace Engine.Animation
{
Vector3 oldPosition = target.Position;
float timePast = 0f;
var timePast = 0f;
while (timePast < duration && !target.IsNativeObjectDisposed && !cancellationToken.IsCancellationRequested)
{
target.Position = oldPosition + (toPosition - oldPosition) *
@@ -139,10 +139,10 @@ namespace Engine.Animation
float distanceDelta,
CancellationToken cancellationToken = default)
{
float distance = Vector3.Distance(target.Position, centerPoint);
var distance = Vector3.Distance(target.Position, centerPoint);
Quaternion startRotation = target.Rotation;
float timePast = 0f;
var timePast = 0f;
while (timePast < duration && !target.IsNativeObjectDisposed && !cancellationToken.IsCancellationRequested)
{
Quaternion newRotation = Quaternion.Slerp(startRotation, toRotation,
@@ -174,7 +174,7 @@ namespace Engine.Animation
{
Quaternion startRotation = target.Rotation;
float timePast = 0f;
var timePast = 0f;
while (timePast < duration && !target.IsNativeObjectDisposed && !cancellationToken.IsCancellationRequested)
{
Quaternion rotation = Quaternion.Slerp(startRotation, toRotation,
@@ -109,10 +109,10 @@ namespace Engine.Core.Implementation
public T GetOrAddComponent<T>() where T : class
{
T component = GetComponent<T>();
var component = GetComponent<T>();
// Since ?? operation does not work well with UnityObject
// So I have to use the old fashion here checking if it is null.
// so I have to use the old fashion here checking if it is null.
if (component as UnityEngine.Object == null)
{
component = AddComponent<T>();
@@ -18,7 +18,7 @@ namespace Engine.Core.Implementation
throw new ArgumentException("rgba32DataBuffer.Length < width * height * 4");
}
Texture2D texture = new Texture2D(width, height, TextureFormat.RGBA32, mipChain: false);
var texture = new Texture2D(width, height, TextureFormat.RGBA32, mipChain: false);
texture.LoadRawTextureData(rgba32DataBuffer);
texture.Apply(updateMipmaps: false);
return new UnityTexture2D(texture);
@@ -31,8 +31,8 @@ namespace Engine.DataLoader
{
if (_rawRgbaDataBuffer != null) throw new Exception("DXT texture already loaded");
using MemoryStream stream = new(data);
using BinaryReader headerReader = new(stream);
using var stream = new MemoryStream(data);
using var headerReader = new BinaryReader(stream);
if (new string(headerReader.ReadChars(4)) != "DDS ")
{
@@ -31,8 +31,8 @@ namespace Engine.Extensions
float scale = GameBoxUnitToUnityUnit)
{
if (gameBoxPositions == null) return null;
UnityEngine.Vector3[] unityPositions = new UnityEngine.Vector3[gameBoxPositions.Length];
for (int i = 0; i < gameBoxPositions.Length; i++)
var unityPositions = new UnityEngine.Vector3[gameBoxPositions.Length];
for (var i = 0; i < gameBoxPositions.Length; i++)
{
unityPositions[i] = ToUnityVector3(gameBoxPositions[i], scale);
}
@@ -49,7 +49,7 @@ namespace Engine.Extensions
throw new ArgumentException("gameBoxPositions and unityPositionsBuffer must be non-null and have the same length");
}
for (int i = 0; i < gameBoxPositions.Length; i++)
for (var i = 0; i < gameBoxPositions.Length; i++)
{
unityPositionsBuffer[i] = ToUnityVector3(gameBoxPositions[i], scale);
}
@@ -148,8 +148,8 @@ namespace Engine.Extensions
public static UnityEngine.Vector3[] ToUnityNormals(this GameBoxVector3[] gameBoxNormals)
{
if (gameBoxNormals == null) return null;
UnityEngine.Vector3[] unityNormals = new UnityEngine.Vector3[gameBoxNormals.Length];
for (int i = 0; i < gameBoxNormals.Length; i++)
var unityNormals = new UnityEngine.Vector3[gameBoxNormals.Length];
for (var i = 0; i < gameBoxNormals.Length; i++)
{
unityNormals[i] = ToUnityNormal(gameBoxNormals[i]);
}
@@ -166,7 +166,7 @@ namespace Engine.Extensions
throw new ArgumentException("gameBoxNormals and unityNormalsBuffer must be non-null and have the same length");
}
for (int i = 0; i < gameBoxNormals.Length; i++)
for (var i = 0; i < gameBoxNormals.Length; i++)
{
unityNormalsBuffer[i] = ToUnityNormal(gameBoxNormals[i]);
}
@@ -248,8 +248,8 @@ namespace Engine.Extensions
public static int[] ToUnityTriangles(this int[] gameBoxTriangles)
{
if (gameBoxTriangles == null) return null;
int[] unityTriangles = new int[gameBoxTriangles.Length];
for (int i = 0; i < gameBoxTriangles.Length; i++)
var unityTriangles = new int[gameBoxTriangles.Length];
for (var i = 0; i < gameBoxTriangles.Length; i++)
{
unityTriangles[i] = gameBoxTriangles[gameBoxTriangles.Length - 1 - i];
}
@@ -271,7 +271,7 @@ namespace Engine.Extensions
throw new ArgumentException("gameBoxTriangles and unityTrianglesBuffer must be non-null and have the same length");
}
for (int i = 0; i < gameBoxTriangles.Length; i++)
for (var i = 0; i < gameBoxTriangles.Length; i++)
{
unityTrianglesBuffer[i] = gameBoxTriangles[gameBoxTriangles.Length - 1 - i];
}
@@ -309,8 +309,8 @@ namespace Engine.Extensions
public static UnityEngine.Vector2[] ToUnityVector2s(this GameBoxVector2[] gameBoxVector2s)
{
if (gameBoxVector2s == null) return null;
UnityEngine.Vector2[] unityVector2s = new UnityEngine.Vector2[gameBoxVector2s.Length];
for (int i = 0; i < gameBoxVector2s.Length; i++)
var unityVector2s = new UnityEngine.Vector2[gameBoxVector2s.Length];
for (var i = 0; i < gameBoxVector2s.Length; i++)
{
unityVector2s[i] = gameBoxVector2s[i].ToUnityVector2();
}
@@ -326,7 +326,7 @@ namespace Engine.Extensions
throw new ArgumentException("gameBoxVector2s and unityVector2sBuffer must be non-null and have the same length");
}
for (int i = 0; i < gameBoxVector2s.Length; i++)
for (var i = 0; i < gameBoxVector2s.Length; i++)
{
unityVector2sBuffer[i] = gameBoxVector2s[i].ToUnityVector2();
}
@@ -358,8 +358,8 @@ namespace Engine.Extensions
public static UnityEngine.Color32[] ToUnityColor32s(this Color32[] gameBoxColor32s)
{
if (gameBoxColor32s == null) return null;
UnityEngine.Color32[] unityColor32s = new UnityEngine.Color32[gameBoxColor32s.Length];
for (int i = 0; i < gameBoxColor32s.Length; i++)
var unityColor32s = new UnityEngine.Color32[gameBoxColor32s.Length];
for (var i = 0; i < gameBoxColor32s.Length; i++)
{
unityColor32s[i] = gameBoxColor32s[i].ToUnityColor32();
}
@@ -68,7 +68,7 @@ namespace Engine.Renderer
_animationCts.Cancel();
_animationCts = new CancellationTokenSource();
CancellationToken cancellationToken = _animationCts.Token;
var cancellationToken = _animationCts.Token;
_spriteRenderer.enabled = true;
@@ -1,5 +1,5 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2024, Jiaqi (0x7c13) Liu. All rights reserved.
// Copyright (c) 2021-2022, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
@@ -28,7 +28,7 @@ namespace Engine.Services
}
else
{
_textureCache[key] = (texture, hasAlphaChannel);
_textureCache[key] = new (texture, hasAlphaChannel);
}
}
@@ -24,7 +24,7 @@ namespace Engine.UI
private void Update()
{
float currentRatio = (float) Screen.width / Screen.height;
var currentRatio = (float) Screen.width / Screen.height;
_transform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, currentRatio > thresholdRatio
? _transform.rect.height * thresholdRatio - padding
: _transform.rect.height * currentRatio - padding);
@@ -92,10 +92,7 @@ namespace Engine.UI
if (_material == null)
{
_material = new Material(_shader)
{
hideFlags = HideFlags.HideAndDontSave
};
_material = new Material(_shader);
}
if (image == null)
@@ -24,7 +24,7 @@
public Color mainColor = new Color(0f, 1f, 0f, 1f);
public Color subColor = new Color(0f, 0.5f, 0f, 1f);
private void CreateLineMaterial()
void CreateLineMaterial()
{
if (!_lineMaterial)
{
@@ -43,7 +43,7 @@
}
}
private void OnPostRender()
void OnPostRender()
{
CreateLineMaterial();
+2 -2
View File
@@ -22,11 +22,11 @@ namespace Engine.Utilities
{
if (_instance != null) return _instance;
_instance = (T)FindFirstObjectByType(typeof(T));
_instance = FindObjectOfType<T>();
if (_instance != null) return _instance;
GameObject singletonObj = new()
var singletonObj = new GameObject
{
name = typeof(T).ToString()
};
@@ -34,20 +34,20 @@ namespace Engine.Utilities
public static void DrawBounds(Bounds b, float duration = 1000)
{
Vector3 p1 = new(b.min.x, b.min.y, b.min.z);
Vector3 p2 = new(b.max.x, b.min.y, b.min.z);
Vector3 p3 = new(b.max.x, b.min.y, b.max.z);
Vector3 p4 = new (b.min.x, b.min.y, b.max.z);
var p1 = new Vector3(b.min.x, b.min.y, b.min.z);
var p2 = new Vector3(b.max.x, b.min.y, b.min.z);
var p3 = new Vector3(b.max.x, b.min.y, b.max.z);
var p4 = new Vector3(b.min.x, b.min.y, b.max.z);
Debug.DrawLine(p1, p2, Color.blue, duration);
Debug.DrawLine(p2, p3, Color.red, duration);
Debug.DrawLine(p3, p4, Color.yellow, duration);
Debug.DrawLine(p4, p1, Color.magenta, duration);
Vector3 p5 = new(b.min.x, b.max.y, b.min.z);
Vector3 p6 = new(b.max.x, b.max.y, b.min.z);
Vector3 p7 = new(b.max.x, b.max.y, b.max.z);
Vector3 p8 = new(b.min.x, b.max.y, b.max.z);
var p5 = new Vector3(b.min.x, b.max.y, b.min.z);
var p6 = new Vector3(b.max.x, b.max.y, b.min.z);
var p7 = new Vector3(b.max.x, b.max.y, b.max.z);
var p8 = new Vector3(b.min.x, b.max.y, b.max.z);
Debug.DrawLine(p5, p6, Color.blue, duration);
Debug.DrawLine(p6, p7, Color.red, duration);
@@ -77,7 +77,7 @@ namespace Engine.Utilities
{
IntPtr versionClass = AndroidJNI.FindClass("android.os.Build$VERSION");
IntPtr sdkFieldID = AndroidJNI.GetStaticFieldID(versionClass, "SDK_INT", "I");
int sdkLevel = AndroidJNI.GetStaticIntField(versionClass, sdkFieldID);
var sdkLevel = AndroidJNI.GetStaticIntField(versionClass, sdkFieldID);
return sdkLevel;
}
@@ -88,12 +88,12 @@ namespace Pal3.Core.Algorithm.PathFinding
Func<(int x, int y), bool> isObstacle,
Func<(int x, int y), (int x, int y), int> heuristicFunc)
{
SearchNode[,] nodes = new SearchNode[gridSize.width, gridSize.height];
var nodes = new SearchNode[gridSize.width, gridSize.height];
// Init
for (int x = 0; x < gridSize.width; x++)
for (var x = 0; x < gridSize.width; x++)
{
for (int y = 0; y < gridSize.height; y++)
for (var y = 0; y < gridSize.height; y++)
{
(int x, int y) position = (x, y);
var node = new SearchNode()
@@ -139,13 +139,13 @@ namespace Pal3.Core.Algorithm.PathFinding
{
node.SetParent(null, float.MaxValue);
List<SearchNode> currentNeighbors = GetNeighbors(node, nodes);
for (int i = 0; i < currentNeighbors.Count; i++)
var currentNeighbors = GetNeighbors(node, nodes);
for (var i = 0; i < currentNeighbors.Count; i++)
{
SearchNode neighbor = currentNeighbors[i];
if (neighbor.Closed)
{
float newGCost = neighbor.GCost +
var newGCost = neighbor.GCost +
heuristicFunc((neighbor.X, neighbor.Y), (node.X, node.Y));
if (newGCost < node.GCost)
node.SetParent(neighbor, newGCost);
@@ -160,8 +160,8 @@ namespace Pal3.Core.Algorithm.PathFinding
node.SearchType = SearchType.Expanded;
node.Closed = true;
List<SearchNode> neighbors = GetNeighbors(node, nodes);
for (int i = 0; i < neighbors.Count; i++)
var neighbors = GetNeighbors(node, nodes);
for (var i = 0; i < neighbors.Count; i++)
{
SearchNode neighbor = neighbors[i];
if (IsNeighborValid(neighbor))
@@ -182,7 +182,7 @@ namespace Pal3.Core.Algorithm.PathFinding
}
}
List<(int x, int y)> path = new();
var path = new List<(int x, int y)>();
SearchNode lastNode = GetNode(endNode.X, endNode.Y, nodes);
while (lastNode != null)
{
@@ -85,7 +85,7 @@ namespace Pal3.Core.Command
{
ushort length = reader.ReadUInt16(); // First 2 bytes is array length
object[] propertyArray = new object[length];
for (int i = 0; i < length; i++)
for (var i = 0; i < length; i++)
{
Type varType = GetVariableType(reader.ReadByte());
// Read from the end of the array to the beginning by design
@@ -88,7 +88,7 @@ namespace Pal3.Core.Command
}
uint hashCode = GetHashCode(commandId, userVariableMask);
return SceCommandTypeCache.GetValueOrDefault(hashCode);
return SceCommandTypeCache.TryGetValue(hashCode, out Type type) ? type : null; // not found
}
}
}
@@ -12,19 +12,19 @@ namespace Pal3.Core.Contract.Constants
{
public static readonly Dictionary<ActorEmojiType, (int Width, int Height, int Frames)> TextureInfo = new()
{
{ ActorEmojiType.Sleepy, (38, 54, 6) },
{ ActorEmojiType.Shock, (25, 57, 10) },
{ ActorEmojiType.Doubt, (31, 43, 10) },
{ ActorEmojiType.Anger, (82, 51, 3) },
{ ActorEmojiType.Happy, (54, 32, 2) },
{ ActorEmojiType.Heart, (31, 41, 4) },
{ ActorEmojiType.Sweat, (16, 111, 7) },
{ ActorEmojiType.Bother, (64, 46, 3) },
{ ActorEmojiType.Anxious, (54, 32, 2) },
{ ActorEmojiType.Cry, (49, 40, 8) },
{ ActorEmojiType.Dizzy, (70, 42, 6) },
{ ActorEmojiType.Sleepy, new(38, 54, 6) },
{ ActorEmojiType.Shock, new(25, 57, 10) },
{ ActorEmojiType.Doubt, new(31, 43, 10) },
{ ActorEmojiType.Anger, new(82, 51, 3) },
{ ActorEmojiType.Happy, new(54, 32, 2) },
{ ActorEmojiType.Heart, new(31, 41, 4) },
{ ActorEmojiType.Sweat, new(16, 111, 7) },
{ ActorEmojiType.Bother, new(64, 46, 3) },
{ ActorEmojiType.Anxious, new(54, 32, 2) },
{ ActorEmojiType.Cry, new(49, 40, 8) },
{ ActorEmojiType.Dizzy, new(70, 42, 6) },
#if PAL3A
{ ActorEmojiType.Speechless, (64, 46, 4) },
{ ActorEmojiType.Speechless, new(64, 46, 4) },
#endif
};
@@ -186,12 +186,14 @@ namespace Pal3.Core.DataReader.Cpk
throw new InvalidOperationException("Initialize the archive before accessing its content");
}
if (!_crcToTableEntityMap.TryGetValue(fileVirtualPathCrcHash, out CpkTableEntity entity))
if (!_crcToTableEntityMap.ContainsKey(fileVirtualPathCrcHash))
{
throw new FileNotFoundException(
$"File <{fileVirtualPathCrcHash}> does not exists in the archive");
}
CpkTableEntity entity = _crcToTableEntityMap[fileVirtualPathCrcHash];
if (entity.IsDirectory())
{
throw new InvalidOperationException(
@@ -208,7 +210,7 @@ namespace Pal3.Core.DataReader.Cpk
}
else
{
using FileStream stream = new(_filePath, FileMode.Open, FileAccess.Read);
using var stream = new FileStream(_filePath, FileMode.Open, FileAccess.Read);
stream.Seek(entity.StartPos, SeekOrigin.Begin);
byte[] buffer = new byte[entity.PackedSize];
_ = stream.Read(buffer.AsSpan());
@@ -31,7 +31,7 @@ namespace Pal3.Core.DataReader.Cpk
for (uint i = 0; i <= CRC_TABLE_MAX; i++)
{
uint crcAccum = i << 24;
for (int j = 0; j < 8; j++)
for (var j = 0; j < 8; j++)
{
crcAccum = (crcAccum & 0x80000000L) != 0 ?
(crcAccum << 1) ^ POLYNOMIAL :
@@ -16,20 +16,20 @@ namespace Pal3.Core.DataReader.Cvd
{
public CvdFile Read(IBinaryReader reader, int codepage)
{
char[] header = reader.ReadChars(4);
string headerStr = new (header);
var header = reader.ReadChars(4);
var headerStr = new string(header);
float version = headerStr switch
var version = headerStr switch
{
"cvdf" => 0.4f,
"cvds" => 0.5f,
_ => throw new InvalidDataException($"Invalid CVD(.cvd) file: header != cvdf or cvds")
};
float animationDuration = 0f;
int numberONodes = reader.ReadInt32();
List<CvdGeometryNode> rootNodes = new();
for (int i = 0; i < numberONodes; i++)
var animationDuration = 0f;
var numberONodes = reader.ReadInt32();
var rootNodes = new List<CvdGeometryNode>();
for (var i = 0; i < numberONodes; i++)
{
ReadGeometryNodes(reader, version, rootNodes, ref animationDuration, codepage);
}
@@ -45,17 +45,17 @@ namespace Pal3.Core.DataReader.Cvd
{
CvdGeometryNode parentNode = default;
byte isGeometryNode = reader.ReadByte();
var isGeometryNode = reader.ReadByte();
if (isGeometryNode == 1)
{
parentNode = ReadGeometryNode(reader, version, ref animationDuration, codepage);
parentNode.IsGeometryNode = true;
}
int numberOfChildNodes = reader.ReadInt32();
var numberOfChildNodes = reader.ReadInt32();
List<CvdGeometryNode> children = new();
for (int i = 0; i < numberOfChildNodes; i++)
var children = new List<CvdGeometryNode>();
for (var i = 0; i < numberOfChildNodes; i++)
{
ReadGeometryNodes(reader, version, children, ref animationDuration, codepage);
}
@@ -69,33 +69,33 @@ namespace Pal3.Core.DataReader.Cvd
ref float animationDuration,
int codepage)
{
int positionKeySize = Math.Max(Marshal.SizeOf(typeof(CvdTcbVector3Key)),
var positionKeySize = Math.Max(Marshal.SizeOf(typeof(CvdTcbVector3Key)),
Math.Max(Marshal.SizeOf(typeof(CvdBezierVector3Key)),
Marshal.SizeOf(typeof(CvdLinearVector3Key))));
CvdAnimationPositionKeyFrame[] positionKeyInfos = ReadPositionAnimationKeyInfo(reader, positionKeySize);
var positionKeyInfos = ReadPositionAnimationKeyInfo(reader, positionKeySize);
if (positionKeyInfos[^1].Time > animationDuration) animationDuration = positionKeyInfos[^1].Time;
int rotationKeySize = Math.Max(Marshal.SizeOf(typeof(CvdTcbRotationKey)),
var rotationKeySize = Math.Max(Marshal.SizeOf(typeof(CvdTcbRotationKey)),
Math.Max(Marshal.SizeOf(typeof(CvdBezierRotationKey)),
Marshal.SizeOf(typeof(CvdLinearRotationKey))));
CvdAnimationRotationKeyFrame[] rotationKeyInfos = ReadRotationAnimationKeyInfo(reader, rotationKeySize);
var rotationKeyInfos = ReadRotationAnimationKeyInfo(reader, rotationKeySize);
if (rotationKeyInfos[^1].Time > animationDuration) animationDuration = rotationKeyInfos[^1].Time;
int scaleKeySize = Math.Max(Marshal.SizeOf(typeof(CvdTcbScaleKey)),
var scaleKeySize = Math.Max(Marshal.SizeOf(typeof(CvdTcbScaleKey)),
Math.Max(Marshal.SizeOf(typeof(CvdBezierScaleKey)),
Marshal.SizeOf(typeof(CvdLinearScaleKey))));
CvdAnimationScaleKeyFrame[] scaleKeyInfos = ReadScaleAnimationKeyInfo(reader, scaleKeySize);
var scaleKeyInfos = ReadScaleAnimationKeyInfo(reader, scaleKeySize);
if (scaleKeyInfos[^1].Time > animationDuration) animationDuration = scaleKeyInfos[^1].Time;
float scale = reader.ReadSingle();
var scale = reader.ReadSingle();
CvdMesh mesh = ReadMesh(reader, version, codepage);
if (mesh.AnimationTimeKeys[^1] > animationDuration) animationDuration = mesh.AnimationTimeKeys[^1];
GameBoxMatrix4x4 transformMatrix = new()
var transformMatrix = new GameBoxMatrix4x4()
{
Xx = reader.ReadSingle(), Xy = reader.ReadSingle(), Xz = reader.ReadSingle(), Xw = reader.ReadSingle(),
Yx = reader.ReadSingle(), Yy = reader.ReadSingle(), Yz = reader.ReadSingle(), Yw = reader.ReadSingle(),
@@ -117,12 +117,12 @@ namespace Pal3.Core.DataReader.Cvd
private static (CvdAnimationKeyType, byte[])[] ReadAnimationKeyInfo(IBinaryReader reader, int size)
{
int numberOfKeys = reader.ReadInt32();
(CvdAnimationKeyType, byte[])[] keyInfos = new (CvdAnimationKeyType, byte[])[numberOfKeys];
var numberOfKeys = reader.ReadInt32();
var keyInfos = new (CvdAnimationKeyType, byte[])[numberOfKeys];
CvdAnimationKeyType keyType = (CvdAnimationKeyType)reader.ReadByte();
var keyType = (CvdAnimationKeyType)reader.ReadByte();
for (int i = 0; i < numberOfKeys; i++)
for (var i = 0; i < numberOfKeys; i++)
{
keyInfos[i] = (keyType, reader.ReadBytes(size));
}
@@ -132,18 +132,18 @@ namespace Pal3.Core.DataReader.Cvd
private static CvdAnimationPositionKeyFrame[] ReadPositionAnimationKeyInfo(IBinaryReader reader, int size)
{
(CvdAnimationKeyType, byte[])[] frameInfos = ReadAnimationKeyInfo(reader, size);
CvdAnimationPositionKeyFrame[] positionKeyFrames = new CvdAnimationPositionKeyFrame[frameInfos.Length];
var frameInfos = ReadAnimationKeyInfo(reader, size);
var positionKeyFrames = new CvdAnimationPositionKeyFrame[frameInfos.Length];
for (int i = 0; i < frameInfos.Length; i++)
for (var i = 0; i < frameInfos.Length; i++)
{
(CvdAnimationKeyType type, byte[] data) = frameInfos[i];
(CvdAnimationKeyType type, var data) = frameInfos[i];
switch (type)
{
case CvdAnimationKeyType.Tcb:
{
CvdTcbVector3Key positionKey = CoreUtility.ReadStruct<CvdTcbVector3Key>(data);
var positionKey = CoreUtility.ReadStruct<CvdTcbVector3Key>(data);
positionKeyFrames[i] = new CvdAnimationPositionKeyFrame()
{
KeyType = type,
@@ -154,7 +154,7 @@ namespace Pal3.Core.DataReader.Cvd
}
case CvdAnimationKeyType.Bezier:
{
CvdBezierVector3Key positionKey = CoreUtility.ReadStruct<CvdBezierVector3Key>(data);
var positionKey = CoreUtility.ReadStruct<CvdBezierVector3Key>(data);
positionKeyFrames[i] = new CvdAnimationPositionKeyFrame()
{
KeyType = type,
@@ -165,7 +165,7 @@ namespace Pal3.Core.DataReader.Cvd
}
case CvdAnimationKeyType.Linear:
{
CvdLinearVector3Key positionKey = CoreUtility.ReadStruct<CvdLinearVector3Key>(data);
var positionKey = CoreUtility.ReadStruct<CvdLinearVector3Key>(data);
positionKeyFrames[i] = new CvdAnimationPositionKeyFrame()
{
KeyType = type,
@@ -182,18 +182,18 @@ namespace Pal3.Core.DataReader.Cvd
private static CvdAnimationRotationKeyFrame[] ReadRotationAnimationKeyInfo(IBinaryReader reader, int size)
{
(CvdAnimationKeyType, byte[])[] frameInfos = ReadAnimationKeyInfo(reader, size);
CvdAnimationRotationKeyFrame[] rotationKeyFrames = new CvdAnimationRotationKeyFrame[frameInfos.Length];
var frameInfos = ReadAnimationKeyInfo(reader, size);
var rotationKeyFrames = new CvdAnimationRotationKeyFrame[frameInfos.Length];
for (int i = 0; i < frameInfos.Length; i++)
for (var i = 0; i < frameInfos.Length; i++)
{
(CvdAnimationKeyType type, byte[] data) = frameInfos[i];
(CvdAnimationKeyType type, var data) = frameInfos[i];
switch (type)
{
case CvdAnimationKeyType.Tcb:
{
CvdTcbRotationKey rotationKey = CoreUtility.ReadStruct<CvdTcbRotationKey>(data);
var rotationKey = CoreUtility.ReadStruct<CvdTcbRotationKey>(data);
GameBoxQuaternion quaternion = GameBoxQuaternion.AngleAxis(rotationKey.Angle, rotationKey.Axis);
rotationKeyFrames[i] = new CvdAnimationRotationKeyFrame()
{
@@ -211,7 +211,7 @@ namespace Pal3.Core.DataReader.Cvd
}
case CvdAnimationKeyType.Bezier:
{
CvdBezierRotationKey rotationKey = CoreUtility.ReadStruct<CvdBezierRotationKey>(data);
var rotationKey = CoreUtility.ReadStruct<CvdBezierRotationKey>(data);
rotationKeyFrames[i] = new CvdAnimationRotationKeyFrame()
{
KeyType = type,
@@ -222,7 +222,7 @@ namespace Pal3.Core.DataReader.Cvd
}
case CvdAnimationKeyType.Linear:
{
CvdLinearRotationKey rotationKey = CoreUtility.ReadStruct<CvdLinearRotationKey>(data);
var rotationKey = CoreUtility.ReadStruct<CvdLinearRotationKey>(data);
rotationKeyFrames[i] = new CvdAnimationRotationKeyFrame()
{
KeyType = type,
@@ -239,18 +239,18 @@ namespace Pal3.Core.DataReader.Cvd
private static CvdAnimationScaleKeyFrame[] ReadScaleAnimationKeyInfo(IBinaryReader reader, int size)
{
(CvdAnimationKeyType, byte[])[] frameInfos = ReadAnimationKeyInfo(reader, size);
CvdAnimationScaleKeyFrame[] scaleKeyFrames = new CvdAnimationScaleKeyFrame[frameInfos.Length];
var frameInfos = ReadAnimationKeyInfo(reader, size);
var scaleKeyFrames = new CvdAnimationScaleKeyFrame[frameInfos.Length];
for (int i = 0; i < frameInfos.Length; i++)
for (var i = 0; i < frameInfos.Length; i++)
{
(CvdAnimationKeyType type, byte[] data) = frameInfos[i];
(CvdAnimationKeyType type, var data) = frameInfos[i];
switch (type)
{
case CvdAnimationKeyType.Tcb:
{
CvdTcbScaleKey scaleKey = CoreUtility.ReadStruct<CvdTcbScaleKey>(data);
var scaleKey = CoreUtility.ReadStruct<CvdTcbScaleKey>(data);
scaleKeyFrames[i] = new CvdAnimationScaleKeyFrame()
{
KeyType = type,
@@ -262,7 +262,7 @@ namespace Pal3.Core.DataReader.Cvd
}
case CvdAnimationKeyType.Bezier:
{
CvdBezierScaleKey scaleKey = CoreUtility.ReadStruct<CvdBezierScaleKey>(data);
var scaleKey = CoreUtility.ReadStruct<CvdBezierScaleKey>(data);
scaleKeyFrames[i] = new CvdAnimationScaleKeyFrame()
{
KeyType = type,
@@ -274,7 +274,7 @@ namespace Pal3.Core.DataReader.Cvd
}
case CvdAnimationKeyType.Linear:
{
CvdLinearScaleKey scaleKey = CoreUtility.ReadStruct<CvdLinearScaleKey>(data);
var scaleKey = CoreUtility.ReadStruct<CvdLinearScaleKey>(data);
scaleKeyFrames[i] = new CvdAnimationScaleKeyFrame()
{
KeyType = type,
@@ -292,14 +292,14 @@ namespace Pal3.Core.DataReader.Cvd
private static CvdMesh ReadMesh(IBinaryReader reader, float version, int codepage)
{
int numberOfFrames = reader.ReadInt32();
int numberOfVertices = reader.ReadInt32();
var numberOfFrames = reader.ReadInt32();
var numberOfVertices = reader.ReadInt32();
CvdVertex[][] frameVertices = new CvdVertex[numberOfFrames][];
for (int i = 0; i < numberOfFrames; i++)
var frameVertices = new CvdVertex[numberOfFrames][];
for (var i = 0; i < numberOfFrames; i++)
{
CvdVertex[] vertices = new CvdVertex[numberOfVertices];
for (int j = 0; j < numberOfVertices; j++)
var vertices = new CvdVertex[numberOfVertices];
for (var j = 0; j < numberOfVertices; j++)
{
GameBoxVector2 uv = reader.ReadGameBoxVector2();
GameBoxVector3 normal = reader.ReadGameBoxVector3();
@@ -321,15 +321,15 @@ namespace Pal3.Core.DataReader.Cvd
frameVertices[i] = vertices;
}
float[] animationTimeKeys = reader.ReadSingles(numberOfFrames);
for (int i = 0; i < numberOfFrames; i++)
var animationTimeKeys = reader.ReadSingles(numberOfFrames);
for (var i = 0; i < numberOfFrames; i++)
{
animationTimeKeys[i] -= animationTimeKeys[0];
}
int numberOfMeshes = reader.ReadInt32();
CvdMeshSection[] meshSections = new CvdMeshSection[numberOfMeshes];
for (int i = 0; i < numberOfMeshes; i++)
var numberOfMeshes = reader.ReadInt32();
var meshSections = new CvdMeshSection[numberOfMeshes];
for (var i = 0; i < numberOfMeshes; i++)
{
meshSections[i] = ReadMeshSection(reader, version, frameVertices, codepage);
}
@@ -358,31 +358,31 @@ namespace Pal3.Core.DataReader.Cvd
TextureFileNames = new [] { reader.ReadString(64, codepage) }
};
int numberOfIndices = reader.ReadInt32();
var numberOfIndices = reader.ReadInt32();
(ushort x, ushort y, ushort z)[] indices = new (ushort x, ushort y, ushort z)[numberOfIndices];
for (int i = 0; i < numberOfIndices; i++)
var indices = new (ushort x, ushort y, ushort z)[numberOfIndices];
for (var i = 0; i < numberOfIndices; i++)
{
ushort x = reader.ReadUInt16();
ushort y = reader.ReadUInt16();
ushort z = reader.ReadUInt16();
var x = reader.ReadUInt16();
var y = reader.ReadUInt16();
var z = reader.ReadUInt16();
indices[i] = (x, y, z);
}
float[] animationTimeKeys = {};
GameBoxMaterial[] animationMaterials = Array.Empty<GameBoxMaterial>();
var animationTimeKeys = new float[] {};
var animationMaterials = Array.Empty<GameBoxMaterial>();
if (version >= 0.5)
{
int numberOfFrames = reader.ReadInt32();
var numberOfFrames = reader.ReadInt32();
animationTimeKeys = reader.ReadSingles(numberOfFrames);
for (int i = 0; i < numberOfFrames; i++)
for (var i = 0; i < numberOfFrames; i++)
{
animationTimeKeys[i] -= animationTimeKeys[0];
}
animationMaterials = new GameBoxMaterial[numberOfFrames];
for (int i = 0; i < numberOfFrames; i++)
for (var i = 0; i < numberOfFrames; i++)
{
animationMaterials[i] = new GameBoxMaterial()
{
@@ -395,14 +395,14 @@ namespace Pal3.Core.DataReader.Cvd
}
}
CvdVertex[][] frameVertices = new CvdVertex[allFrameVertices.Length][];
var frameVertices = new CvdVertex[allFrameVertices.Length][];
(int[] triangles, int[] indexBuffer) = CalculateTriangles(indices);
for (int i = 0; i < allFrameVertices.Length; i++)
for (var i = 0; i < allFrameVertices.Length; i++)
{
CvdVertex[] verts = new CvdVertex[indexBuffer.Length];
CvdVertex[] allVertices = allFrameVertices[i];
var verts = new CvdVertex[indexBuffer.Length];
var allVertices = allFrameVertices[i];
for (var j = 0; j < indexBuffer.Length; j++)
{
@@ -426,11 +426,11 @@ namespace Pal3.Core.DataReader.Cvd
private static (int[] triangles, int[] indexBuffer) CalculateTriangles(
(ushort x, ushort y, ushort z)[] allIndices)
{
int[] indexBuffer = new int[allIndices.Length * 3];
int[] triangles = new int[allIndices.Length * 3];
var indexBuffer = new int[allIndices.Length * 3];
var triangles = new int[allIndices.Length * 3];
int index = 0;
for (int i = 0; i < allIndices.Length; i++)
for (var i = 0; i < allIndices.Length; i++)
{
ushort[] indices =
{
@@ -439,7 +439,7 @@ namespace Pal3.Core.DataReader.Cvd
allIndices[i].z
};
for (int j = 0; j < 3; j++)
for (var j = 0; j < 3; j++)
{
indexBuffer[index] = indices[j];
triangles[index] = index;
@@ -11,9 +11,9 @@ namespace Pal3.Core.DataReader.Dat
public EffectLinkerFile Read(IBinaryReader reader, int codepage)
{
EffectLinker[] effectDefinitions = new EffectLinker[NUM_OF_EFFECT_LINKERS];
var effectDefinitions = new EffectLinker[NUM_OF_EFFECT_LINKERS];
for (int i = 0; i < NUM_OF_EFFECT_LINKERS; i++)
for (var i = 0; i < NUM_OF_EFFECT_LINKERS; i++)
{
effectDefinitions[i] = ReadEffectLinker(reader);
}
@@ -23,11 +23,11 @@ namespace Pal3.Core.DataReader.Dat
private static EffectLinker ReadEffectLinker(IBinaryReader reader)
{
uint skillId = reader.ReadUInt32();
var skillId = reader.ReadUInt32();
EffectGroupInfo[] effectGroupInfos = new EffectGroupInfo[2];
var effectGroupInfos = new EffectGroupInfo[2];
for (int i = 0; i < 2; i++)
for (var i = 0; i < 2; i++)
{
effectGroupInfos[i] = ReadEffectGroupInfo(reader);
}
@@ -11,9 +11,9 @@ namespace Pal3.Core.DataReader.Data
public EffectDefinitionFile Read(IBinaryReader reader, int codepage)
{
EffectDefinition[] effectDefinitions = new EffectDefinition[NUM_OF_EFFECTS];
var effectDefinitions = new EffectDefinition[NUM_OF_EFFECTS];
for (int i = 0; i < NUM_OF_EFFECTS; i++)
for (var i = 0; i < NUM_OF_EFFECTS; i++)
{
effectDefinitions[i] = ReadEffectDefinition(reader, codepage);
}
@@ -23,7 +23,7 @@ namespace Pal3.Core.DataReader.Data
private EffectDefinition ReadEffectDefinition(IBinaryReader reader, int codepage)
{
EffectDefinition effectDefinition = new()
var effectDefinition = new EffectDefinition
{
ClassNameCrc = reader.ReadUInt32(),
TypeName = reader.ReadString(32, codepage),
@@ -32,7 +32,7 @@ namespace Pal3.Core.DataReader.Data
// union
{
string unionStr = reader.ReadString(128, codepage);
var unionStr = reader.ReadString(128, codepage);
effectDefinition.TextureName = unionStr;
effectDefinition.ParticleFileName = unionStr;
effectDefinition.SfxFileNamePrefix = unionStr;
@@ -50,7 +50,7 @@ namespace Pal3.Core.DataReader.Data
// union
{
float unionFloat = reader.ReadSingle();
var unionFloat = reader.ReadSingle();
effectDefinition.InitYRotation = unionFloat;
effectDefinition.InitAngle = unionFloat;
}
@@ -34,12 +34,12 @@ namespace Pal3.Core.DataReader.Dxt
fixed (byte* srcStart = &data[DDS_FILE_HEADER_SIZE], dstStart = buffer)
{
byte* src = srcStart;
byte* dst = dstStart;
var src = srcStart;
var dst = dstStart;
for (int j = 0; j < (height + 3) / 4; j++)
for (var j = 0; j < (height + 3) / 4; j++)
{
for (int i = 0; i < (width + 3) / 4; i++)
for (var i = 0; i < (width + 3) / 4; i++)
{
DecodeDxt1Block(i, j, width, height, src, dst);
src += 8; // 2 + 2 + 4
@@ -58,9 +58,9 @@ namespace Pal3.Core.DataReader.Dxt
uint lookupTable = *(uint*)(src + 4);
for (int blockY = 0; blockY < 4; blockY++)
for (var blockY = 0; blockY < 4; blockY++)
{
for (int blockX = 0; blockX < 4; blockX++)
for (var blockX = 0; blockX < 4; blockX++)
{
byte r = 0, g = 0, b = 0, a = 255;
uint index = (lookupTable >> 2 * (4 * blockY + blockX)) & 0x03;
@@ -37,9 +37,9 @@ namespace Pal3.Core.DataReader.Dxt
byte* src = srcStart;
byte* dst = dstStart;
for (int j = 0; j < (height + 3) / 4; j++)
for (var j = 0; j < (height + 3) / 4; j++)
{
for (int i = 0; i < (width + 3) / 4; i++)
for (var i = 0; i < (width + 3) / 4; i++)
{
DecodeDxt3Block(i, j, width, height, src, dst);
src += 16; // 8 + 2 + 2 + 4
@@ -59,9 +59,9 @@ namespace Pal3.Core.DataReader.Dxt
uint lookupTable = *(uint*)(src + 12);
int alphaIndex = 0;
for (int blockY = 0; blockY < 4; blockY++)
for (var blockY = 0; blockY < 4; blockY++)
{
for (int blockX = 0; blockX < 4; blockX++)
for (var blockX = 0; blockX < 4; blockX++)
{
byte r = 0, g = 0, b = 0, a = 0;
@@ -98,12 +98,12 @@ namespace Pal3.Core.DataReader.Dxt
break;
}
int px = (x << 2) + blockX;
int py = (y << 2) + blockY;
var px = (x << 2) + blockX;
var py = (y << 2) + blockY;
if (px < width && py < height)
{
int offset = ((py * width) + px) << 2;
var offset = ((py * width) + px) << 2;
*(dst + offset) = r;
*(dst + offset + 1) = g;
*(dst + offset + 2) = b;
@@ -30,32 +30,32 @@ namespace Pal3.Core.DataReader.Gdb
int numOfComboSkills = reader.ReadInt32();
reader.Seek(combatActorDataOffset, SeekOrigin.Begin);
Dictionary<int, CombatActorInfo> combatActorInfos = new();
for (int i = 0; i < numOfActors; i++)
var combatActorInfos = new Dictionary<int, CombatActorInfo>();
for (var i = 0; i < numOfActors; i++)
{
CombatActorInfo actor = ReadCombatActorInfo(reader, codepage);
combatActorInfos[(int) actor.Id] = actor;
}
reader.Seek(skillDataOffset, SeekOrigin.Begin);
Dictionary<int, SkillInfo> skillInfos = new();
for (int i = 0; i < numOfSkills; i++)
var skillInfos = new Dictionary<int, SkillInfo>();
for (var i = 0; i < numOfSkills; i++)
{
SkillInfo skill = ReadSkillInfo(reader, codepage);
skillInfos[(int) skill.Id] = skill;
}
reader.Seek(itemDataOffset, SeekOrigin.Begin);
Dictionary<int, GameItemInfo> gameItems = new();
for (int i = 0; i < numOfItems; i++)
var gameItems = new Dictionary<int, GameItemInfo>();
for (var i = 0; i < numOfItems; i++)
{
GameItemInfo item = ReadGameItemInfo(reader, codepage);
gameItems[(int) item.Id] = item;
}
reader.Seek(comboSkillDataOffset, SeekOrigin.Begin);
Dictionary<int, ComboSkillInfo> comboSkillInfos = new();
for (int i = 0; i < numOfComboSkills; i++)
var comboSkillInfos = new Dictionary<int, ComboSkillInfo>();
for (var i = 0; i < numOfComboSkills; i++)
{
ComboSkillInfo comboSkill = ReadComboSkillInfo(reader, codepage);
comboSkillInfos[(int) comboSkill.Id] = comboSkill;
@@ -69,45 +69,45 @@ namespace Pal3.Core.DataReader.Gdb
private static CombatActorInfo ReadCombatActorInfo(IBinaryReader reader, int codepage)
{
uint id = reader.ReadUInt32();
CombatActorType type = (CombatActorType) reader.ReadUInt16();
string description = reader.ReadString(512, codepage);
string modelId = reader.ReadString(30, codepage);
string iconId = reader.ReadString(32, codepage);
int[] elementAttributeValues = reader.ReadInt32s(5);
string name = reader.ReadString(32, codepage);
int level = reader.ReadInt32();
int[] attributeValues = reader.ReadInt32s(12);
byte[] combatStateImpactTypes = reader.ReadBytes(31);
var id = reader.ReadUInt32();
var type = (CombatActorType) reader.ReadUInt16();
var description = reader.ReadString(512, codepage);
var modelId = reader.ReadString(30, codepage);
var iconId = reader.ReadString(32, codepage);
var elementAttributeValues = reader.ReadInt32s(5);
var name = reader.ReadString(32, codepage);
var level = reader.ReadInt32();
var attributeValues = reader.ReadInt32s(12);
var combatStateImpactTypes = reader.ReadBytes(31);
_ = reader.ReadByte(); // padding
int maxRound = reader.ReadInt32();
int specialActionId = reader.ReadInt32();
float escapeRate = reader.ReadSingle();
ushort[] mainActorFavor = reader.ReadUInt16s(6);
int experience = reader.ReadInt32();
ushort money = reader.ReadUInt16();
var maxRound = reader.ReadInt32();
var specialActionId = reader.ReadInt32();
var escapeRate = reader.ReadSingle();
var mainActorFavor = reader.ReadUInt16s(6);
var experience = reader.ReadInt32();
var money = reader.ReadUInt16();
_ = reader.ReadUInt16(); // padding
uint normalAttackModeId = reader.ReadUInt32();
byte heightLevel = reader.ReadByte();
byte moveRangeLevel = reader.ReadByte();
byte attackRangeLevel = reader.ReadByte();
byte moveSpeedLevel = reader.ReadByte();
byte chaseSpeed = reader.ReadByte();
var normalAttackModeId = reader.ReadUInt32();
var heightLevel = reader.ReadByte();
var moveRangeLevel = reader.ReadByte();
var attackRangeLevel = reader.ReadByte();
var moveSpeedLevel = reader.ReadByte();
var chaseSpeed = reader.ReadByte();
_ = reader.ReadBytes(3); // padding
uint[] skillIds = reader.ReadUInt32s(4);
byte[] skillLevels = reader.ReadBytes(4);
int spImpactValue = reader.ReadInt32();
float[] properties = reader.ReadSingles(10);
uint normalLoot = reader.ReadUInt32();
short normalLootCount = reader.ReadInt16();
var skillIds = reader.ReadUInt32s(4);
var skillLevels = reader.ReadBytes(4);
var spImpactValue = reader.ReadInt32();
var properties = reader.ReadSingles(10);
var normalLoot = reader.ReadUInt32();
var normalLootCount = reader.ReadInt16();
_ = reader.ReadInt16(); // padding
uint corpseId = reader.ReadUInt32();
uint corpseSkillId = reader.ReadUInt32();
short corpseSuccessRate = reader.ReadInt16();
short stealableMoneyAmount = reader.ReadInt16();
uint stealableItemId = reader.ReadUInt32();
short stealableItemCount = reader.ReadInt16();
short moneyWhenKilled = reader.ReadInt16();
var corpseId = reader.ReadUInt32();
var corpseSkillId = reader.ReadUInt32();
var corpseSuccessRate = reader.ReadInt16();
var stealableMoneyAmount = reader.ReadInt16();
var stealableItemId = reader.ReadUInt32();
var stealableItemCount = reader.ReadInt16();
var moneyWhenKilled = reader.ReadInt16();
return new CombatActorInfo()
{
@@ -151,49 +151,49 @@ namespace Pal3.Core.DataReader.Gdb
private SkillInfo ReadSkillInfo(IBinaryReader reader, int codepage)
{
uint id = reader.ReadUInt32();
SkillType type = (SkillType)reader.ReadByte();
var id = reader.ReadUInt32();
var type = (SkillType)reader.ReadByte();
_ = reader.ReadBytes(3); // padding
byte[] elementAttributes = reader.ReadInt32s(5).Select(_ => (byte)_).ToArray();
var elementAttributes = reader.ReadInt32s(5).Select(_ => (byte)_).ToArray();
string name = reader.ReadString(32, codepage);
string description = reader.ReadString(512, codepage);
byte[] mainActorCanUse = reader.ReadBytes(5);
TargetRangeType targetRangeType = (TargetRangeType)reader.ReadByte();
byte specialSkillId = reader.ReadByte();
byte[] attributeImpactType = reader.ReadBytes(12);
var name = reader.ReadString(32, codepage);
var description = reader.ReadString(512, codepage);
var mainActorCanUse = reader.ReadBytes(5);
var targetRangeType = (TargetRangeType)reader.ReadByte();
var specialSkillId = reader.ReadByte();
var attributeImpactType = reader.ReadBytes(12);
_ = reader.ReadByte(); // padding
short[] attributeImpactValue = reader.ReadInt16s(12);
byte successRateLevel = reader.ReadByte();
var attributeImpactValue = reader.ReadInt16s(12);
var successRateLevel = reader.ReadByte();
_ = reader.ReadByte(); // padding
byte[] combatStateImpactTypes = reader.ReadInt16s(31).Select(_ => (byte)_).ToArray();
var combatStateImpactTypes = reader.ReadInt16s(31).Select(_ => (byte)_).ToArray();
AttributeImpactType spConsumeImpactType = (AttributeImpactType)reader.ReadInt32();
AttributeImpactType mpConsumeImpactType = (AttributeImpactType)reader.ReadInt32();
var spConsumeImpactType = (AttributeImpactType)reader.ReadInt32();
var mpConsumeImpactType = (AttributeImpactType)reader.ReadInt32();
int spConsumeValue = reader.ReadInt32();
int mpConsumeValue = reader.ReadInt32();
var spConsumeValue = reader.ReadInt32();
var mpConsumeValue = reader.ReadInt32();
int specialConsumeType = reader.ReadInt32();
AttributeImpactType specialConsumeImpactType = (AttributeImpactType)reader.ReadByte();
var specialConsumeType = reader.ReadInt32();
var specialConsumeImpactType = (AttributeImpactType)reader.ReadByte();
_ = reader.ReadBytes(3); // padding
int specialConsumeValue = reader.ReadInt32();
var specialConsumeValue = reader.ReadInt32();
byte level = reader.ReadByte();
byte[] timesBeforeLevelUp = reader.ReadBytes(4);
var level = reader.ReadByte();
var timesBeforeLevelUp = reader.ReadBytes(4);
byte requiredActorLevel = reader.ReadByte();
byte magicLevel = reader.ReadByte();
var requiredActorLevel = reader.ReadByte();
var magicLevel = reader.ReadByte();
_ = reader.ReadByte(); // padding
uint nextLevelSkillId = reader.ReadUInt32();
byte isUsableOutsideCombat = reader.ReadByte();
var nextLevelSkillId = reader.ReadUInt32();
var isUsableOutsideCombat = reader.ReadByte();
_ = reader.ReadBytes(3); // padding
uint[] compositeSkillIds = reader.ReadUInt32s(3);
uint[] compositeRequiredSkillIds = reader.ReadUInt32s(3);
byte[] compositeRequiredSkillLevels = reader.ReadBytes(3);
byte[] compositeRequiredCurrentSkillLevels = reader.ReadBytes(3);
byte[] compositeRequiredActorLevels = reader.ReadBytes(3);
byte canTriggerComboSkill = reader.ReadByte();
var compositeSkillIds = reader.ReadUInt32s(3);
var compositeRequiredSkillIds = reader.ReadUInt32s(3);
var compositeRequiredSkillLevels = reader.ReadBytes(3);
var compositeRequiredCurrentSkillLevels = reader.ReadBytes(3);
var compositeRequiredActorLevels = reader.ReadBytes(3);
var canTriggerComboSkill = reader.ReadByte();
_ = reader.ReadBytes(2); // padding
return new SkillInfo()
@@ -233,53 +233,53 @@ namespace Pal3.Core.DataReader.Gdb
private static GameItemInfo ReadGameItemInfo(IBinaryReader reader, int codepage)
{
uint id = reader.ReadUInt32();
string name = reader.ReadString(32, codepage);
string modelName = reader.ReadString(30, codepage);
string iconName = reader.ReadString(30, codepage);
string description = reader.ReadString(512, codepage);
int price = reader.ReadInt32();
ItemType type = (ItemType) reader.ReadByte();
WeaponType weaponType = (WeaponType) reader.ReadByte();
byte[] mainActorCanUse = reader.ReadBytes(5);
byte[] elementAttributes = reader.ReadBytes(5);
int ancientValue = reader.ReadInt32();
ItemSpecialType itemSpecialType = (ItemSpecialType) reader.ReadByte();
TargetRangeType targetRangeType = (TargetRangeType) reader.ReadByte();
PlaceOfUseType placeOfUseType = (PlaceOfUseType) reader.ReadByte();
byte[] attributeImpactType = reader.ReadBytes(12);
var id = reader.ReadUInt32();
var name = reader.ReadString(32, codepage);
var modelName = reader.ReadString(30, codepage);
var iconName = reader.ReadString(30, codepage);
var description = reader.ReadString(512, codepage);
var price = reader.ReadInt32();
var type = (ItemType) reader.ReadByte();
var weaponType = (WeaponType) reader.ReadByte();
var mainActorCanUse = reader.ReadBytes(5);
var elementAttributes = reader.ReadBytes(5);
var ancientValue = reader.ReadInt32();
var itemSpecialType = (ItemSpecialType) reader.ReadByte();
var targetRangeType = (TargetRangeType) reader.ReadByte();
var placeOfUseType = (PlaceOfUseType) reader.ReadByte();
var attributeImpactType = reader.ReadBytes(12);
_ = reader.ReadByte(); // padding
short[] attributeImpactValue = reader.ReadInt16s(12);
byte[] combatStateImpactTypes = reader.ReadBytes(31);
var attributeImpactValue = reader.ReadInt16s(12);
var combatStateImpactTypes = reader.ReadBytes(31);
_ = reader.ReadByte(); // padding
short[] combatStateImpactValue = reader.ReadInt16s(31);
var combatStateImpactValue = reader.ReadInt16s(31);
_ = reader.ReadBytes(2); // padding
#if PAL3
int comboCount = reader.ReadInt32();
short spSavingPercentage = reader.ReadInt16();
short mpSavingPercentage = reader.ReadInt16();
short criticalAttackAmplifyPercentage = reader.ReadInt16();
short specialSkillSuccessRate = reader.ReadInt16();
uint oreId = reader.ReadUInt32();
uint productId = reader.ReadUInt32();
int productPrice = reader.ReadInt32();
uint[] synthesisMaterialIds = reader.ReadUInt32s(2);
uint synthesisProductId = reader.ReadUInt32();
var comboCount = reader.ReadInt32();
var spSavingPercentage = reader.ReadInt16();
var mpSavingPercentage = reader.ReadInt16();
var criticalAttackAmplifyPercentage = reader.ReadInt16();
var specialSkillSuccessRate = reader.ReadInt16();
var oreId = reader.ReadUInt32();
var productId = reader.ReadUInt32();
var productPrice = reader.ReadInt32();
var synthesisMaterialIds = reader.ReadUInt32s(2);
var synthesisProductId = reader.ReadUInt32();
#elif PAL3A
int unknown1 = reader.ReadInt32();
uint unknown2 = reader.ReadUInt32();
var unknown1 = reader.ReadInt32();
var unknown2 = reader.ReadUInt32();
short spSavingPercentage = reader.ReadInt16();
short mpSavingPercentage = reader.ReadInt16();
short criticalAttackAmplifyPercentage = reader.ReadInt16();
short specialSkillSuccessRate = reader.ReadInt16();
var spSavingPercentage = reader.ReadInt16();
var mpSavingPercentage = reader.ReadInt16();
var criticalAttackAmplifyPercentage = reader.ReadInt16();
var specialSkillSuccessRate = reader.ReadInt16();
PlayerActorId creatorActorId = (PlayerActorId)reader.ReadInt32();
uint materialId = reader.ReadUInt32();
int productType = reader.ReadInt32();
uint productId = reader.ReadUInt32();
uint requiredFavorValue = reader.ReadUInt32();
var creatorActorId = (PlayerActorId)reader.ReadInt32();
var materialId = reader.ReadUInt32();
var productType = reader.ReadInt32();
var productId = reader.ReadUInt32();
var requiredFavorValue = reader.ReadUInt32();
#endif
return new GameItemInfo()
@@ -331,25 +331,25 @@ namespace Pal3.Core.DataReader.Gdb
private ComboSkillInfo ReadComboSkillInfo(IBinaryReader reader, int codepage)
{
string name = reader.ReadString(32, codepage);
uint id = reader.ReadUInt32();
uint[] mainActorRequirements = reader.ReadUInt32s(4);
ElementPositionRequirementType[] elementPositionRequirements = reader.ReadBytes(4)
var name = reader.ReadString(32, codepage);
var id = reader.ReadUInt32();
var mainActorRequirements = reader.ReadUInt32s(4);
var elementPositionRequirements = reader.ReadBytes(4)
.Select(_ => (ElementPositionRequirementType)_).ToArray();
uint skillId = reader.ReadUInt32();
WeaponType[] weaponTypeRequirements = reader.ReadBytes(4).Select(_ => (WeaponType)_).ToArray();
var skillId = reader.ReadUInt32();
var weaponTypeRequirements = reader.ReadBytes(4).Select(_ => (WeaponType)_).ToArray();
_ = reader.ReadBytes(4); // not used
ActorCombatStateType[] combatStateRequirements = reader.ReadInt32s(3)
var combatStateRequirements = reader.ReadInt32s(3)
.Select(_ => (ActorCombatStateType)_).ToArray();
string description = reader.ReadString(512, codepage);
TargetRangeType targetRangeType = (TargetRangeType)reader.ReadByte();
var description = reader.ReadString(512, codepage);
var targetRangeType = (TargetRangeType)reader.ReadByte();
byte[] attributeImpactType = reader.ReadBytes(12);
var attributeImpactType = reader.ReadBytes(12);
_ = reader.ReadBytes(3); // padding
short[] attributeImpactValue = reader.ReadInt16s(12);
var attributeImpactValue = reader.ReadInt16s(12);
#if PAL3A
int unknown = reader.ReadInt32();
var unknown = reader.ReadInt32();
#endif
return new ComboSkillInfo()
@@ -455,7 +455,8 @@ namespace Pal3.Core.DataReader.Gdb
{
combatStateImpacts[combatState] = new CombatStateImpact
{
Type = combatStateImpactTypes.GetValueOrDefault(combatState, CombatStateImpactType.None),
Type = combatStateImpactTypes.TryGetValue(combatState, out CombatStateImpactType impactType) ?
impactType : CombatStateImpactType.None,
Value = impactValue
};
}
@@ -21,9 +21,9 @@ namespace Pal3.Core.DataReader
// Use unsafe binary reader (faster) if IL2CPP is enabled
// otherwise use safe reader
#if ENABLE_IL2CPP || UNITY_EDITOR
using IBinaryReader reader = new UnsafeBinaryReader(data);
using var reader = new UnsafeBinaryReader(data);
#else
using IBinaryReader reader = new SafeBinaryReader(data);
using var reader = new SafeBinaryReader(data);
#endif
return Read(reader, codepage);
@@ -34,9 +34,9 @@ namespace Pal3.Core.DataReader
// Use unsafe binary reader (faster) if IL2CPP is enabled
// otherwise use safe reader
#if ENABLE_IL2CPP || UNITY_EDITOR
using IBinaryReader reader = new UnsafeBinaryReader(stream);
using var reader = new UnsafeBinaryReader(stream);
#else
using IBinaryReader reader = new SafeBinaryReader(stream);
using var reader = new SafeBinaryReader(stream);
#endif
return Read(reader, codepage);
@@ -24,13 +24,13 @@ namespace Pal3.Core.DataReader.Ini
public CombatCameraConfigFile Read(byte[] data, int _)
{
FileIniDataParser parser = new();
using MemoryStream stream = new(data);
using StreamReader reader = new(stream, Encoding.GetEncoding(DEFAULT_CODEPAGE));
var parser = new FileIniDataParser();
using var stream = new MemoryStream(data);
using var reader = new StreamReader(stream, Encoding.GetEncoding(DEFAULT_CODEPAGE));
IniData iniData = parser.ReadData(reader);
List<CombatCameraConfig> defaultCamConfigs = new();
var defaultCamConfigs = new List<CombatCameraConfig>();
foreach (SectionData section in iniData.Sections)
{
if (section.SectionName.StartsWith(DEFAULT_CAM_SECTION_HEADER_PREFIX))
@@ -25,13 +25,13 @@ namespace Pal3.Core.DataReader.Ini
public CombatConfigFile Read(byte[] data, int codepage)
{
FileIniDataParser parser = new();
using MemoryStream stream = new(data);
using StreamReader reader = new(stream, Encoding.GetEncoding(codepage));
var parser = new FileIniDataParser();
using var stream = new MemoryStream(data);
using var reader = new StreamReader(stream, Encoding.GetEncoding(codepage));
IniData iniData = parser.ReadData(reader);
GameBoxVector3[] actorGameBoxPositions = new GameBoxVector3[10];
var actorGameBoxPositions = new GameBoxVector3[10];
FiveElementsFormationConfig allyFormationConfig = default;
FiveElementsFormationConfig enemyFormationConfig = default;
int[] levelExperienceTable = new int[100];
@@ -62,7 +62,7 @@ namespace Pal3.Core.DataReader.Ini
if (radius.Contains(";")) radius = radius[..radius.IndexOf(';')].Trim();
FiveElementsFormationConfig config = new()
var config = new FiveElementsFormationConfig()
{
CenterGameBoxPosition = new GameBoxVector3(float.Parse(x), float.Parse(y), float.Parse(z)),
GameBoxRadius = float.Parse(radius),
@@ -30,9 +30,9 @@ namespace Pal3.Core.DataReader.Ini
public MovActionConfig Read(byte[] data, int codepage)
{
FileIniDataParser parser = new();
using MemoryStream stream = new(data);
using StreamReader reader = new(stream, Encoding.GetEncoding(codepage));
FileIniDataParser parser = new ();
using var stream = new MemoryStream(data);
using var reader = new StreamReader(stream, Encoding.GetEncoding(codepage));
IniData iniData = parser.ReadData(reader);
@@ -14,12 +14,12 @@ namespace Pal3.Core.DataReader.Lgt
{
public LgtFile Read(IBinaryReader reader, int codepage)
{
int numOfLightNodes = reader.ReadInt32();
List<LightNode> lightNodes = new();
var numOfLightNodes = reader.ReadInt32();
var lightNodes = new List<LightNode>();
for (int i = 0; i < numOfLightNodes; i++)
for (var i = 0; i < numOfLightNodes; i++)
{
LightNode lightNode = ReadLightNode(reader);
var lightNode = ReadLightNode(reader);
if (Enum.IsDefined(typeof(GameBoxLightType), lightNode.LightType) &&
Enum.IsDefined(typeof(GameBoxLightShapeType), lightNode.LightShapeType))
@@ -33,7 +33,7 @@ namespace Pal3.Core.DataReader.Lgt
private static LightNode ReadLightNode(IBinaryReader reader)
{
GameBoxMatrix4x4 transformMatrix = new()
var transformMatrix = new GameBoxMatrix4x4()
{
Xx = reader.ReadSingle(), Xy = reader.ReadSingle(), Xz = reader.ReadSingle(), Xw = reader.ReadSingle(),
Yx = reader.ReadSingle(), Yy = reader.ReadSingle(), Yz = reader.ReadSingle(), Yw = reader.ReadSingle(),
@@ -42,7 +42,7 @@ namespace Pal3.Core.DataReader.Lgt
};
transformMatrix.Tw = 1f;
LightNode lightNode = new()
var lightNode = new LightNode
{
GameBoxWorldMatrix = transformMatrix,
LightType = (GameBoxLightType)reader.ReadInt32(),
@@ -12,39 +12,39 @@ namespace Pal3.Core.DataReader.Mov
{
public MovFile Read(IBinaryReader reader, int codepage)
{
char[] header = reader.ReadChars(4);
string headerStr = new string(header[..^1]);
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
if (headerStr != "anm")
{
throw new InvalidDataException("Invalid MOV(.mov) file: header != anm");
}
int version = reader.ReadInt32();
var version = reader.ReadInt32();
if (version != 100)
{
throw new InvalidDataException("Invalid MOV(.mov) file: version != 100");
}
float duration = reader.ReadSingle();
int numberOfBoneAnimationTracks = reader.ReadInt32();
int numberOfVertices = reader.ReadInt32();
int numberOfAnimationEvents = reader.ReadInt32();
var duration = reader.ReadSingle();
var numberOfBoneAnimationTracks = reader.ReadInt32();
var numberOfVertices = reader.ReadInt32();
var numberOfAnimationEvents = reader.ReadInt32();
MovAnimationEvent[] animationEvents = new MovAnimationEvent[numberOfAnimationEvents];
for (int i = 0; i < numberOfAnimationEvents; i++)
var animationEvents = new MovAnimationEvent[numberOfAnimationEvents];
for (var i = 0; i < numberOfAnimationEvents; i++)
{
animationEvents[i] = ReadAnimationEvent(reader, codepage);
}
MovBoneAnimationTrack[] boneAnimationTracks = new MovBoneAnimationTrack[numberOfBoneAnimationTracks];
for (int i = 0; i < numberOfBoneAnimationTracks; i++)
var boneAnimationTracks = new MovBoneAnimationTrack[numberOfBoneAnimationTracks];
for (var i = 0; i < numberOfBoneAnimationTracks; i++)
{
boneAnimationTracks[i] = ReadBoneAnimationTrack(reader, codepage);
}
float totalDuration = 0;
for (int i = 0; i < boneAnimationTracks.Length; i++)
for (var i = 0; i < boneAnimationTracks.Length; i++)
{
int numOfKeyFrames = boneAnimationTracks[i].KeyFrames.Length;
if (numOfKeyFrames > 0)
@@ -71,16 +71,16 @@ namespace Pal3.Core.DataReader.Mov
private static MovBoneAnimationTrack ReadBoneAnimationTrack(IBinaryReader reader, int codepage)
{
int boneId = reader.ReadInt32();
var boneId = reader.ReadInt32();
int lengthOfBoneName = reader.ReadInt32();
string boneName = reader.ReadString(lengthOfBoneName, codepage);
var lengthOfBoneName = reader.ReadInt32();
var boneName = reader.ReadString(lengthOfBoneName, codepage);
int numberOfKeyFrames = reader.ReadInt32();
int animationFlags = reader.ReadInt32();
var numberOfKeyFrames = reader.ReadInt32();
var animationFlags = reader.ReadInt32();
MovAnimationKeyFrame[] animationKeyFrames = new MovAnimationKeyFrame[numberOfKeyFrames];
for (int i = 0; i < animationKeyFrames.Length; i++)
var animationKeyFrames = new MovAnimationKeyFrame[numberOfKeyFrames];
for (var i = 0; i < animationKeyFrames.Length; i++)
{
animationKeyFrames[i] = new MovAnimationKeyFrame()
{
@@ -12,15 +12,15 @@ namespace Pal3.Core.DataReader.Msh
{
public MshFile Read(IBinaryReader reader, int codepage)
{
char[] header = reader.ReadChars(4);
string headerStr = new (header[..^1]);
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
if (headerStr != "msh")
{
throw new InvalidDataException("Invalid MSH(.msh) file: header != msh");
}
int version = reader.ReadInt32();
var version = reader.ReadInt32();
if (version != 100)
{
throw new InvalidDataException("Invalid MSH(.msh) file: version != 100");
@@ -38,18 +38,18 @@ namespace Pal3.Core.DataReader.Msh
ParentId = 0,
};
int numberOfChildBones = reader.ReadInt32();
BoneNode[] childBoneNodes = new BoneNode[numberOfChildBones];
for (int i = 0; i < numberOfChildBones; i++)
var numberOfChildBones = reader.ReadInt32();
var childBoneNodes = new BoneNode[numberOfChildBones];
for (var i = 0; i < numberOfChildBones; i++)
{
childBoneNodes[i] = ReadBoneNode(reader, rootBoneNode, codepage);
}
rootBoneNode.Children = childBoneNodes;
int numberOfSubMeshes = reader.ReadInt32();
MshMesh[] subMeshes = new MshMesh[numberOfSubMeshes];
for (int i = 0; i < numberOfSubMeshes; i++)
var numberOfSubMeshes = reader.ReadInt32();
var subMeshes = new MshMesh[numberOfSubMeshes];
for (var i = 0; i < numberOfSubMeshes; i++)
{
subMeshes[i] = ReadSubMesh(reader);
}
@@ -59,9 +59,9 @@ namespace Pal3.Core.DataReader.Msh
private static BoneNode ReadBoneNode(IBinaryReader reader, BoneNode parent, int codepage)
{
BoneNodeType nodeType = (BoneNodeType)reader.ReadInt32();
int nameLength = reader.ReadInt32();
string name = reader.ReadString(nameLength, codepage);
var nodeType = (BoneNodeType)reader.ReadInt32();
var nameLength = reader.ReadInt32();
var name = reader.ReadString(nameLength, codepage);
GameBoxVector3 gameBoxTranslation = reader.ReadGameBoxVector3();
GameBoxQuaternion gameBoxRotation = new GameBoxQuaternion()
@@ -89,9 +89,9 @@ namespace Pal3.Core.DataReader.Msh
Tx = reader.ReadSingle(), Ty = reader.ReadSingle(), Tz = reader.ReadSingle(), Tw = reader.ReadSingle()
};
int boneID = reader.ReadInt32();
int parentBoneID = reader.ReadInt32();
int numberOfChildBones = reader.ReadInt32();
var boneID = reader.ReadInt32();
var parentBoneID = reader.ReadInt32();
var numberOfChildBones = reader.ReadInt32();
BoneNode boneNode = new()
{
@@ -107,8 +107,8 @@ namespace Pal3.Core.DataReader.Msh
GameBoxLocalTransform = gameBoxLocalTransformMatrix,
};
BoneNode[] childBoneNodes = new BoneNode[numberOfChildBones];
for (int i = 0; i < numberOfChildBones; i++)
var childBoneNodes = new BoneNode[numberOfChildBones];
for (var i = 0; i < numberOfChildBones; i++)
{
childBoneNodes[i] = ReadBoneNode(reader, boneNode, codepage);
}
@@ -120,12 +120,12 @@ namespace Pal3.Core.DataReader.Msh
private static MshMesh ReadSubMesh(IBinaryReader reader)
{
int materialId = reader.ReadInt32();
int numberOfVertices = reader.ReadInt32();
int numberOfFaces = reader.ReadInt32();
int numberOfSprings = reader.ReadInt32();
int numberOfLods = reader.ReadInt32();
MshLayerFlag layerFlag = (MshLayerFlag)reader.ReadInt32();
var materialId = reader.ReadInt32();
var numberOfVertices = reader.ReadInt32();
var numberOfFaces = reader.ReadInt32();
var numberOfSprings = reader.ReadInt32();
var numberOfLods = reader.ReadInt32();
var layerFlag = (MshLayerFlag)reader.ReadInt32();
GameBoxVector3[] gameBoxVertices = null;
if (layerFlag.HasFlag(MshLayerFlag.Position))
@@ -136,12 +136,12 @@ namespace Pal3.Core.DataReader.Msh
PhyVertex[] phyVertices = new PhyVertex[numberOfVertices];
if (layerFlag.HasFlag(MshLayerFlag.Bone))
{
for (int i = 0; i < numberOfVertices; i++)
for (var i = 0; i < numberOfVertices; i++)
{
byte numberOfBones = reader.ReadByte();
byte[] boneIds = new byte[numberOfBones];
byte[] weights = new byte[numberOfBones];
for (int j = 0; j < numberOfBones; j++)
var numberOfBones = reader.ReadByte();
var boneIds = new byte[numberOfBones];
var weights = new byte[numberOfBones];
for (var j = 0; j < numberOfBones; j++)
{
boneIds[j] = reader.ReadByte();
weights[j] = reader.ReadByte();
@@ -153,8 +153,8 @@ namespace Pal3.Core.DataReader.Msh
}
}
PhyFace[] phyFaces = new PhyFace[numberOfFaces];
for (int i = 0; i < numberOfFaces; i++)
var phyFaces = new PhyFace[numberOfFaces];
for (var i = 0; i < numberOfFaces; i++)
{
phyFaces[i] = new PhyFace
{
@@ -185,7 +185,7 @@ namespace Pal3.Core.DataReader.Msh
}
};
for (int j = 0; j < 3; j++)
for (var j = 0; j < 3; j++)
{
phyFaces[i].U[j, 0] = ((int)(phyFaces[i].U[j, 0] * 255)) / 255f;
phyFaces[i].V[j, 0] = ((int)(phyFaces[i].V[j, 0] * 255)) / 255f;
@@ -14,24 +14,24 @@ namespace Pal3.Core.DataReader.Mtl
{
public MtlFile Read(IBinaryReader reader, int codepage)
{
char[] header = reader.ReadChars(4);
string headerStr = new string(header[..^1]);
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
if (headerStr != "mtl")
{
throw new InvalidDataException("Invalid MTL(.mtl) file: header != mtl");
}
int version = reader.ReadInt32();
var version = reader.ReadInt32();
if (version != 100)
{
throw new InvalidDataException("Invalid MTL(.mtl) file: version != 100");
}
int numberOfMaterials = reader.ReadInt32();
GameBoxMaterial[] materials = new GameBoxMaterial[numberOfMaterials];
var materials = new GameBoxMaterial[numberOfMaterials];
for (int i = 0; i < numberOfMaterials; i++)
for (var i = 0; i < numberOfMaterials; i++)
{
materials[i] = new GameBoxMaterial
{
@@ -43,7 +43,7 @@ namespace Pal3.Core.DataReader.Mtl
};
List<string> textureNames = new ();
for (int j = 0; j < 4; j++)
for (var j = 0; j < 4; j++)
{
int textureNameLength = reader.ReadInt32();
if (textureNameLength == 0) continue;
@@ -14,51 +14,51 @@ namespace Pal3.Core.DataReader.Mv3
{
public Mv3File Read(IBinaryReader reader, int codepage)
{
char[] header = reader.ReadChars(4);
string headerStr = new string(header[..^1]);
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
if (headerStr != "MV3")
{
throw new InvalidDataException("Invalid MV3(.mv3) file: header != MV3");
}
int version = reader.ReadInt32();
var version = reader.ReadInt32();
if (version != 100)
{
throw new InvalidDataException("Invalid MV3(.mv3) file: version != 100");
}
uint duration = reader.ReadUInt32();
int numberOfMaterials = reader.ReadInt32();
int numberOfTagNodes = reader.ReadInt32();
int numberOfMeshes = reader.ReadInt32();
int numberOfAnimationEvents = reader.ReadInt32();
var duration = reader.ReadUInt32();
var numberOfMaterials = reader.ReadInt32();
var numberOfTagNodes = reader.ReadInt32();
var numberOfMeshes = reader.ReadInt32();
var numberOfAnimationEvents = reader.ReadInt32();
if (numberOfMeshes == 0 || numberOfMaterials == 0)
{
throw new InvalidDataException("Invalid MV3(.mv3) file: missing mesh or material info");
}
Mv3AnimationEvent[] animationEvents = new Mv3AnimationEvent[numberOfAnimationEvents];
for (int i = 0; i < numberOfAnimationEvents; i++)
var animationEvents = new Mv3AnimationEvent[numberOfAnimationEvents];
for (var i = 0; i < numberOfAnimationEvents; i++)
{
animationEvents[i] = ReadAnimationEvent(reader, codepage);
}
Mv3TagNode[] tagNodes = new Mv3TagNode[numberOfTagNodes];
for (int i = 0; i < numberOfTagNodes; i++)
var tagNodes = new Mv3TagNode[numberOfTagNodes];
for (var i = 0; i < numberOfTagNodes; i++)
{
tagNodes[i] = ReadTagNode(reader, codepage);
}
GameBoxMaterial[] materials = new GameBoxMaterial[numberOfMaterials];
for (int i = 0; i < numberOfMaterials; i++)
var materials = new GameBoxMaterial[numberOfMaterials];
for (var i = 0; i < numberOfMaterials; i++)
{
materials[i] = ReadMaterial(reader, codepage);
}
Mv3Mesh[] meshes = new Mv3Mesh[numberOfMeshes];
for (int i = 0; i < numberOfMeshes; i++)
var meshes = new Mv3Mesh[numberOfMeshes];
for (var i = 0; i < numberOfMeshes; i++)
{
meshes[i] = ReadMesh(reader, codepage);
}
@@ -72,19 +72,19 @@ namespace Pal3.Core.DataReader.Mv3
private static Mv3Mesh ReadMesh(IBinaryReader reader, int codepage)
{
string name = reader.ReadString(64, codepage);
int numberOfVertices = reader.ReadInt32();
var name = reader.ReadString(64, codepage);
var numberOfVertices = reader.ReadInt32();
GameBoxVector3 gameBoxBoundsMin = reader.ReadGameBoxVector3();
GameBoxVector3 gameBoxBoundsMax = reader.ReadGameBoxVector3();
int numberOfFrames = reader.ReadInt32();
Mv3VertFrame[] frames = new Mv3VertFrame[numberOfFrames];
for (int i = 0; i < numberOfFrames; i++)
var numberOfFrames = reader.ReadInt32();
var frames = new Mv3VertFrame[numberOfFrames];
for (var i = 0; i < numberOfFrames; i++)
{
uint gameBoxTick = reader.ReadUInt32();
Mv3Vert[] vertices = new Mv3Vert[numberOfVertices];
for (int j = 0; j < numberOfVertices; j++)
var gameBoxTick = reader.ReadUInt32();
var vertices = new Mv3Vert[numberOfVertices];
for (var j = 0; j < numberOfVertices; j++)
{
vertices[j] = new Mv3Vert()
{
@@ -101,20 +101,20 @@ namespace Pal3.Core.DataReader.Mv3
};
}
int numberOfTexCoords = reader.ReadInt32();
var numberOfTexCoords = reader.ReadInt32();
GameBoxVector2[] texCoords = numberOfTexCoords == 0 ?
new GameBoxVector2[] { new (0f, 0f) } :
reader.ReadGameBoxVector2s(numberOfTexCoords);
int numberOfAttributes = reader.ReadInt32();
Mv3Attribute[] attributes = new Mv3Attribute[numberOfAttributes];
for (int i = 0; i < numberOfAttributes; i++)
var numberOfAttributes = reader.ReadInt32();
var attributes = new Mv3Attribute[numberOfAttributes];
for (var i = 0; i < numberOfAttributes; i++)
{
int materialId = reader.ReadInt32();
int numberOfTriangles = reader.ReadInt32();
var materialId = reader.ReadInt32();
var numberOfTriangles = reader.ReadInt32();
Mv3IndexBuffer[] triangles = new Mv3IndexBuffer[numberOfTriangles];
for (int j = 0; j < numberOfTriangles; j++)
var triangles = new Mv3IndexBuffer[numberOfTriangles];
for (var j = 0; j < numberOfTriangles; j++)
{
triangles[j] = new Mv3IndexBuffer()
{
@@ -123,9 +123,9 @@ namespace Pal3.Core.DataReader.Mv3
};
}
int numberOfCommands = reader.ReadInt32();
int[] commands = new int[numberOfCommands];
for (int j = 0; j < numberOfCommands; j++)
var numberOfCommands = reader.ReadInt32();
var commands = new int[numberOfCommands];
for (var j = 0; j < numberOfCommands; j++)
{
commands[j] = reader.ReadInt32();
}
@@ -149,23 +149,24 @@ namespace Pal3.Core.DataReader.Mv3
GameBoxVector2[] texCoords)
{
int numberOfTriangles = attributes[0].IndexBuffers.Length * 3;
int[] triangles = new int[numberOfTriangles];
GameBoxVector2[] uvs = new GameBoxVector2[numberOfTriangles];
var triangles = new int[numberOfTriangles];
var uvs = new GameBoxVector2[numberOfTriangles];
int totalVerticesPerKeyFrame = attributes[0].IndexBuffers.Length * 3;
GameBoxVector3[][] keyFrameVertices = new GameBoxVector3[vertFrames.Length][];
var keyFrameVertices = new GameBoxVector3[vertFrames.Length][];
for (int i = 0; i < vertFrames.Length; i++)
{
keyFrameVertices[i] = new GameBoxVector3[totalVerticesPerKeyFrame];
}
int triangleIndex = 0;
var triangleIndex = 0;
foreach (Mv3IndexBuffer indexBuffer in attributes[0].IndexBuffers)
for (var i = 0; i < attributes[0].IndexBuffers.Length; i++)
{
for (int j = 0; j < 3; j++)
Mv3IndexBuffer indexBuffer = attributes[0].IndexBuffers[i];
for (var j = 0; j < 3; j++)
{
for (int k = 0; k < vertFrames.Length; k++)
for (var k = 0; k < vertFrames.Length; k++)
{
Mv3VertFrame frame = vertFrames[k];
Mv3Vert vertex = frame.Vertices[indexBuffer.TriangleIndex[j]];
@@ -179,8 +180,8 @@ namespace Pal3.Core.DataReader.Mv3
}
}
Mv3AnimationKeyFrame[] animationKeyFrames = new Mv3AnimationKeyFrame[vertFrames.Length];
for (int i = 0; i < animationKeyFrames.Length; i++)
var animationKeyFrames = new Mv3AnimationKeyFrame[vertFrames.Length];
for (var i = 0; i < animationKeyFrames.Length; i++)
{
animationKeyFrames[i] = new Mv3AnimationKeyFrame()
{
@@ -204,12 +205,12 @@ namespace Pal3.Core.DataReader.Mv3
private static Mv3TagNode ReadTagNode(IBinaryReader reader, int codepage)
{
string nodeName = reader.ReadString(64, codepage);
float flipScale = reader.ReadSingle();
int numberOfFrames = reader.ReadInt32();
var nodeName = reader.ReadString(64, codepage);
var flipScale = reader.ReadSingle();
var numberOfFrames = reader.ReadInt32();
Mv3TagFrame[] tagFrames = new Mv3TagFrame[numberOfFrames];
for (int i = 0; i < numberOfFrames; i++)
var tagFrames = new Mv3TagFrame[numberOfFrames];
for (var i = 0; i < numberOfFrames; i++)
{
tagFrames[i] = ReadTagFrame(reader);
}
@@ -224,10 +225,10 @@ namespace Pal3.Core.DataReader.Mv3
private static Mv3TagFrame ReadTagFrame(IBinaryReader reader)
{
uint gameBoxTick = reader.ReadUInt32();
var gameBoxTick = reader.ReadUInt32();
GameBoxVector3 gameBoxPosition = reader.ReadGameBoxVector3();
GameBoxQuaternion gameBoxRotation = new()
var gameBoxRotation = new GameBoxQuaternion()
{
X = reader.ReadSingle(),
Y = reader.ReadSingle(),
@@ -235,7 +236,7 @@ namespace Pal3.Core.DataReader.Mv3
W = reader.ReadSingle(),
};
float[][] scale =
var scale = new []
{
new [] {reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()},
new [] {reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()},
@@ -272,10 +273,10 @@ namespace Pal3.Core.DataReader.Mv3
};
List<string> textureNames = new ();
for (int i = 0; i < 4; i++)
for (var i = 0; i < 4; i++)
{
string textureName;
int length = reader.ReadInt32();
var length = reader.ReadInt32();
if (length == 0)
{
@@ -15,29 +15,29 @@ namespace Pal3.Core.DataReader.Nav
{
public NavFile Read(IBinaryReader reader, int codepage)
{
char[] header = reader.ReadChars(4);
string headerStr = new string(header[..^1]);
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
if (headerStr != "NAV")
{
throw new InvalidDataException("Invalid NAV(.nav) file: header != NAV");
}
byte version = reader.ReadByte();
byte numberOfLayers = reader.ReadByte();
uint tileOffset = reader.ReadUInt32();
uint faceOffset = reader.ReadUInt32();
var version = reader.ReadByte();
var numberOfLayers = reader.ReadByte();
var tileOffset = reader.ReadUInt32();
var faceOffset = reader.ReadUInt32();
reader.Seek(tileOffset, SeekOrigin.Begin);
NavLayer[] layers = new NavLayer[numberOfLayers];
for (int i = 0; i < numberOfLayers; i++)
var layers = new NavLayer[numberOfLayers];
for (var i = 0; i < numberOfLayers; i++)
{
layers[i] = ReadLayerData(reader, version);
}
reader.Seek(faceOffset, SeekOrigin.Begin);
NavMeshData[] meshData = new NavMeshData[numberOfLayers];
for (int i = 0; i < numberOfLayers; i++)
var meshData = new NavMeshData[numberOfLayers];
for (var i = 0; i < numberOfLayers; i++)
{
meshData[i] = ReadMeshData(reader);
}
@@ -47,12 +47,12 @@ namespace Pal3.Core.DataReader.Nav
private static NavLayer ReadLayerData(IBinaryReader reader, byte version)
{
GameBoxRect[] portals = Array.Empty<GameBoxRect>();
var portals = Array.Empty<GameBoxRect>();
if (version == 2)
{
portals = new GameBoxRect[8];
for (int i = 0; i < 8; i++)
for (var i = 0; i < 8; i++)
{
portals[i] = new GameBoxRect()
{
@@ -67,17 +67,17 @@ namespace Pal3.Core.DataReader.Nav
GameBoxVector3 gameBoxMaxWorldPosition = reader.ReadGameBoxVector3();
GameBoxVector3 gameBoxMinWorldPosition = reader.ReadGameBoxVector3();
int width = reader.ReadInt32();
int height = reader.ReadInt32();
var width = reader.ReadInt32();
var height = reader.ReadInt32();
int navMapSize = width * height;
var navMapSize = width * height;
if (navMapSize <= 0)
{
throw new Exception($"Invalid NAV(.nav) file: Map size is in valid: {navMapSize}");
}
NavTile[] tiles = new NavTile[navMapSize];
for (int i = 0; i < navMapSize; i++)
var tiles = new NavTile[navMapSize];
for (var i = 0; i < navMapSize; i++)
{
tiles[i] = new NavTile
{
@@ -101,15 +101,15 @@ namespace Pal3.Core.DataReader.Nav
private static NavMeshData ReadMeshData(IBinaryReader reader)
{
ushort numberOfVertices = reader.ReadUInt16();
ushort numberOfFaces = reader.ReadUInt16();
var numberOfVertices = reader.ReadUInt16();
var numberOfFaces = reader.ReadUInt16();
GameBoxVector3[] gameBoxVertices = reader.ReadGameBoxVector3s(numberOfVertices);
int[] gameBoxTriangles = new int[numberOfFaces * 3];
for (int i = 0; i < numberOfFaces; i++)
var gameBoxTriangles = new int[numberOfFaces * 3];
for (var i = 0; i < numberOfFaces; i++)
{
int index = i * 3;
var index = i * 3;
gameBoxTriangles[index] = reader.ReadUInt16();
gameBoxTriangles[index + 1] = reader.ReadUInt16();
gameBoxTriangles[index + 2] = reader.ReadUInt16();
@@ -121,9 +121,9 @@ namespace Pal3.Core.DataReader.Nav
{
GameBoxVector3[] normals = CoreUtility.CalculateNormals(gameBoxVertices, gameBoxTriangles);
for (int i = 0; i < numberOfFaces; i++)
for (var i = 0; i < numberOfFaces; i++)
{
int index = i * 3;
var index = i * 3;
// Determine if the face is pointing downwards.
if (normals[gameBoxTriangles[index]].Y +
@@ -14,19 +14,19 @@ namespace Pal3.Core.DataReader.Pol
{
public PolFile Read(IBinaryReader reader, int codepage)
{
char[] header = reader.ReadChars(4);
string headerStr = new string(header);
var header = reader.ReadChars(4);
var headerStr = new string(header);
if (headerStr != "POLY")
{
throw new InvalidDataException($"Invalid POLY(.pol) file: header != POLY");
}
int version = reader.ReadInt32();
int numberOfNodes = reader.ReadInt32();
var version = reader.ReadInt32();
var numberOfNodes = reader.ReadInt32();
PolGeometryNode[] nodeInfos = new PolGeometryNode[numberOfNodes];
for (int i = 0; i < numberOfNodes; i++)
var nodeInfos = new PolGeometryNode[numberOfNodes];
for (var i = 0; i < numberOfNodes; i++)
{
nodeInfos[i] = new PolGeometryNode
{
@@ -37,22 +37,22 @@ namespace Pal3.Core.DataReader.Pol
};
}
TagNode[] tagNodes = Array.Empty<TagNode>();
var tagNodes = Array.Empty<TagNode>();
if (version > 100)
{
int numberOfTagNodes = reader.ReadInt32();
var numberOfTagNodes = reader.ReadInt32();
if (numberOfTagNodes > 0)
{
tagNodes = new TagNode[numberOfTagNodes];
for (int i = 0; i < numberOfTagNodes; i++)
for (var i = 0; i < numberOfTagNodes; i++)
{
tagNodes[i] = ReadTagNodeInfo(reader, codepage);
}
}
}
PolMesh[] meshInfos = new PolMesh[numberOfNodes];
for (int i = 0; i < numberOfNodes; i++)
var meshInfos = new PolMesh[numberOfNodes];
for (var i = 0; i < numberOfNodes; i++)
{
meshInfos[i] = ReadMeshData(reader, version, codepage);
}
@@ -62,7 +62,7 @@ namespace Pal3.Core.DataReader.Pol
private static TagNode ReadTagNodeInfo(IBinaryReader reader, int codepage)
{
string name = reader.ReadString(32, codepage);
var name = reader.ReadString(32, codepage);
GameBoxMatrix4x4 gameBoxTransformMatrix = new GameBoxMatrix4x4()
{
Xx = reader.ReadSingle(), Xy = reader.ReadSingle(), Xz = reader.ReadSingle(), Xw = reader.ReadSingle(),
@@ -71,13 +71,13 @@ namespace Pal3.Core.DataReader.Pol
Tx = reader.ReadSingle(), Ty = reader.ReadSingle(), Tz = reader.ReadSingle(), Tw = reader.ReadSingle()
};
int type = reader.ReadInt32();
int customColorStringLength = reader.ReadInt32();
var type = reader.ReadInt32();
var customColorStringLength = reader.ReadInt32();
uint tintColor = 0xffffffff;
if (customColorStringLength > 0)
{
string[] parts = new string(reader.ReadChars(customColorStringLength)).Split(' ');
var parts = new string(reader.ReadChars(customColorStringLength)).Split(' ');
if (parts.Length == 3)
{
tintColor = 0xff000000 |
@@ -104,26 +104,26 @@ namespace Pal3.Core.DataReader.Pol
GameBoxVector3 gameBoxBoundsMin = reader.ReadGameBoxVector3();
GameBoxVector3 gameBoxBoundsMax = reader.ReadGameBoxVector3();
uint vertexTypeFlag = reader.ReadUInt32();
int numberOfVertices = reader.ReadInt32();
var vertexTypeFlag = reader.ReadUInt32();
var numberOfVertices = reader.ReadInt32();
if (numberOfVertices <= 0)
{
throw new InvalidDataException($"Invalid POLY(.pol) file: vertices == 0");
}
GameBoxVector3[] gameBoxPositions = new GameBoxVector3[numberOfVertices];
GameBoxVector3[] gameBoxNormals = new GameBoxVector3[numberOfVertices];
Color32[] diffuseColors = new Color32[numberOfVertices];
Color32[] specularColors = new Color32[numberOfVertices];
GameBoxVector2[][] uvs = new GameBoxVector2[4][];
var gameBoxPositions = new GameBoxVector3[numberOfVertices];
var gameBoxNormals = new GameBoxVector3[numberOfVertices];
var diffuseColors = new Color32[numberOfVertices];
var specularColors = new Color32[numberOfVertices];
var uvs = new GameBoxVector2[4][];
uvs[0] = new GameBoxVector2[numberOfVertices];
uvs[1] = new GameBoxVector2[numberOfVertices];
uvs[2] = new GameBoxVector2[numberOfVertices];
uvs[3] = new GameBoxVector2[numberOfVertices];
for (int i = 0; i < numberOfVertices; i++)
for (var i = 0; i < numberOfVertices; i++)
{
if ((vertexTypeFlag & GameBoxVertexType.XYZ) != 0)
{
@@ -148,26 +148,26 @@ namespace Pal3.Core.DataReader.Pol
}
if ((vertexTypeFlag & GameBoxVertexType.UV0) != 0)
{
float x = reader.ReadSingle();
float y = reader.ReadSingle();
var x = reader.ReadSingle();
var y = reader.ReadSingle();
uvs[0][i] = new GameBoxVector2(x, y);
}
if ((vertexTypeFlag & GameBoxVertexType.UV1) != 0)
{
float x = reader.ReadSingle();
float y = reader.ReadSingle();
var x = reader.ReadSingle();
var y = reader.ReadSingle();
uvs[1][i] = new GameBoxVector2(x, y);
}
if ((vertexTypeFlag & GameBoxVertexType.UV2) != 0)
{
float x = reader.ReadSingle();
float y = reader.ReadSingle();
var x = reader.ReadSingle();
var y = reader.ReadSingle();
uvs[2][i] = new GameBoxVector2(x, y);
}
if ((vertexTypeFlag & GameBoxVertexType.UV3) != 0)
{
float x = reader.ReadSingle();
float y = reader.ReadSingle();
var x = reader.ReadSingle();
var y = reader.ReadSingle();
uvs[3][i] = new GameBoxVector2(x, y);
}
@@ -178,7 +178,7 @@ namespace Pal3.Core.DataReader.Pol
}
}
PolVertexInfo vertexInfo = new()
var vertexInfo = new PolVertexInfo()
{
GameBoxPositions = gameBoxPositions,
GameBoxNormals = gameBoxNormals,
@@ -187,11 +187,11 @@ namespace Pal3.Core.DataReader.Pol
Uvs = uvs,
};
int numberOfTextures = reader.ReadInt32();
var numberOfTextures = reader.ReadInt32();
PolTexture[] textureInfos = new PolTexture[numberOfTextures];
var textureInfos = new PolTexture[numberOfTextures];
for (int i = 0; i < numberOfTextures; i++)
for (var i = 0; i < numberOfTextures; i++)
{
textureInfos[i] = ReadTextureInfo(reader, version, codepage);
}
@@ -223,26 +223,26 @@ namespace Pal3.Core.DataReader.Pol
if (material.SpecularPower < 0) material.SpecularPower = 0;
else if (material.SpecularPower > 128) material.SpecularPower = 128;
int numberOfTextures = reader.ReadInt32();
string[] textureNames = new string[numberOfTextures];
var numberOfTextures = reader.ReadInt32();
var textureNames = new string[numberOfTextures];
for (int i = 0; i < numberOfTextures; i++)
for (var i = 0; i < numberOfTextures; i++)
{
string textureName = reader.ReadString(64, codepage);
var textureName = reader.ReadString(64, codepage);
textureNames[i] = textureName;
}
material.TextureFileNames = textureNames;
_ = reader.ReadInt32();
uint vertStart = reader.ReadUInt32();
uint vertEnd = reader.ReadUInt32();
int numberOfFaces = reader.ReadInt32();
var vertStart = reader.ReadUInt32();
var vertEnd = reader.ReadUInt32();
var numberOfFaces = reader.ReadInt32();
int[] gameBoxTriangles = new int[numberOfFaces * 3];
for (int i = 0; i < numberOfFaces; i++)
var gameBoxTriangles = new int[numberOfFaces * 3];
for (var i = 0; i < numberOfFaces; i++)
{
int index = i * 3;
var index = i * 3;
gameBoxTriangles[index] = reader.ReadUInt16();
gameBoxTriangles[index + 1] = reader.ReadUInt16();
gameBoxTriangles[index + 2] = reader.ReadUInt16();
@@ -49,7 +49,7 @@ namespace Pal3.Core.DataReader.Sce
{
Indexes = indexes;
Dictionary<uint, SceScriptBlock> scriptBlocksDic = new();
var scriptBlocksDic = new Dictionary<uint, SceScriptBlock>();
foreach (SceScriptBlock block in scriptBlocks)
{
scriptBlocksDic[block.Id] = block;
@@ -11,31 +11,31 @@ namespace Pal3.Core.DataReader.Sce
{
public SceFile Read(IBinaryReader reader, int codepage)
{
char[] header = reader.ReadChars(4);
string headerStr = new string(header[..^1]);
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
if (headerStr != "SCE")
{
throw new InvalidDataException("Invalid SCE(.sce) file: header != SCE");
}
byte version = reader.ReadByte();
var version = reader.ReadByte();
if (version != 1)
{
throw new InvalidDataException($"Invalid SCE(.sce) file: version ({version}) != 1");
}
ushort numberOfBlocks = reader.ReadUInt16();
var numberOfBlocks = reader.ReadUInt16();
SceIndex[] indexes = new SceIndex[numberOfBlocks];
for (int i = 0; i < numberOfBlocks; i++)
var indexes = new SceIndex[numberOfBlocks];
for (var i = 0; i < numberOfBlocks; i++)
{
indexes[i] = ReadSceIndex(reader, codepage);
}
SceScriptBlock[] scriptBlocks = new SceScriptBlock[numberOfBlocks];
for (int i = 0; i < numberOfBlocks; i++)
var scriptBlocks = new SceScriptBlock[numberOfBlocks];
for (var i = 0; i < numberOfBlocks; i++)
{
scriptBlocks[i] = ReadScriptBlock(reader, indexes[i], codepage);
}
@@ -47,19 +47,19 @@ namespace Pal3.Core.DataReader.Sce
{
reader.Seek(sceIndex.Offset, SeekOrigin.Begin);
uint id = reader.ReadUInt32();
ushort descriptionLength = reader.ReadUInt16();
string description = reader.ReadString(descriptionLength, codepage);
ushort numberOfUserVars = reader.ReadUInt16();
var id = reader.ReadUInt32();
var descriptionLength = reader.ReadUInt16();
var description = reader.ReadString(descriptionLength, codepage);
var numberOfUserVars = reader.ReadUInt16();
SceUserVarInfo[] userVarInfos = new SceUserVarInfo[numberOfUserVars];
for (int i = 0; i < numberOfUserVars; i++)
var userVarInfos = new SceUserVarInfo[numberOfUserVars];
for (var i = 0; i < numberOfUserVars; i++)
{
userVarInfos[i] = ReadUserVarInfo(reader);
}
uint scriptSize = reader.ReadUInt32();
byte[] scriptData = reader.ReadBytes((int)scriptSize);
var scriptSize = reader.ReadUInt32();
var scriptData = reader.ReadBytes((int)scriptSize);
return new SceScriptBlock()
{
@@ -72,9 +72,9 @@ namespace Pal3.Core.DataReader.Sce
private static SceUserVarInfo ReadUserVarInfo(IBinaryReader reader)
{
byte type = reader.ReadByte();
ushort length = reader.ReadUInt16();
byte[] data = reader.ReadBytes(length);
var type = reader.ReadByte();
var length = reader.ReadUInt16();
var data = reader.ReadBytes(length);
return new SceUserVarInfo()
{
@@ -14,21 +14,21 @@ namespace Pal3.Core.DataReader.Scn
{
public ScnFile Read(IBinaryReader reader, int codepage)
{
char[] header = reader.ReadChars(4);
string headerStr = new (header[..^1]);
var header = reader.ReadChars(4);
var headerStr = new string(header[..^1]);
if (headerStr != "SCN")
{
throw new InvalidDataException("Invalid SCN(.scn) file: header != SCN");
}
short version = reader.ReadInt16();
short numberOfNpc = reader.ReadInt16();
uint npcDataOffset = reader.ReadUInt32();
short numberOfObjects = reader.ReadInt16();
uint objectDataOffset = reader.ReadUInt32();
var version = reader.ReadInt16();
var numberOfNpc = reader.ReadInt16();
var npcDataOffset = reader.ReadUInt32();
var numberOfObjects = reader.ReadInt16();
var objectDataOffset = reader.ReadUInt32();
ScnSceneInfo sceneInfo = new()
var sceneInfo = new ScnSceneInfo()
{
CityName = reader.ReadString(32, codepage),
SceneName = reader.ReadString(32, codepage),
@@ -40,15 +40,15 @@ namespace Pal3.Core.DataReader.Scn
};
reader.Seek(npcDataOffset, SeekOrigin.Begin);
ScnNpcInfo[] npcInfos = new ScnNpcInfo[numberOfNpc];
for (int i = 0; i < numberOfNpc; i++)
var npcInfos = new ScnNpcInfo[numberOfNpc];
for (var i = 0; i < numberOfNpc; i++)
{
npcInfos[i] = ReadNpcInfo(reader, codepage);
}
reader.Seek(objectDataOffset, SeekOrigin.Begin);
ScnObjectInfo[] objInfos = new ScnObjectInfo[numberOfObjects];
for (int i = 0; i < numberOfObjects; i++)
var objInfos = new ScnObjectInfo[numberOfObjects];
for (var i = 0; i < numberOfObjects; i++)
{
ScnObjectInfo sceneObject = ReadObjectInfo(reader, codepage);
objInfos[i] = sceneObject;
@@ -92,21 +92,21 @@ namespace Pal3.Core.DataReader.Scn
private static ScnObjectInfo ReadObjectInfo(IBinaryReader reader, int codepage)
{
byte id = reader.ReadByte();
byte initActive = reader.ReadByte();
byte times = reader.ReadByte();
byte switchState = reader.ReadByte();
var id = reader.ReadByte();
var initActive = reader.ReadByte();
var times = reader.ReadByte();
var switchState = reader.ReadByte();
string name = reader.ReadString(32, codepage);
var name = reader.ReadString(32, codepage);
byte triggerType = reader.ReadByte();
byte isNonBlocking = reader.ReadByte();
var triggerType = reader.ReadByte();
var isNonBlocking = reader.ReadByte();
_ = reader.ReadBytes(2); // Empty padding bytes to complete 4-byte alignment
GameBoxVector3 gameBoxPosition = reader.ReadGameBoxVector3();
float yRotation = reader.ReadSingle();
var gameBoxPosition = reader.ReadGameBoxVector3();
var yRotation = reader.ReadSingle();
GameBoxRect tileMapTriggerRect = new()
var tileMapTriggerRect = new GameBoxRect()
{
Left = reader.ReadInt32(),
Top = reader.ReadInt32(),
@@ -114,75 +114,75 @@ namespace Pal3.Core.DataReader.Scn
Bottom = reader.ReadInt32(),
};
SceneObjectType type = (SceneObjectType)reader.ReadByte();
byte saveState = reader.ReadByte();
byte layerIndex = reader.ReadByte();
ObjectElementType elementType = (ObjectElementType)reader.ReadByte();
var type = (SceneObjectType)reader.ReadByte();
var saveState = reader.ReadByte();
var layerIndex = reader.ReadByte();
var elementType = (ObjectElementType)reader.ReadByte();
#if PAL3
int[] parameters = reader.ReadInt32s(6);
var parameters = reader.ReadInt32s(6);
#elif PAL3A
int[] parameters = Array.ConvertAll(reader.ReadSingles(6), Convert.ToInt32);
var parameters = Array.ConvertAll(reader.ReadSingles(6), Convert.ToInt32);
#endif
#if PAL3A
uint notUsed = reader.ReadUInt32();
var notUsed = reader.ReadUInt32();
#endif
byte requireSpecialAction = reader.ReadByte();
ushort requireItem = reader.ReadUInt16();
var requireSpecialAction = reader.ReadByte();
var requireItem = reader.ReadUInt16();
_ = reader.ReadByte(); // Empty padding byte to complete 4-byte alignment
ushort requireMoney = reader.ReadUInt16();
ushort requireLevel = reader.ReadUInt16();
var requireMoney = reader.ReadUInt16();
var requireLevel = reader.ReadUInt16();
ushort requireAttackValue = reader.ReadUInt16();
byte requireAllMechanismsSolved = reader.ReadByte();
string failedMessage = reader.ReadString(16, codepage);
var requireAttackValue = reader.ReadUInt16();
var requireAllMechanismsSolved = reader.ReadByte();
var failedMessage = reader.ReadString(16, codepage);
_ = reader.ReadByte(); // Empty padding byte to complete 4-byte alignment
#if PAL3A
ushort linkedObjectGroupId = reader.ReadUInt16();
var linkedObjectGroupId = reader.ReadUInt16();
_ = reader.ReadBytes(2); // Empty padding bytes to complete 4-byte alignment
#endif
uint scriptId = reader.ReadUInt32();
var scriptId = reader.ReadUInt32();
ScnPath path = new()
var path = new ScnPath()
{
NumberOfWaypoints = reader.ReadInt32(),
GameBoxWaypoints = reader.ReadGameBoxVector3s(16)
};
ushort linkedObjectId = reader.ReadUInt16();
string dependentSceneName = reader.ReadString(32, codepage);
byte dependentObjectId = reader.ReadByte();
var linkedObjectId = reader.ReadUInt16();
var dependentSceneName = reader.ReadString(32, codepage);
var dependentObjectId = reader.ReadByte();
_ = reader.ReadByte(); // Empty padding byte to complete 4-byte alignment
GameBoxVector3 gameBoxBoundsMin = reader.ReadGameBoxVector3();
GameBoxVector3 gameBoxBoundsMax = reader.ReadGameBoxVector3();
float xRotation = reader.ReadSingle();
var xRotation = reader.ReadSingle();
#if PAL3A
float zRotation = reader.ReadSingle();
var zRotation = reader.ReadSingle();
#endif
string sfxName = reader.ReadString(8, codepage);
var sfxName = reader.ReadString(8, codepage);
uint effectModelType = reader.ReadUInt32();
var effectModelType = reader.ReadUInt32();
uint scriptActivated = reader.ReadUInt32();
uint scriptMoved = reader.ReadUInt32();
var scriptActivated = reader.ReadUInt32();
var scriptMoved = reader.ReadUInt32();
#if PAL3A
uint canOnlyBeTriggeredOnce = reader.ReadUInt32();
var canOnlyBeTriggeredOnce = reader.ReadUInt32();
#endif
#if PAL3
uint[] reserved = reader.ReadUInt32s(52);
var reserved = reader.ReadUInt32s(52);
#elif PAL3A
uint[] reserved = reader.ReadUInt32s(44);
var reserved = reader.ReadUInt32s(44);
#endif
return new ScnObjectInfo()
@@ -33,7 +33,7 @@ namespace Pal3.Core.DataReader.Tga
fixed (byte* srcStart = &data[TGA_FILE_HEADER_SIZE], dstStart = buffer)
{
byte* src = srcStart, dst = dstStart;
for (int i = 0; i < width * height; i++, src += 3, dst += 4)
for (var i = 0; i < width * height; i++, src += 3, dst += 4)
{
*dst = *(src + 2);
*(dst + 1) = *(src + 1);
@@ -67,7 +67,7 @@ namespace Pal3.Core.DataReader.Tga
hasAlphaChannel = false;
fixed (byte* srcStart = &data[TGA_FILE_HEADER_SIZE], dstStart = buffer)
{
byte firstAlpha = *(srcStart + 3);
var firstAlpha = *(srcStart + 3);
byte* src = srcStart, dst = dstStart;
for (var i = 0; i < width * height; i++, src += 4, dst += 4)
{
@@ -21,8 +21,8 @@ namespace Pal3.Core.DataReader.Txt
public CombatScnFile Read(byte[] data, int _)
{
string content = Encoding.GetEncoding(DEFAULT_CODEPAGE).GetString(data, 0, data.Length);
string[] lines = content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
var content = Encoding.GetEncoding(DEFAULT_CODEPAGE).GetString(data, 0, data.Length);
var lines = content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
string currentCombatSceneName = string.Empty;
Dictionary<FloorType, string> currentCombatSceneMap = null;
@@ -30,7 +30,7 @@ namespace Pal3.Core.DataReader.Txt
Dictionary<string, ElementType> combatSceneElementTypeInfo = new(StringComparer.OrdinalIgnoreCase);
Dictionary<string, Dictionary<FloorType, string>> combatSceneMapInfo = new(StringComparer.OrdinalIgnoreCase);
for (int i = 0; i < lines.Length; i++)
for (var i = 0; i < lines.Length; i++)
{
string line = lines[i].Trim();
@@ -18,18 +18,18 @@ namespace Pal3.Core.DataReader.Txt
public TaskDefinitionFile Read(byte[] data, int codepage)
{
string content = Encoding.GetEncoding(codepage).GetString(data, 0, data.Length);
List<Task> tasks = new();
string[] taskLines = content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
Task currentTask = new();
var content = Encoding.GetEncoding(codepage).GetString(data, 0, data.Length);
var tasks = new List<Task>();
var taskLines = content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
var currentTask = new Task();
foreach (string taskLine in taskLines)
foreach (var taskLine in taskLines)
{
if (taskLine.TrimStart().StartsWith(";")) continue;
string[] splitLine = taskLine.Split('$');
string tag = splitLine[0].Trim();
string value = splitLine.Length > 1 ? splitLine[1].Trim().Trim('$', '&') : string.Empty;
var splitLine = taskLine.Split('$');
var tag = splitLine[0].Trim();
var value = splitLine.Length > 1 ? splitLine[1].Trim().Trim('$', '&') : string.Empty;
switch (tag)
{
Loaded 100 of 222 files, more files were not shown because too many files have changed in this diff. Show more