mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1f3fcb009 | ||
|
|
af53118087 | ||
|
|
efcb28734d | ||
|
|
b1d9e3b0ac | ||
|
|
613098c3a3 | ||
|
|
51862f6398 | ||
|
|
7fe163c5ff | ||
|
|
42b616a473 | ||
|
|
44970173ee | ||
|
|
5ba326f2e4 | ||
|
|
59a4761681 | ||
|
|
7cc8ba6aab | ||
|
|
2bb0d5e2f3 | ||
|
|
5a63a2b27a | ||
|
|
980c349a81 | ||
|
|
ff3e49a4ad | ||
|
|
adcf01833b | ||
|
|
1d9072977a | ||
|
|
264db76be5 | ||
|
|
927d62ff19 | ||
|
|
85d2e15225 | ||
|
|
b016e38b9d | ||
|
|
9ca97a2977 | ||
|
|
487fc773fe | ||
|
|
8e3406abb3 | ||
|
|
991bb6823b | ||
|
|
fb814e421d | ||
|
|
30686527cc | ||
|
|
6363a80596 | ||
|
|
8433938a0e | ||
|
|
ad844450a2 | ||
|
|
6158aa2b81 | ||
|
|
714321fc71 | ||
|
|
abb147953f | ||
|
|
1ca0ec59dc | ||
|
|
a967d353e7 | ||
|
|
1e0725d767 | ||
|
|
3669e1992b | ||
|
|
9d93c1f540 | ||
|
|
95fc8445df | ||
|
|
66324a805b | ||
|
|
3ca627c8da | ||
|
|
634ca8ff27 | ||
|
|
d5e6f2d3e9 | ||
|
|
5c52760ce7 | ||
|
|
78bb782909 | ||
|
|
123583efd2 | ||
|
|
bc6ba3d486 | ||
|
|
7abe307bd1 | ||
|
|
b8bb1e018f | ||
|
|
18e3fb68ad | ||
|
|
f3eba7070e | ||
|
|
1ff06369e8 | ||
|
|
b91acc8e14 | ||
|
|
7a0836269f | ||
|
|
be36de9858 | ||
|
|
be0b9758cb | ||
|
|
458879180a | ||
|
|
d334cf9918 | ||
|
|
bb8ea6584a | ||
|
|
60f381b565 | ||
|
|
0fe5074585 | ||
|
|
f7c9d805bb | ||
|
|
25c8dd3d83 | ||
|
|
ae08e1ff92 | ||
|
|
9caf32c80b | ||
|
|
3dce798326 | ||
|
|
de98baab9b | ||
|
|
e36ced68aa | ||
|
|
778c33a246 | ||
|
|
bdcb7fa784 | ||
|
|
8ef806cca0 | ||
|
|
e1214f3143 | ||
|
|
e923a46b09 | ||
|
|
9f4c731069 | ||
|
|
3792944d10 | ||
|
|
3751ea11a4 | ||
|
|
01913ed717 | ||
|
|
09cd24ddaf | ||
|
|
c587ffe433 | ||
|
|
a18eae05ec | ||
|
|
3a6016f94e | ||
|
|
866e6325f2 | ||
|
|
f114592ddc | ||
|
|
23384143d7 | ||
|
|
608b6caa98 | ||
|
|
b41c94e232 | ||
|
|
730fb70aab | ||
|
|
1a03b20e0e | ||
|
|
b380075ee3 | ||
|
|
8368b1502e | ||
|
|
8b265c5459 | ||
|
|
ed9f744764 | ||
|
|
cd23875f3f | ||
|
|
4e85f6ef9f | ||
|
|
77cc03d167 | ||
|
|
01a586e028 | ||
|
|
f3da6151eb | ||
|
|
d8b2da7b7d | ||
|
|
72b14f8069 | ||
|
|
a4f6c4ff9c | ||
|
|
5fb27d643e | ||
|
|
2077272d1c | ||
|
|
96732877a6 | ||
|
|
1162899f69 | ||
|
|
ed8ff6cdb3 | ||
|
|
20d094f064 | ||
|
|
9e492a6ba1 | ||
|
|
b9db26c8f1 | ||
|
|
f550398fb7 | ||
|
|
1337a185bf | ||
|
|
72969ebb42 | ||
|
|
5b90410d7d | ||
|
|
7f5e57195e | ||
|
|
4e50d553c5 | ||
|
|
9d7876480e | ||
|
|
a20430358c | ||
|
|
02a7e94001 | ||
|
|
e725e96bcd | ||
|
|
cce9ff7913 | ||
|
|
f36fed85fa | ||
|
|
95778b055d | ||
|
|
2aa2229bcf | ||
|
|
0185eba411 | ||
|
|
df235e2838 | ||
|
|
3826e1c238 | ||
|
|
554446c4c1 | ||
|
|
ba175a9f0e | ||
|
|
7e1f99efd1 | ||
|
|
61a0c7bdad | ||
|
|
94bc9d63ba | ||
|
|
8a2c31cb84 | ||
|
|
3d95b0a60c | ||
|
|
e515624139 | ||
|
|
ca27dea76f | ||
|
|
78f0a1a8f7 | ||
|
|
19b1b56a29 | ||
|
|
662bf15548 | ||
|
|
31dcaf27ae | ||
|
|
252089fd48 | ||
|
|
192140b5e2 | ||
|
|
da13789bd9 | ||
|
|
2179efe8bd | ||
|
|
5628415721 | ||
|
|
68109dbeb2 | ||
|
|
c6aa72b0f4 | ||
|
|
4506397e73 | ||
|
|
89aba474ae | ||
|
|
94a3bc6466 | ||
|
|
8369ce4457 | ||
|
|
3ca369173a | ||
|
|
27e92ce148 | ||
|
|
5eb5574ff6 | ||
|
|
5e73768756 | ||
|
|
1c40f78179 | ||
|
|
3506623d43 | ||
|
|
6dcfa9acc0 | ||
|
|
f0efdfa67c | ||
|
|
ef2710f028 | ||
|
|
bd39ad5474 | ||
|
|
1db9c09281 | ||
|
|
6949a02355 |
No files matched your search
@@ -12,23 +12,34 @@ jobs:
|
||||
targetPlatform:
|
||||
- Android # Build an Android .apk standalone app.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
- uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: false
|
||||
android: true
|
||||
dotnet: true
|
||||
haskell: true
|
||||
large-packages: true
|
||||
docker-images: true
|
||||
swap-storage: true
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v3.3.1
|
||||
- uses: actions/cache@v4.2.2
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
- uses: game-ci/unity-builder@v4
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
with:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
- uses: actions/upload-artifact@v4.6.1
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
|
||||
@@ -12,18 +12,20 @@ jobs:
|
||||
targetPlatform:
|
||||
- iOS # Build an iOS player.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v3.3.1
|
||||
- uses: actions/cache@v4.2.2
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
- uses: game-ci/unity-builder@v4
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
with:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
|
||||
@@ -12,23 +12,25 @@ jobs:
|
||||
targetPlatform:
|
||||
- StandaloneLinux64 # Build a Linux 64-bit standalone.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v3.3.1
|
||||
- uses: actions/cache@v4.2.2
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
- uses: game-ci/unity-builder@v4
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
with:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
- uses: actions/upload-artifact@v4.6.1
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
|
||||
@@ -12,23 +12,25 @@ jobs:
|
||||
targetPlatform:
|
||||
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v3.3.1
|
||||
- uses: actions/cache@v4.2.2
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
- uses: game-ci/unity-builder@v4
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
with:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
- uses: actions/upload-artifact@v4.6.1
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
|
||||
@@ -13,23 +13,25 @@ jobs:
|
||||
- StandaloneWindows # Build a Windows standalone.
|
||||
- StandaloneWindows64 # Build a Windows 64-bit standalone.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
- uses: actions/cache@v3.3.1
|
||||
- uses: actions/cache@v4.2.2
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
- uses: game-ci/unity-builder@v4
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
with:
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
- uses: actions/upload-artifact@v4.6.1
|
||||
with:
|
||||
name: PAL3-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
|
||||
@@ -12,7 +12,16 @@ jobs:
|
||||
targetPlatform:
|
||||
- Android # Build an Android .apk standalone app.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
- uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: false
|
||||
android: true
|
||||
dotnet: true
|
||||
haskell: true
|
||||
large-packages: true
|
||||
docker-images: true
|
||||
swap-storage: true
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
@@ -28,20 +37,22 @@ jobs:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v3.3.1
|
||||
- uses: actions/cache@v4.2.2
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
- uses: game-ci/unity-builder@v4
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
with:
|
||||
allowDirtyBuild: true
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
- uses: actions/upload-artifact@v4.6.1
|
||||
with:
|
||||
name: PAL3A-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
targetPlatform:
|
||||
- iOS # Build an iOS player.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
@@ -28,14 +28,16 @@ jobs:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v3.3.1
|
||||
- uses: actions/cache@v4.2.2
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
- uses: game-ci/unity-builder@v4
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
with:
|
||||
allowDirtyBuild: true
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
targetPlatform:
|
||||
- StandaloneLinux64 # Build a Linux 64-bit standalone.
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
@@ -28,20 +28,22 @@ jobs:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v3.3.1
|
||||
- uses: actions/cache@v4.2.2
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
- uses: game-ci/unity-builder@v4
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
with:
|
||||
allowDirtyBuild: true
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
- uses: actions/upload-artifact@v4.6.1
|
||||
with:
|
||||
name: PAL3A-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
targetPlatform:
|
||||
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
|
||||
steps:
|
||||
- uses: actions/checkout@v3.5.0
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
@@ -28,20 +28,22 @@ jobs:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v3.3.1
|
||||
- uses: actions/cache@v4.2.2
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
- uses: game-ci/unity-builder@v4
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
with:
|
||||
allowDirtyBuild: true
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
- uses: actions/upload-artifact@v4.6.1
|
||||
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@v3.5.0
|
||||
- uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
lfs: true
|
||||
@@ -29,20 +29,22 @@ jobs:
|
||||
find: "6b32649dccc45df4ebe8e3f8eccee249"
|
||||
replace: "d03d417e5660d5849939c8fe43732dbd"
|
||||
include: "**ProjectSettings.asset"
|
||||
- uses: actions/cache@v3.3.1
|
||||
- uses: actions/cache@v4.2.2
|
||||
with:
|
||||
path: Library
|
||||
key: Library-${{ matrix.targetPlatform }}
|
||||
restore-keys: Library-
|
||||
- uses: game-ci/unity-builder@v2
|
||||
- uses: game-ci/unity-builder@v4
|
||||
env:
|
||||
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
|
||||
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
|
||||
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
|
||||
with:
|
||||
allowDirtyBuild: true
|
||||
targetPlatform: ${{ matrix.targetPlatform }}
|
||||
buildName: PAL3A
|
||||
versioning: Semantic
|
||||
- uses: actions/upload-artifact@v3.1.2
|
||||
- uses: actions/upload-artifact@v4.6.1
|
||||
with:
|
||||
name: PAL3A-Mono-${{ matrix.targetPlatform }}
|
||||
path: build/${{ matrix.targetPlatform }}
|
||||
|
||||
@@ -67,6 +67,9 @@ crashlytics-build.properties
|
||||
# MacOS generated files
|
||||
.DS_Store
|
||||
|
||||
# Unity CMake tmp files
|
||||
.utmp
|
||||
|
||||
# Unity StreamingAssets folder
|
||||
/Assets/StreamingAssets
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,41 @@
|
||||
<?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
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bed3e3b7fed51194da24fb7fb8c0a316
|
||||
guid: c94022471fa0dc1458e85b14d0c0dbd8
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
<?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>
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 284597a55e57c044bb7e9b4d3071e02d
|
||||
guid: 3d4c838ee303a814f829ff91259ec31a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
+13
-24
@@ -2,24 +2,20 @@
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2180264
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
serializedVersion: 6
|
||||
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_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 1
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
@@ -71,7 +67,6 @@ 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
|
||||
@@ -112,9 +107,9 @@ Material:
|
||||
- _Parallax: 0.02
|
||||
- _PerspectiveFilter: 0.875
|
||||
- _Reflectivity: 10
|
||||
- _ScaleRatioA: 0.9
|
||||
- _ScaleRatioA: 0.90909094
|
||||
- _ScaleRatioB: 0.73125
|
||||
- _ScaleRatioC: 0.73125
|
||||
- _ScaleRatioC: 0.7386364
|
||||
- _ScaleX: 1
|
||||
- _ScaleY: 1
|
||||
- _ShaderFlags: 0
|
||||
@@ -153,7 +148,6 @@ 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
|
||||
@@ -166,21 +160,18 @@ 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
|
||||
@@ -201,7 +192,7 @@ MonoBehaviour:
|
||||
m_AtlasTextures:
|
||||
- {fileID: 28268798066460806}
|
||||
m_AtlasTextureIndex: 0
|
||||
m_IsMultiAtlasTexturesEnabled: 0
|
||||
m_IsMultiAtlasTexturesEnabled: 1
|
||||
m_ClearDynamicDataOnBuild: 1
|
||||
m_UsedGlyphRects: []
|
||||
m_FreeGlyphRects:
|
||||
@@ -240,15 +231,21 @@ 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
|
||||
@@ -320,21 +317,15 @@ 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
|
||||
@@ -348,11 +339,9 @@ 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: OUTLINE_ON
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 1
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
@@ -23,10 +23,8 @@ 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
|
||||
@@ -61,7 +59,6 @@ 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
|
||||
@@ -76,14 +73,14 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
hashCode: 231247347
|
||||
material: {fileID: 2180264}
|
||||
materialHashCode: 198912371
|
||||
materialHashCode: -1183942120
|
||||
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
|
||||
@@ -4608,8 +4605,6 @@ MonoBehaviour:
|
||||
m_AtlasTextures:
|
||||
- {fileID: 28684132378477856}
|
||||
m_AtlasTextureIndex: 0
|
||||
m_IsMultiAtlasTexturesEnabled: 0
|
||||
m_ClearDynamicDataOnBuild: 0
|
||||
m_UsedGlyphRects:
|
||||
- m_X: 0
|
||||
m_Y: 0
|
||||
@@ -7796,20 +7791,15 @@ 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
|
||||
@@ -7823,11 +7813,9 @@ Texture2D:
|
||||
m_WrapW: 0
|
||||
m_LightmapFormat: 0
|
||||
m_ColorSpace: 0
|
||||
m_PlatformBlob:
|
||||
image data: 1048576
|
||||
_typelessdata: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040607090b0d0f101112121313131212100f0e0c0a08060603000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000407090a1313131313131313130e0d0b08030000000000000000000000000000000000000002070a0c0d1313131313131313130b0a0805000000000000000000000000000000000000000000000000000000000000050a0d0f10131313131313130e0d0b0803000000000000000000000000000000000000000000000004080a0a13131313131313131313131313131313131313131313131313131313131313131313131313131313130a09070400000000000000000000000000000000000000000006060606060600000000000000000000000000000000000000000000020507080c0f1112131211100c080806020000000000000000000000030607090d1011121312110e0a070604010000000000000000000000000000000000000000000000000000000000000000000000000606060606060000000000000000000000000000000000000000000000000000000000010507070c0f1112131312100c08080602000000000000000000000000000000000000000000000000000000000000000000030608091313131313120707050100000000000000000000000000000000000000000000000000000000000105070713131313130c0b09060100000000000000000000000000000000000000000000000000000000000306080913131313131207070501000000000000000000000000000000000000000000000000000000000105070713131313130c0b09060100000000000000000000000000000000000004080a0a0b0b0b0b0b0b0b07060401000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030607090b0d0f1111121313121211100f0d0a0807050200000000000000000000000000000000000000000000000000000000000000000003080c0e0e131313131313130f0e0c09040000000000000000000000000000000000000000000000000000000000000003070b0d0e131313131313130e0e0c0803000000000000000000000003080c0e0e131313131313130f0e0c09040000000000000000000000000000000000000000000000000000000000000003070b0d0e131313131313130e0e0c080300000000000000000000000000000000000000000000040613131313131313131312110e09040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000205070c10131315171a1c1d1e1e1f20201f1f1e1d1c1b19171513120f0b06060401000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050b101316172020202020202020201b1a18140f080100000000000000000000000000000000070e1317191a202020202020202020181715110c060000000000000000000000000000000000000000000000000000030a10161a1c1d202020202020201b1a18140f080100000000000000000000000000000000000000050b101416172020202020202020202020202020202020202020202020202020202020202020202020202020202020171614100b0500000000000000000000000000000106090b0c131313131313080705020000000000000000000000000000000002090e111414181c1e1f201f1e1c191514120e090300000000000000060b101213161a1d1e1f201e1d1b171413110d0701000000000000000000000000000000000000000000000000000000000000030608091313131313130b0a08050000000000000000000000Line truncated
|
||||
m_StreamData:
|
||||
serializedVersion: 2
|
||||
offset: 2176340
|
||||
offset: 0
|
||||
size: 0
|
||||
path:
|
||||
@@ -3,8 +3,9 @@
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
@@ -12,6 +13,12 @@ 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>*
|
||||
@@ -19,19 +26,25 @@ MonoBehaviour:
|
||||
m_OpeningTagArray: 3c00000073000000690000007a000000650000003d00000032000000650000006d0000003e0000003c000000620000003e0000003c000000230000003400000030000000660000006600000038000000300000003e0000002a000000
|
||||
m_ClosingTagArray: 2a0000003c0000002f00000073000000690000007a000000650000003e0000003c0000002f000000620000003e0000003c0000002f000000630000006f0000006c0000006f000000720000003e000000
|
||||
- m_Name: Quote
|
||||
m_HashCode: 92254330
|
||||
m_HashCode: 93368250
|
||||
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: 2687968
|
||||
m_HashCode: 2656128
|
||||
m_OpeningDefinition: <u><#40a0ff><link="ID_01">
|
||||
m_ClosingDefinition: </u></color></link>
|
||||
m_OpeningTagArray: 3c000000750000003e0000003c000000230000003400000030000000610000003000000066000000660000003e0000003c0000006c000000690000006e0000006b0000003d0000002200000049000000440000005f0000003000000031000000220000003e000000
|
||||
m_ClosingTagArray: 3c0000002f000000750000003e0000003c0000002f000000630000006f0000006c0000006f000000720000003e0000003c0000002f0000006c000000690000006e0000006b0000003e000000
|
||||
- m_Name: Title
|
||||
m_HashCode: 98732960
|
||||
m_HashCode: 97690656
|
||||
m_OpeningDefinition: <size=125%><b><align=center>
|
||||
m_ClosingDefinition: </size></b></align>
|
||||
m_OpeningTagArray: 3c00000073000000690000007a000000650000003d000000310000003200000035000000250000003e0000003c000000620000003e0000003c000000610000006c00000069000000670000006e0000003d00000063000000650000006e0000007400000065000000720000003e000000
|
||||
|
||||
@@ -12,14 +12,17 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 2705215ac5b84b70bacc50632be6e391, type: 3}
|
||||
m_Name: TMP Settings
|
||||
m_EditorClassIdentifier:
|
||||
m_enableWordWrapping: 1
|
||||
assetVersion: 2
|
||||
m_TextWrappingMode: 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/
|
||||
@@ -29,13 +32,16 @@ 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}
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
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" {}
|
||||
[HDR]_FaceColor ("Text Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_FaceTex ("Font Texture", 2D) = "white" {}
|
||||
_FaceColor ("Text Color", Color) = (1,1,1,1)
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
_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,15 +55,18 @@ SubShader{
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
@@ -81,15 +84,9 @@ SubShader{
|
||||
uniform float4 _ClipRect;
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
|
||||
float2 UnpackUV(float uv)
|
||||
{
|
||||
float2 output;
|
||||
output.x = floor(uv / 4096);
|
||||
output.y = uv - 4096 * output.x;
|
||||
|
||||
return output * 0.001953125;
|
||||
}
|
||||
uniform float _UIMaskSoftnessX;
|
||||
uniform float _UIMaskSoftnessY;
|
||||
uniform int _UIVertexColorAlwaysGammaSpace;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
@@ -101,6 +98,10 @@ SubShader{
|
||||
|
||||
float4 vPosition = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
|
||||
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
|
||||
{
|
||||
v.color.rgb = UIGammaToLinear(v.color.rgb);
|
||||
}
|
||||
fixed4 faceColor = v.color;
|
||||
faceColor *= _FaceColor;
|
||||
|
||||
@@ -108,13 +109,14 @@ SubShader{
|
||||
OUT.vertex = vPosition;
|
||||
OUT.color = faceColor;
|
||||
OUT.texcoord0 = v.texcoord0;
|
||||
OUT.texcoord1 = TRANSFORM_TEX(UnpackUV(v.texcoord1), _FaceTex);
|
||||
OUT.texcoord1 = TRANSFORM_TEX(v.texcoord1, _FaceTex);
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
|
||||
|
||||
// Clamp _ClipRect to 16bit.
|
||||
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));
|
||||
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));
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
Shader "TextMeshPro/Mobile/Bitmap" {
|
||||
|
||||
Properties {
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
[HDR]_Color ("Text Color", Color) = (1,1,1,1)
|
||||
_DiffusePower ("Diffuse Power", Range(1.0,4.0)) = 1.0
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_Color ("Text Color", Color) = (1,1,1,1)
|
||||
_DiffusePower ("Diffuse Power", Range(1.0,4.0)) = 1.0
|
||||
|
||||
_VertexOffsetX("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY("Vertex OffsetY", float) = 0
|
||||
_MaskSoftnessX("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY("Mask SoftnessY", float) = 0
|
||||
_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,15 +55,18 @@ 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;
|
||||
@@ -79,6 +82,9 @@ SubShader {
|
||||
uniform float4 _ClipRect;
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
uniform float _UIMaskSoftnessX;
|
||||
uniform float _UIMaskSoftnessY;
|
||||
uniform int _UIVertexColorAlwaysGammaSpace;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
@@ -88,8 +94,11 @@ SubShader {
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
vert.xy += (vert.w * 0.5) / _ScreenParams.xy;
|
||||
|
||||
OUT.vertex = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
|
||||
{
|
||||
v.color.rgb = UIGammaToLinear(v.color.rgb);
|
||||
}
|
||||
OUT.vertex = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
OUT.color = v.color;
|
||||
OUT.color *= _Color;
|
||||
OUT.color.rgb *= _DiffusePower;
|
||||
@@ -99,8 +108,9 @@ SubShader {
|
||||
//pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
|
||||
|
||||
// Clamp _ClipRect to 16bit.
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
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));
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
Shader "TextMeshPro/Bitmap" {
|
||||
|
||||
Properties {
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_FaceTex ("Font Texture", 2D) = "white" {}
|
||||
[HDR]_FaceColor ("Text Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_FaceTex ("Font Texture", 2D) = "white" {}
|
||||
_FaceColor ("Text Color", Color) = (1,1,1,1)
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
_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,15 +54,18 @@ SubShader{
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
struct appdata_t {
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct v2f {
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
@@ -80,15 +83,9 @@ SubShader{
|
||||
uniform float4 _ClipRect;
|
||||
uniform float _MaskSoftnessX;
|
||||
uniform float _MaskSoftnessY;
|
||||
|
||||
float2 UnpackUV(float uv)
|
||||
{
|
||||
float2 output;
|
||||
output.x = floor(uv / 4096);
|
||||
output.y = uv - 4096 * output.x;
|
||||
|
||||
return output * 0.001953125;
|
||||
}
|
||||
uniform float _UIMaskSoftnessX;
|
||||
uniform float _UIMaskSoftnessY;
|
||||
uniform int _UIVertexColorAlwaysGammaSpace;
|
||||
|
||||
v2f vert (appdata_t v)
|
||||
{
|
||||
@@ -100,6 +97,10 @@ SubShader{
|
||||
|
||||
float4 vPosition = UnityPixelSnap(UnityObjectToClipPos(vert));
|
||||
|
||||
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
|
||||
{
|
||||
v.color.rgb = UIGammaToLinear(v.color.rgb);
|
||||
}
|
||||
fixed4 faceColor = v.color;
|
||||
faceColor *= _FaceColor;
|
||||
|
||||
@@ -107,13 +108,14 @@ SubShader{
|
||||
OUT.vertex = vPosition;
|
||||
OUT.color = faceColor;
|
||||
OUT.texcoord0 = v.texcoord0;
|
||||
OUT.texcoord1 = TRANSFORM_TEX(UnpackUV(v.texcoord1), _FaceTex);
|
||||
OUT.texcoord1 = TRANSFORM_TEX(v.texcoord1, _FaceTex);
|
||||
float2 pixelSize = vPosition.w;
|
||||
pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
|
||||
|
||||
// Clamp _ClipRect to 16bit.
|
||||
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));
|
||||
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));
|
||||
|
||||
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
|
||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_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
|
||||
[HDR]_SpecularColor ("Specular", Color) = (1,1,1,1)
|
||||
_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)
|
||||
|
||||
|
||||
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
||||
_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||
|
||||
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_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,17 +127,18 @@ 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;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
|
||||
struct pixel_t {
|
||||
struct pixel_t
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 position : SV_POSITION;
|
||||
@@ -147,16 +148,20 @@ 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.
|
||||
float4 _FaceTex_ST;
|
||||
float4 _OutlineTex_ST;
|
||||
uniform float4 _FaceTex_ST;
|
||||
uniform float4 _OutlineTex_ST;
|
||||
uniform float _UIMaskSoftnessX;
|
||||
uniform float _UIMaskSoftnessY;
|
||||
uniform int _UIVertexColorAlwaysGammaSpace;
|
||||
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
@@ -167,7 +172,7 @@ SubShader {
|
||||
UNITY_TRANSFER_INSTANCE_ID(input,output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
float bold = step(input.texcoord0.w, 0);
|
||||
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
@@ -178,7 +183,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.texcoord1.y) * _GradientScale * (_Sharpness + 1);
|
||||
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;
|
||||
@@ -188,13 +193,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;
|
||||
|
||||
@@ -205,23 +210,28 @@ 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 = UnpackUV(input.texcoord1.x);
|
||||
float2 textureUV = input.texcoord1;
|
||||
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);
|
||||
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
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.viewDir = mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz);
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
output.texcoord2 = float4(input.texcoord0 + bOffset, bScale, bBias);
|
||||
@@ -239,9 +249,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;
|
||||
@@ -261,7 +271,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);
|
||||
|
||||
@@ -278,36 +288,35 @@ 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
|
||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_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
|
||||
[HDR]_SpecularColor ("Specular", Color) = (1,1,1,1)
|
||||
_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)
|
||||
|
||||
|
||||
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
||||
_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||
|
||||
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_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,7 +109,8 @@ SubShader {
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass {
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex VertShader
|
||||
@@ -127,17 +128,18 @@ 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;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
|
||||
struct pixel_t {
|
||||
struct pixel_t
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 position : SV_POSITION;
|
||||
@@ -147,18 +149,23 @@ 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);
|
||||
}
|
||||
|
||||
@@ -171,7 +178,7 @@ SubShader {
|
||||
UNITY_TRANSFER_INSTANCE_ID(input,output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
float bold = step(input.texcoord0.w, 0);
|
||||
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
@@ -182,27 +189,31 @@ 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 = UnpackUV(input.texcoord1.x);
|
||||
float2 textureUV = input.texcoord1;
|
||||
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;
|
||||
@@ -210,10 +221,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;
|
||||
@@ -226,9 +237,9 @@ SubShader {
|
||||
|
||||
float c = tex2D(_MainTex, input.atlas).a;
|
||||
|
||||
float2 pixelSize = float2(ddx(input.atlas.y), ddy(input.atlas.y));
|
||||
pixelSize *= _TextureWidth * .75;
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize)) * _GradientScale * (_Sharpness + 1);
|
||||
float pixelSize = abs(ddx(input.atlas.y)) + abs(ddy(input.atlas.y));
|
||||
pixelSize *= _TextureHeight * 0.75;
|
||||
float scale = 1 / pixelSize * _GradientScale * (_Sharpness + 1);
|
||||
|
||||
float weight = input.weight;
|
||||
float bias = (.5 - weight) + (.5 / scale);
|
||||
@@ -247,7 +258,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);
|
||||
|
||||
@@ -264,45 +275,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
|
||||
float2 maskZW = 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + (1 / scale));
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
|
||||
float2 maskZW = 0.25 / (0.25 * maskSoftness + 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
@@ -0,0 +1,10 @@
|
||||
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
@@ -0,0 +1,10 @@
|
||||
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 {
|
||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
|
||||
_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,35 +99,41 @@ SubShader {
|
||||
#include "UnityUI.cginc"
|
||||
#include "TMPro_Properties.cginc"
|
||||
|
||||
struct vertex_t {
|
||||
struct vertex_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 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.texcoord1.y, 0);
|
||||
float bold = step(input.texcoord0.w, 0);
|
||||
|
||||
float4 vert = input.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
@@ -138,7 +144,7 @@ SubShader {
|
||||
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
||||
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize));
|
||||
scale *= abs(input.texcoord1.y) * _GradientScale * (_Sharpness + 1);
|
||||
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;
|
||||
@@ -150,6 +156,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)
|
||||
opacity = 1.0;
|
||||
@@ -163,7 +173,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);
|
||||
@@ -171,11 +181,12 @@ 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 = {
|
||||
@@ -184,11 +195,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 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)),
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy)),
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
float4(input.texcoord0 + layerOffset, input.color.a, 0),
|
||||
half2(layerScale, layerBias),
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
return output;
|
||||
@@ -201,41 +212,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 {
|
||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
|
||||
_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,16 +93,18 @@ 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;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct pixel_t {
|
||||
struct pixel_t
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 vertex : SV_POSITION;
|
||||
@@ -111,12 +113,17 @@ 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)
|
||||
{
|
||||
@@ -127,7 +134,7 @@ SubShader {
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
float bold = step(input.texcoord0.w, 0);
|
||||
|
||||
float4 vert = input.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
@@ -138,7 +145,7 @@ SubShader {
|
||||
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
||||
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize));
|
||||
scale *= abs(input.texcoord1.y) * _GradientScale * (_Sharpness + 1);
|
||||
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;
|
||||
@@ -150,10 +157,14 @@ 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;
|
||||
@@ -163,14 +174,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);
|
||||
@@ -182,7 +193,8 @@ 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);
|
||||
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
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);
|
||||
@@ -200,35 +212,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 {
|
||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
|
||||
_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
|
||||
|
||||
@@ -0,0 +1,389 @@
|
||||
// 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"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0178fcb869bafef4690d177d31d17db8
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -6,14 +6,14 @@
|
||||
Shader "TextMeshPro/Mobile/Distance Field" {
|
||||
|
||||
Properties {
|
||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
|
||||
_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,6 +81,7 @@ SubShader {
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma enable_d3d11_debug_symbols
|
||||
#pragma vertex VertShader
|
||||
#pragma fragment PixShader
|
||||
#pragma shader_feature __ OUTLINE_ON
|
||||
@@ -98,7 +99,7 @@ SubShader {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
@@ -117,6 +118,9 @@ SubShader {
|
||||
#endif
|
||||
};
|
||||
|
||||
float _UIMaskSoftnessX;
|
||||
float _UIMaskSoftnessY;
|
||||
int _UIVertexColorAlwaysGammaSpace;
|
||||
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
@@ -127,7 +131,7 @@ SubShader {
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
float bold = step(input.texcoord0.w, 0);
|
||||
|
||||
float4 vert = input.vertex;
|
||||
vert.x += _VertexOffsetX;
|
||||
@@ -138,7 +142,7 @@ SubShader {
|
||||
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
||||
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize));
|
||||
scale *= abs(input.texcoord1.y) * _GradientScale * (_Sharpness + 1);
|
||||
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;
|
||||
@@ -150,7 +154,11 @@ SubShader {
|
||||
float bias = (0.5 - weight) * scale - 0.5;
|
||||
float outline = _OutlineWidth * _ScaleRatioA * 0.5 * scale;
|
||||
|
||||
float opacity = input.color.a;
|
||||
if (_UIVertexColorAlwaysGammaSpace && !IsGammaSpace())
|
||||
{
|
||||
input.color.rgb = UIGammaToLinear(input.color.rgb);
|
||||
}
|
||||
float opacity = input.color.a;
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
opacity = 1.0;
|
||||
#endif
|
||||
@@ -182,7 +190,9 @@ 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);
|
||||
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
|
||||
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);
|
||||
|
||||
@@ -7,15 +7,15 @@ Shader "TextMeshPro/Mobile/Distance Field (Surface)" {
|
||||
|
||||
Properties {
|
||||
_FaceTex ("Fill Texture", 2D) = "white" {}
|
||||
[HDR]_FaceColor ("Fill Color", Color) = (1,1,1,1)
|
||||
_FaceColor ("Fill Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineTex ("Outline Texture", 2D) = "white" {}
|
||||
_OutlineWidth ("Outline Thickness", Range(0, 1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_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,7 +99,8 @@ 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
|
||||
[HDR]_FaceColor ("Fill Color", Color) = (1,1,1,1)
|
||||
_FaceColor ("Fill Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_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)
|
||||
[HDR]_SpecColor ("Specular Color", Color) = (0,0,0,1)
|
||||
_SpecColor ("Specular Color", Color) = (0,0,0,1)
|
||||
|
||||
_FaceShininess ("Face Shininess", Range(0,1)) = 0
|
||||
_OutlineShininess ("Outline Shininess", Range(0,1)) = 0
|
||||
|
||||
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_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,7 +118,8 @@ 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
@@ -0,0 +1,10 @@
|
||||
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
@@ -0,0 +1,10 @@
|
||||
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
|
||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_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
|
||||
[HDR]_SpecularColor ("Specular", Color) = (1,1,1,1)
|
||||
_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)
|
||||
|
||||
|
||||
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
||||
_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||
|
||||
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_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,17 +127,18 @@ 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;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
|
||||
struct pixel_t {
|
||||
struct pixel_t
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 position : SV_POSITION;
|
||||
@@ -147,16 +148,20 @@ 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)
|
||||
{
|
||||
@@ -167,7 +172,7 @@ SubShader {
|
||||
UNITY_TRANSFER_INSTANCE_ID(input,output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
float bold = step(input.texcoord0.w, 0);
|
||||
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
@@ -178,7 +183,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.texcoord1.y) * _GradientScale * (_Sharpness + 1);
|
||||
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;
|
||||
@@ -188,13 +193,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;
|
||||
|
||||
@@ -205,23 +210,28 @@ 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 = UnpackUV(input.texcoord1.x);
|
||||
float2 textureUV = input.texcoord1;
|
||||
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);
|
||||
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
|
||||
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.viewDir = mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz);
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
output.texcoord2 = float4(input.texcoord0 + bOffset, bScale, bBias);
|
||||
@@ -239,9 +249,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;
|
||||
@@ -261,7 +271,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);
|
||||
|
||||
@@ -278,36 +288,35 @@ 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
|
||||
{
|
||||
[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)
|
||||
_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,29 +69,43 @@ Shader "TextMeshPro/Sprite"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
float4 mask : TEXCOORD2;
|
||||
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);
|
||||
OUT.worldPosition = v.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
||||
float4 vPosition = UnityObjectToClipPos(v.vertex);
|
||||
OUT.worldPosition = v.vertex;
|
||||
OUT.vertex = vPosition;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -99,9 +113,10 @@ Shader "TextMeshPro/Sprite"
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
|
||||
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
|
||||
color *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
@@ -110,7 +125,7 @@ Shader "TextMeshPro/Sprite"
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
userData: Version 2.0
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,20 +1,22 @@
|
||||
struct vertex_t {
|
||||
struct vertex_t
|
||||
{
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float4 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; // weight, scaleRatio
|
||||
float4 param : TEXCOORD1; // x = weight, y = no longer used
|
||||
float2 mask : TEXCOORD2;
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 texcoord2 : TEXCOORD3;
|
||||
@@ -22,10 +24,14 @@ 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;
|
||||
@@ -35,7 +41,7 @@ pixel_t VertShader(vertex_t input)
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
float bold = step(input.texcoord0.w, 0);
|
||||
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
@@ -71,7 +77,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, 1.3333 * _GradientScale * (_Sharpness + 1) / _TextureWidth, _OutlineWidth * _ScaleRatioA * 0.5, 0);
|
||||
output.param = float4(0.5 - weight, 0, _OutlineWidth * _ScaleRatioA * 0.5, 0);
|
||||
|
||||
float2 mask = float2(0, 0);
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
@@ -99,8 +105,9 @@ float4 PixShader(pixel_t input) : SV_Target
|
||||
|
||||
float d = tex2D(_MainTex, input.texcoord0.xy).a;
|
||||
|
||||
float2 UV = input.texcoord0.xy;
|
||||
float scale = rsqrt(abs(ddx(UV.x) * ddy(UV.y) - ddy(UV.x) * ddx(UV.y))) * input.param.y;
|
||||
float pixelSize = abs(ddx(input.texcoord0.y)) + abs(ddy(input.texcoord0.y));
|
||||
pixelSize *= _TextureHeight * 0.75;
|
||||
float scale = 1 / pixelSize * _GradientScale * (_Sharpness + 1);
|
||||
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
float layerScale = scale;
|
||||
@@ -112,7 +119,7 @@ float4 PixShader(pixel_t input) : SV_Target
|
||||
|
||||
float4 faceColor = input.faceColor * saturate((d - input.param.x) * scale + 0.5);
|
||||
|
||||
#ifdef OUTLINE_ON
|
||||
#if 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);
|
||||
@@ -130,7 +137,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
|
||||
|
||||
#ifdef MASKING
|
||||
#if MASKING
|
||||
float a = abs(_MaskInverse - tex2D(_MaskTex, input.texcoord0.zw).a);
|
||||
float t = a + (1 - _MaskWipeControl) * _MaskEdgeSoftness - _MaskWipeControl;
|
||||
a = saturate(t / _MaskEdgeSoftness);
|
||||
@@ -140,7 +147,8 @@ float4 PixShader(pixel_t input) : SV_Target
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
float2 maskZW = 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + (1 / scale));
|
||||
half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
|
||||
float2 maskZW = 0.25 / (0.25 * maskSoftness + 1 / scale);
|
||||
float2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * maskZW);
|
||||
faceColor *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
@@ -66,11 +66,6 @@ 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.texcoord1.y, 0);
|
||||
float bold = step(v.texcoord.w, 0);
|
||||
|
||||
// Generate normal for backface
|
||||
float3 view = ObjSpaceViewDir(v.vertex);
|
||||
@@ -20,14 +20,12 @@ 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.texcoord1.y) * _GradientScale * (_Sharpness + 1);
|
||||
scale *= abs(v.texcoord.w) * _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; //
|
||||
|
||||
v.texcoord1.xy = UnpackUV(v.texcoord1.x);
|
||||
data.param.x = (lerp(_WeightNormal, _WeightBold, bold) / 4.0 + _FaceDilate) * _ScaleRatioA * 0.5; //
|
||||
data.viewDirEnv = mul((float3x3)_EnvMatrix, WorldSpaceViewDir(v.vertex));
|
||||
}
|
||||
|
||||
@@ -82,7 +80,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;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e722869deff58e4cae41190ceee880a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
DarkMode Mod for Unity Editor on Windows
|
||||
----------------------------------------------------------------------------
|
||||
v1.1 04/08/2024
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
A fully working runtime dark mode mod for Unity Editor on Windows with:
|
||||
|
||||
- Dark title bar
|
||||
- Dark menu bar
|
||||
- Dark context menu
|
||||
- And more...
|
||||
|
||||
> This runtime mod works on Windows 11 and Windows 10 1903+.
|
||||
Tested on Unity 2019, 2020, 2021, 2022, 2023 and Unity 6.
|
||||
|
||||
Source code is available at: https://github.com/0x7c13/UnityEditor-DarkMode
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Jiaqi (0x7c13) Liu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33d8f76296a183145ae27b820db1e4b4
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
menubar_textcolor = 200,200,200
|
||||
menubar_textcolor_disabled = 160,160,160
|
||||
menubar_bgcolor = 48,48,48
|
||||
menubaritem_bgcolor = 48,48,48
|
||||
menubaritem_bgcolor_hot = 62,62,62
|
||||
menubaritem_bgcolor_selected = 62,62,62
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c50fe9ef05bb7b49bf69b0c596fd1ed
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8116b2fba7c75047b30e087741eb77b
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 1
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Editor: 0
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: Windows
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: None
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -15,7 +15,7 @@ Shader "Pal3/PostEffectDistortion"
|
||||
_XFactor ("X Factor",float) = 15.0
|
||||
_YFactor("Y Factor",float) = 10.0
|
||||
}
|
||||
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
|
||||
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
|
||||
@@ -28,18 +28,18 @@ Shader "Pal3/PostEffectDistortion"
|
||||
{
|
||||
float2 uv = i.texcoord;
|
||||
const float time = _Time.y;
|
||||
|
||||
|
||||
uv.x += sin(uv.y * _XFactor + time * _TimeScale) / 400.0;
|
||||
uv.y += cos(uv.x * _YFactor + time * _TimeScale) / 450.0;
|
||||
|
||||
uv.x += sin((uv.y+uv.x) * _XFactor + time * _TimeScale) / (180.0 + (_TimeScale * sin(time)));
|
||||
uv.y += cos((uv.y+uv.x) * _YFactor + time * _TimeScale) / (200.0 + (_TimeScale * sin(time)));
|
||||
|
||||
|
||||
float4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex,uv);
|
||||
return col;
|
||||
}
|
||||
ENDHLSL
|
||||
|
||||
|
||||
SubShader
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
@@ -1472,6 +1472,7 @@ MonoBehaviour:
|
||||
- {fileID: 455792505896753558}
|
||||
- {fileID: -804113543285745465}
|
||||
- {fileID: -8365138130595697379}
|
||||
- {fileID: 7765848554721425837}
|
||||
--- !u!114 &455792505896753558
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
@@ -1544,3 +1545,19 @@ MonoBehaviour:
|
||||
yFactor:
|
||||
overrideState: 0
|
||||
value: 10
|
||||
--- !u!114 &7765848554721425837
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dcb7f03e990a4b3eb9988671f88cd793, type: 3}
|
||||
m_Name: Snow
|
||||
m_EditorClassIdentifier:
|
||||
active: 0
|
||||
enabled:
|
||||
overrideState: 1
|
||||
value: 1
|
||||
@@ -78,6 +78,7 @@ MonoBehaviour:
|
||||
m_DeselectOnBackgroundClick: 0
|
||||
m_PointerBehavior: 0
|
||||
m_CursorLockBehavior: 0
|
||||
m_ScrollDeltaPerTick: 6
|
||||
--- !u!1 &147356287
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -258,6 +259,7 @@ AudioSource:
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_Resource: {fileID: 0}
|
||||
m_PlayOnAwake: 1
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
@@ -403,7 +405,9 @@ MonoBehaviour:
|
||||
m_BeforeTransparentBundles: []
|
||||
m_BeforeStackBundles: []
|
||||
m_AfterStackBundles:
|
||||
- assemblyQualifiedName: Pal3.Effect.PostProcessing.Distortion, Pal3, Version=0.0.0.0,
|
||||
- assemblyQualifiedName: Pal3.Game.Effect.PostProcessing.Distortion, Pal3.Game,
|
||||
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
- assemblyQualifiedName: Pal3.Game.Effect.PostProcessing.Snow, Pal3.Game, Version=0.0.0.0,
|
||||
Culture=neutral, PublicKeyToken=null
|
||||
--- !u!1 &547426358569454562
|
||||
GameObject:
|
||||
@@ -847,7 +851,7 @@ GameObject:
|
||||
- component: {fileID: 3380992277591487538}
|
||||
- component: {fileID: 6576087623676656161}
|
||||
m_Layer: 5
|
||||
m_Name: BigMapCanvas
|
||||
m_Name: WorldMapCanvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@@ -1045,15 +1049,17 @@ MonoBehaviour:
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
@@ -1440,15 +1446,17 @@ MonoBehaviour:
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
@@ -1574,15 +1582,17 @@ MonoBehaviour:
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
@@ -2864,15 +2874,17 @@ MonoBehaviour:
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
@@ -2998,15 +3010,17 @@ MonoBehaviour:
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
@@ -4062,7 +4076,7 @@ MonoBehaviour:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: "https://github.com/0x7c13/Pal3.Unity B\u7AD9@\u67D2\u624D\nCopyright (c)
|
||||
2021-2023, \u67D2\u624D(0x7c13). All rights reserved.\nCopyright (c) 2003, SOFTSTAR
|
||||
2021-2025, \u67D2\u624D(0x7c13). All rights reserved.\nCopyright (c) 2003, SOFTSTAR
|
||||
ENTERTAINMENT. All rights reserved."
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 9e1d886e63529bb4ca3c95ece3e3189c, type: 2}
|
||||
@@ -4106,15 +4120,17 @@ MonoBehaviour:
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
@@ -4146,7 +4162,7 @@ GameObject:
|
||||
- component: {fileID: 6994295648662812940}
|
||||
- component: {fileID: 6856973301777993055}
|
||||
m_Layer: 5
|
||||
m_Name: BigMapCanvasGroup
|
||||
m_Name: WorldMapCanvasGroup
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@@ -4784,15 +4800,17 @@ MonoBehaviour:
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
@@ -4929,7 +4947,7 @@ Transform:
|
||||
m_GameObject: {fileID: 8627381932629902481}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 1019.9595, y: 583.6859, z: 4.5594697}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
@@ -4982,9 +5000,10 @@ MonoBehaviour:
|
||||
dialogueSelectionButtonPrefab: {fileID: 4172465472256067823, guid: a7a35ac194873f94d8d9f86a534fb73f, type: 3}
|
||||
captionImage: {fileID: 3071742581265337525}
|
||||
debugInfo: {fileID: 9135205958574637510}
|
||||
bigMapCanvasGroup: {fileID: 6994295648662812940}
|
||||
bigMapRegionButtonPrefab: {fileID: 799485479191424804, guid: 6cb716e1f5237d348a31b595966399f8, type: 3}
|
||||
bigMapBackground: {fileID: 8628713396278854032}
|
||||
fpsCounter: {fileID: 887733067292281693}
|
||||
worldMapCanvasGroup: {fileID: 6994295648662812940}
|
||||
worldMapRegionButtonPrefab: {fileID: 799485479191424804, guid: 6cb716e1f5237d348a31b595966399f8, type: 3}
|
||||
worldMapBackground: {fileID: 8628713396278854032}
|
||||
mainMenuCanvasGroup: {fileID: 1901874775859308762}
|
||||
menuButtonPrefab: {fileID: 799485479191424804, guid: 6cb716e1f5237d348a31b595966399f8, type: 3}
|
||||
backgroundTransform: {fileID: 4335801449381553810}
|
||||
@@ -5025,7 +5044,7 @@ GameObject:
|
||||
- component: {fileID: 2118054520435326509}
|
||||
- component: {fileID: 4357341297223052173}
|
||||
m_Layer: 5
|
||||
m_Name: BigMapBackground
|
||||
m_Name: WorldMapBackground
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@@ -5262,15 +5281,17 @@ MonoBehaviour:
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -7,10 +7,10 @@ Shader "Pal3/Dev"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||
LOD 100
|
||||
@@ -18,7 +18,7 @@ Shader "Pal3/Dev"
|
||||
ZWrite Off
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Pass
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
@@ -37,7 +37,7 @@ Shader "Pal3/Dev"
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
UNITY_FOG_COORDS(7)
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
@@ -58,8 +58,8 @@ Shader "Pal3/Dev"
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
half4 col = tex2D(_MainTex, i.texcoord);
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
col.a = 0.5;
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/Opaque"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
|
||||
|
||||
|
||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
|
||||
@@ -12,67 +17,70 @@ Shader "Pal3/Opaque"
|
||||
SubShader
|
||||
{
|
||||
Lighting Off
|
||||
|
||||
|
||||
Tags { "QUEUE" = "Geometry" }
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags{ "Qeueue" = "Geometry" }
|
||||
Blend Off
|
||||
ZWrite On
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 shadowcoord : TEXCOORD1;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 shadowcoord : TEXCOORD1;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_FOG_COORDS(7)
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
float4 _TintColor;
|
||||
|
||||
|
||||
float _HasShadowTex;
|
||||
sampler2D _ShadowTex;
|
||||
float4 _ShadowTex_ST;
|
||||
float _Exposure;
|
||||
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.shadowcoord = TRANSFORM_TEX(v.shadowcoord, _ShadowTex);
|
||||
|
||||
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
||||
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
||||
UNITY_TRANSFER_FOG(o, o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.texcoord);
|
||||
half4 color = tex2D(_MainTex, i.texcoord0);
|
||||
if(_HasShadowTex > 0.5f)
|
||||
{
|
||||
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
|
||||
color *= tex2D(_ShadowTex, i.texcoord1) / (1 - _Exposure);
|
||||
}
|
||||
color *= _TintColor;
|
||||
UNITY_APPLY_FOG(i.fogCoord, color);
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Based on cician's shader from https://forum.unity3d.com/threads/simple-optimized-blur-shader.185327/#post-1267642
|
||||
// Based on RoundedCorners.shader from https://github.com/kirevdokimov/Unity-UI-Rounded-Corners
|
||||
// with some modifications
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Based on https://www.shadertoy.com/view/4dl3R4
|
||||
|
||||
Shader "Pal3/Snow"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_xSpeed ("Snow falling speed [X axis]", Range(0.1, 5)) = 2.0
|
||||
_ySpeed ("Snow falling speed [y axis]", Range(0.1, 5)) = 1.0
|
||||
}
|
||||
|
||||
HLSLINCLUDE
|
||||
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
|
||||
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
|
||||
|
||||
#define vec2 float2
|
||||
#define vec3 float3
|
||||
#define vec4 float4
|
||||
#define mod fmod
|
||||
#define fract frac
|
||||
|
||||
float _xSpeed;
|
||||
float _ySpeed;
|
||||
|
||||
// This shader uses noise shaders by stegu -- http://webstaff.itn.liu.se/~stegu/
|
||||
// This is supposed to look like snow falling, for example like
|
||||
// http://24.media.tumblr.com/tumblr_mdhvqrK2EJ1rcru73o1_500.gif
|
||||
|
||||
vec2 mod289(vec2 x) {
|
||||
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||
}
|
||||
|
||||
vec3 mod289(vec3 x) {
|
||||
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||
}
|
||||
|
||||
vec4 mod289(vec4 x) {
|
||||
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||
}
|
||||
|
||||
vec3 permute(vec3 x) {
|
||||
return mod289(((x*34.0)+1.0)*x);
|
||||
}
|
||||
|
||||
vec4 permute(vec4 x) {
|
||||
return mod((34.0 * x + 1.0) * x, 289.0);
|
||||
}
|
||||
|
||||
vec4 taylorInvSqrt(vec4 r)
|
||||
{
|
||||
return 1.79284291400159 - 0.85373472095314 * r;
|
||||
}
|
||||
|
||||
float snoise(vec2 v)
|
||||
{
|
||||
const vec4 C = vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);
|
||||
vec2 i = floor(v + dot(v, C.yy) );
|
||||
vec2 x0 = v - i + dot(i, C.xx);
|
||||
|
||||
vec2 i1;
|
||||
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
||||
vec4 x12 = x0.xyxy + C.xxzz;
|
||||
x12.xy -= i1;
|
||||
|
||||
i = mod289(i); // Avoid truncation effects in permutation
|
||||
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
|
||||
+ i.x + vec3(0.0, i1.x, 1.0 ));
|
||||
|
||||
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
|
||||
m = m*m ;
|
||||
m = m*m ;
|
||||
|
||||
vec3 x = 2.0 * fract(p * C.www) - 1.0;
|
||||
vec3 h = abs(x) - 0.5;
|
||||
vec3 ox = floor(x + 0.5);
|
||||
vec3 a0 = x - ox;
|
||||
|
||||
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
|
||||
|
||||
vec3 g;
|
||||
g.x = a0.x * x0.x + h.x * x0.y;
|
||||
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
|
||||
|
||||
return 130.0 * dot(m, g);
|
||||
}
|
||||
|
||||
float cellular2x2(vec2 P)
|
||||
{
|
||||
#define K 0.142857142857 // 1/7
|
||||
#define K2 0.0714285714285 // K/2
|
||||
#define jitter 0.8 // jitter 1.0 makes F1 wrong more often
|
||||
|
||||
vec2 Pi = mod(floor(P), 289.0);
|
||||
vec2 Pf = fract(P);
|
||||
vec4 Pfx = Pf.x + vec4(-0.5, -1.5, -0.5, -1.5);
|
||||
vec4 Pfy = Pf.y + vec4(-0.5, -0.5, -1.5, -1.5);
|
||||
vec4 p = permute(Pi.x + vec4(0.0, 1.0, 0.0, 1.0));
|
||||
p = permute(p + Pi.y + vec4(0.0, 0.0, 1.0, 1.0));
|
||||
vec4 ox = mod(p, 7.0)*K+K2;
|
||||
vec4 oy = mod(floor(p*K),7.0)*K+K2;
|
||||
vec4 dx = Pfx + jitter*ox;
|
||||
vec4 dy = Pfy + jitter*oy;
|
||||
vec4 d = dx * dx + dy * dy; // d11, d12, d21 and d22, squared
|
||||
// Sort out the two smallest distances
|
||||
|
||||
// Cheat and pick only F1
|
||||
d.xy = min(d.xy, d.zw);
|
||||
d.x = min(d.x, d.y);
|
||||
return d.x; // F1 duplicated, F2 not computed
|
||||
}
|
||||
|
||||
float fbm(vec2 p) {
|
||||
float f = 0.0;
|
||||
float w = 0.5;
|
||||
for (int i = 0; i < 5; i ++) {
|
||||
f += w * snoise(p);
|
||||
p *= 2.;
|
||||
w *= 0.5;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
float4 Frag(VaryingsDefault i) : SV_Target
|
||||
{
|
||||
float2 uv = i.texcoord;
|
||||
float2 originUV = uv;
|
||||
const float time = _Time.y;
|
||||
|
||||
uv.x *= _ScreenParams.x / _ScreenParams.y;
|
||||
|
||||
vec2 GA = float2(0.0,0.0);
|
||||
GA.x -= time * _xSpeed;
|
||||
GA.y += time * _ySpeed;
|
||||
|
||||
float F1=0.0,F2=0.0,F3=0.0,F4=0.0,F5=0.0,N1=0.0,N2=0.0,N3=0.0,N4=0.0,N5=0.0;
|
||||
float A=0.0,A1=0.0,A2=0.0,A3=0.0,A4=0.0,A5=0.0;
|
||||
|
||||
// Attentuation
|
||||
A = (uv.x-(uv.y*0.3));
|
||||
A = clamp(A,0.0,1.0);
|
||||
|
||||
// Snow layers, somewhat like an fbm with worley layers.
|
||||
F1 = 1.0-cellular2x2((uv+(GA*0.1))*8.0);
|
||||
A1 = 1.0-(A*1.0);
|
||||
N1 = smoothstep(0.998,1.0,F1)*1.0*A1;
|
||||
|
||||
F2 = 1.0-cellular2x2((uv+(GA*0.2))*6.0);
|
||||
A2 = 1.0-(A*0.8);
|
||||
N2 = smoothstep(0.995,1.0,F2)*0.85*A2;
|
||||
|
||||
F3 = 1.0-cellular2x2((uv+(GA*0.4))*4.0);
|
||||
A3 = 1.0-(A*0.6);
|
||||
N3 = smoothstep(0.99,1.0,F3)*0.65*A3;
|
||||
|
||||
F4 = 1.0-cellular2x2((uv+(GA*0.6))*3.0);
|
||||
A4 = 1.0-(A*1.0);
|
||||
N4 = smoothstep(0.98,1.0,F4)*0.4*A4;
|
||||
|
||||
F5 = 1.0-cellular2x2((uv+(GA))*1.2);
|
||||
A5 = 1.0-(A*1.0);
|
||||
N5 = smoothstep(0.98,1.0,F5)*0.25*A5;
|
||||
|
||||
float Snowout=N5+N4+N3+N2+N1;
|
||||
|
||||
float4 snowColor = vec4(Snowout*0.9, Snowout, Snowout*1.1, 1.0);
|
||||
float4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex,originUV);
|
||||
return col + snowColor;
|
||||
}
|
||||
ENDHLSL
|
||||
|
||||
SubShader
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
Pass
|
||||
{
|
||||
HLSLPROGRAM
|
||||
#pragma vertex VertDefault
|
||||
#pragma fragment Frag
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 310e70fe34ae470e9e0521e3fbb649d0
|
||||
timeCreated: 1693107269
|
||||
@@ -1,3 +1,8 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/Sprite"
|
||||
{
|
||||
Properties
|
||||
@@ -8,12 +13,12 @@ Shader "Pal3/Sprite"
|
||||
{
|
||||
Tags { "Queue" = "Transparent" }
|
||||
LOD 100
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha One
|
||||
ZWrite Off
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
@@ -1,94 +1,102 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/Transparent"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
|
||||
_Threshold ("Transparent Threshold", Range(0, 1)) = 1.0
|
||||
|
||||
|
||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
|
||||
|
||||
|
||||
[Enum(UnityEngine.Rendering.BlendMode)]
|
||||
_BlendSrcFactor("Source Blend Factor", int) = 5 // BlendMode.SrcAlpha as Default
|
||||
|
||||
|
||||
[Enum(UnityEngine.Rendering.BlendMode)]
|
||||
_BlendDstFactor("Dest Blend Factor", int) = 10 // BlendMode.OneMinusSrcAlpha as Default
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Lighting Off
|
||||
|
||||
|
||||
Tags { "Queue" = "Transparent" }
|
||||
|
||||
|
||||
// Pass 2 ,transparent part
|
||||
Pass
|
||||
{
|
||||
Blend [_BlendSrcFactor] [_BlendDstFactor]
|
||||
ZWrite Off
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 shadowcoord : TEXCOORD1;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 shadowcoord : TEXCOORD1;
|
||||
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_FOG_COORDS(7)
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
float _Threshold;
|
||||
|
||||
|
||||
float _HasShadowTex;
|
||||
sampler2D _ShadowTex;
|
||||
float4 _ShadowTex_ST;
|
||||
float _Exposure;
|
||||
|
||||
float4 _TintColor;
|
||||
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.shadowcoord = TRANSFORM_TEX(v.shadowcoord, _ShadowTex);
|
||||
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
||||
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
||||
UNITY_TRANSFER_FOG(o, o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.texcoord);
|
||||
half4 color = tex2D(_MainTex, i.texcoord0);
|
||||
const float alpha = color.a;
|
||||
if(color.a >= _Threshold)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
|
||||
if(_HasShadowTex > 0.5f)
|
||||
{
|
||||
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
|
||||
color *= tex2D(_ShadowTex, i.texcoord1) / (1 - _Exposure);
|
||||
color.a = alpha;
|
||||
}
|
||||
color *= _TintColor;
|
||||
UNITY_APPLY_FOG(i.fogCoord, color);
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/TransparentOpaquePart"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
|
||||
_Threshold ("Transparent Threshold", Range(0, 1)) = 1.0
|
||||
|
||||
|
||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
|
||||
@@ -13,43 +18,44 @@ Shader "Pal3/TransparentOpaquePart"
|
||||
SubShader
|
||||
{
|
||||
Lighting Off
|
||||
|
||||
|
||||
Tags { "Qeueue" = "Geometry" }
|
||||
|
||||
|
||||
// pass 1 , opaque part
|
||||
Pass
|
||||
{
|
||||
Blend Off
|
||||
ZWrite On
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 shadowcoord : TEXCOORD1;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 shadowcoord : TEXCOORD1;
|
||||
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_FOG_COORDS(7)
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
float _Threshold;
|
||||
|
||||
|
||||
float _HasShadowTex;
|
||||
sampler2D _ShadowTex;
|
||||
float4 _ShadowTex_ST;
|
||||
@@ -63,22 +69,23 @@ Shader "Pal3/TransparentOpaquePart"
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.shadowcoord = TRANSFORM_TEX(v.shadowcoord, _ShadowTex);
|
||||
|
||||
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
||||
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
||||
UNITY_TRANSFER_FOG(o, o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.texcoord);
|
||||
half4 color = tex2D(_MainTex, i.texcoord0);
|
||||
clip(color.a - _Threshold);
|
||||
|
||||
if(_HasShadowTex > 0.5f)
|
||||
{
|
||||
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
|
||||
color *= tex2D(_ShadowTex, i.texcoord1) / (1 - _Exposure);
|
||||
}
|
||||
color *= _TintColor;
|
||||
UNITY_APPLY_FOG(i.fogCoord, color);
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@@ -1,60 +1,67 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
Shader "Pal3/Water"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
// main texture
|
||||
_MainTex ("Main texture", 2D) = "white" {}
|
||||
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
|
||||
// alpha value
|
||||
_Alpha ("Alpha",Range(0, 1)) = 0.5
|
||||
|
||||
|
||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.3
|
||||
|
||||
|
||||
// pre baked shadow texture
|
||||
_ShadowTex ("Shadow texture", 2D) = "white" {}
|
||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||
|
||||
|
||||
[Enum(UnityEngine.Rendering.BlendMode)]
|
||||
_BlendSrcFactor("Source Blend Factor", int) = 5 // BlendMode.SrcAlpha as Default
|
||||
|
||||
|
||||
[Enum(UnityEngine.Rendering.BlendMode)]
|
||||
_BlendDstFactor("Dest Blend Factor", int) = 10 // BlendMode.OneMinusSrcAlpha as Default
|
||||
}
|
||||
|
||||
|
||||
SubShader
|
||||
{
|
||||
Lighting Off
|
||||
|
||||
|
||||
Tags { "QUEUE" = "Transparent-1" } // -1 to fix sorting order issue with semi-transparent trees etc.
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend [_BlendSrcFactor] [_BlendDstFactor]
|
||||
ZWrite Off
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 texcoord2 : TEXCOORD1;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 texcoord2 : TEXCOORD1;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_FOG_COORDS(7)
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
@@ -64,25 +71,26 @@ Shader "Pal3/Water"
|
||||
float _HasShadowTex;
|
||||
sampler2D _ShadowTex;
|
||||
float4 _ShadowTex_ST;
|
||||
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.texcoord2 = TRANSFORM_TEX(v.texcoord2, _ShadowTex);
|
||||
|
||||
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
||||
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
||||
UNITY_TRANSFER_FOG(o, o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
const half4 color = tex2D(_MainTex, i.texcoord);
|
||||
const half4 colorShadow = tex2D(_ShadowTex, i.texcoord2);
|
||||
const half4 color = tex2D(_MainTex, i.texcoord0);
|
||||
const half4 colorShadow = tex2D(_ShadowTex, i.texcoord1);
|
||||
half4 mixedColor = color * colorShadow / (1 - _Exposure);
|
||||
mixedColor.a = _Alpha; // use global alpha
|
||||
UNITY_APPLY_FOG(i.fogCoord, mixedColor);
|
||||
return mixedColor;
|
||||
}
|
||||
ENDCG
|
||||
|
||||
@@ -10,10 +10,8 @@ RenderTexture:
|
||||
m_ImageContentsHash:
|
||||
serializedVersion: 2
|
||||
Hash: 00000000000000000000000000000000
|
||||
m_ForcedFallbackFormat: 4
|
||||
m_DownscaleFallback: 0
|
||||
m_IsAlphaChannelOptional: 0
|
||||
serializedVersion: 5
|
||||
serializedVersion: 6
|
||||
m_Width: 800
|
||||
m_Height: 448
|
||||
m_AntiAliasing: 1
|
||||
@@ -24,6 +22,7 @@ RenderTexture:
|
||||
m_GenerateMips: 1
|
||||
m_SRGB: 0
|
||||
m_UseDynamicScale: 0
|
||||
m_UseDynamicScaleExplicit: 0
|
||||
m_BindMS: 0
|
||||
m_EnableCompatibleFormat: 1
|
||||
m_EnableRandomWrite: 0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataLoader
|
||||
{
|
||||
using DataReader.Bmp;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// .bmp file loader and Texture2D converter.
|
||||
/// </summary>
|
||||
public sealed class BmpTextureLoader : ITextureLoader
|
||||
{
|
||||
private BmpFile _image;
|
||||
|
||||
public void Load(byte[] data, out bool hasAlphaChannel)
|
||||
{
|
||||
hasAlphaChannel = false;
|
||||
_image = new BmpFileReader().Read(data);
|
||||
}
|
||||
|
||||
public Texture2D ToTexture2D()
|
||||
{
|
||||
if (_image == null) return null;
|
||||
|
||||
var texture = new Texture2D(_image.Info.AbsWidth,
|
||||
_image.Info.AbsHeight,
|
||||
TextureFormat.RGBA32,
|
||||
mipChain: false);
|
||||
|
||||
if (_image.Info.Height < 0)
|
||||
{
|
||||
FlipImage();
|
||||
}
|
||||
|
||||
texture.SetPixels32(_image.ImageData);
|
||||
texture.Apply(updateMipmaps: false);
|
||||
return texture;
|
||||
}
|
||||
|
||||
// flip image if height is negative
|
||||
private void FlipImage()
|
||||
{
|
||||
if (_image.Info.Height > 0)
|
||||
return;
|
||||
int w = _image.Info.AbsWidth;
|
||||
int h = _image.Info.AbsHeight;
|
||||
int h2 = h / 2;
|
||||
for (int y = 0; y < h2; y++)
|
||||
{
|
||||
for(int x = 0, o1=y*w, o2=(h-y-1)*w; x < w; x++,o1++,o2++)
|
||||
{
|
||||
(_image.ImageData[o1], _image.ImageData[o2]) = (_image.ImageData[o2], _image.ImageData[o1]);
|
||||
}
|
||||
}
|
||||
_image.Info.Height = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataLoader
|
||||
{
|
||||
using System;
|
||||
using DataReader;
|
||||
using DataReader.Dxt;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// .dds file loader and Texture2D converter.
|
||||
/// </summary>
|
||||
public sealed class DxtTextureLoader : ITextureLoader
|
||||
{
|
||||
private int _width;
|
||||
private int _height;
|
||||
private byte[] _rawData;
|
||||
private TextureFormat _format;
|
||||
|
||||
public void Load(byte[] data, out bool hasAlphaChannel)
|
||||
{
|
||||
#if ENABLE_IL2CPP || UNITY_EDITOR
|
||||
using var reader = new UnsafeBinaryReader(data);
|
||||
#else
|
||||
using var reader = new SafeBinaryReader(data);
|
||||
#endif
|
||||
|
||||
if (!IsValidDxtFile(reader))
|
||||
{
|
||||
throw new ArgumentException($"Not a valid DXT file.");
|
||||
}
|
||||
|
||||
DxtHeader header = DxtHeader.ReadHeader(reader);
|
||||
var format = header.DxtPixelFormat.Format;
|
||||
|
||||
_width = header.Width;
|
||||
_height = header.Height;
|
||||
|
||||
switch (format)
|
||||
{
|
||||
case "DXT1":
|
||||
hasAlphaChannel = false;
|
||||
LoadDxt1Texture(data);
|
||||
break;
|
||||
case "DXT3":
|
||||
hasAlphaChannel = true;
|
||||
LoadDxt3Texture(data);
|
||||
break;
|
||||
case "DXT5":
|
||||
throw new NotImplementedException("DXT5 decoder not implemented yet.");
|
||||
default:
|
||||
throw new Exception($"Texture format: {format} not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsValidDxtFile(IBinaryReader reader)
|
||||
{
|
||||
var header = new string(reader.ReadChars(4));
|
||||
if (header == "DDS ") return true;
|
||||
Debug.Log($"[{nameof(DxtTextureLoader)}] Invalid DXT header: {header}");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Texture2D.LoadRawTextureData does not support DXT1 format on iOS/Android
|
||||
// devices so we have to manually decode it to RGBA32(RGB888) format and then
|
||||
// invoke LoadRawTextureData method later to convert it to Texture2D.
|
||||
private void LoadDxt1Texture(byte[] data)
|
||||
{
|
||||
_rawData = Dxt1Decoder.ToRgba32(data, _width, _height);
|
||||
_format = TextureFormat.RGBA32;
|
||||
}
|
||||
|
||||
// Texture2D.LoadRawTextureData does not support DXT3 format
|
||||
// so we have to manually decode it to RGBA32(RGB888) format and then
|
||||
// invoke LoadRawTextureData method later to convert it to Texture2D.
|
||||
private void LoadDxt3Texture(byte[] data)
|
||||
{
|
||||
_rawData = Dxt3Decoder.ToRgba32(data, _width, _height);
|
||||
_format = TextureFormat.RGBA32;
|
||||
}
|
||||
|
||||
public Texture2D ToTexture2D()
|
||||
{
|
||||
if (_rawData == null) return null;
|
||||
Texture2D texture = new Texture2D(_width, _height, _format, mipChain: false);
|
||||
texture.LoadRawTextureData(_rawData);
|
||||
texture.Apply(updateMipmaps: false);
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataLoader
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Texture2D provider.
|
||||
/// </summary>
|
||||
public interface ITextureResourceProvider
|
||||
{
|
||||
string GetTexturePath(string name);
|
||||
|
||||
Texture2D GetTexture(string name);
|
||||
|
||||
Texture2D GetTexture(string name, out bool hasAlphaChannel);
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataLoader
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// .tga file loader and Texture2D converter.
|
||||
/// </summary>
|
||||
public sealed class TgaTextureLoader : ITextureLoader
|
||||
{
|
||||
private Color32[] _pixels;
|
||||
private short _width;
|
||||
private short _height;
|
||||
|
||||
public unsafe void Load(byte[] data, out bool hasAlphaChannel)
|
||||
{
|
||||
byte bitDepth;
|
||||
|
||||
fixed (byte* p = &data[12])
|
||||
{
|
||||
_width = *(short*)p;
|
||||
_height = *(short*)(p + 2);
|
||||
bitDepth = *(p + 4);
|
||||
}
|
||||
|
||||
var dataStartIndex = 18;
|
||||
_pixels = new Color32[_width * _height];
|
||||
|
||||
switch (bitDepth)
|
||||
{
|
||||
case 32:
|
||||
hasAlphaChannel = Convert32BitData(data, dataStartIndex);
|
||||
break;
|
||||
case 24:
|
||||
hasAlphaChannel = false;
|
||||
Convert24BitData(data, dataStartIndex);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("TGA texture had non 32/24 bit depth.");
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe bool Convert32BitData(byte[] data, int startIndex)
|
||||
{
|
||||
bool hasAlphaChannel = false;
|
||||
fixed (byte* srcStart = &data[startIndex], dstStart = &_pixels[0].r)
|
||||
{
|
||||
var firstAlpha = *(srcStart + 3);
|
||||
byte* src = srcStart, dst = dstStart;
|
||||
for (var i = 0; i < _width * _height; i++, src += 4, dst += 4)
|
||||
{
|
||||
*dst = *(src + 2);
|
||||
*(dst + 1) = *(src + 1);
|
||||
*(dst + 2) = *src;
|
||||
|
||||
var alpha = *(src + 3);
|
||||
*(dst + 3) = alpha;
|
||||
|
||||
if (alpha != firstAlpha) hasAlphaChannel = true;
|
||||
}
|
||||
}
|
||||
return hasAlphaChannel;
|
||||
}
|
||||
|
||||
private unsafe void Convert24BitData(byte[] data, int startIndex)
|
||||
{
|
||||
fixed (byte* srcStart = &data[startIndex], dstStart = &_pixels[0].r)
|
||||
{
|
||||
byte* src = srcStart, dst = dstStart;
|
||||
for (var i = 0; i < _width * _height; i++, src += 3, dst += 4)
|
||||
{
|
||||
*dst = *(src + 2);
|
||||
*(dst + 1) = *(src + 1);
|
||||
*(dst + 2) = *src;
|
||||
*(dst + 3) = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Texture2D ToTexture2D()
|
||||
{
|
||||
if (_pixels == null) return null;
|
||||
var texture = new Texture2D(_width, _height, TextureFormat.RGBA32, mipChain: false);
|
||||
texture.SetPixels32(_pixels);
|
||||
texture.Apply(updateMipmaps: false);
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Bmp
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public sealed class BmpFile
|
||||
{
|
||||
public BmpFileHeader Header;
|
||||
public BitmapInfoHeader Info;
|
||||
public uint RMask = 0x00FF0000;
|
||||
public uint GMask = 0x0000FF00;
|
||||
public uint BMask = 0x000000FF;
|
||||
public uint AMask = 0x00000000;
|
||||
public List<Color32> Palette;
|
||||
public Color32[] ImageData;
|
||||
|
||||
// private void ReplaceColor(Color32 aColorToSearch, Color32 aReplacementColor)
|
||||
// {
|
||||
// Color32 s = aColorToSearch;
|
||||
// for (int i = 0; i < ImageData.Length; i++)
|
||||
// {
|
||||
// Color32 c = ImageData[i];
|
||||
// if (c.r == s.r && c.g == s.g && c.b == s.b && c.a == s.a)
|
||||
// ImageData[i] = aReplacementColor;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void ReplaceFirstPixelColor(Color32 aReplacementColor)
|
||||
// {
|
||||
// ReplaceColor(ImageData[0], aReplacementColor);
|
||||
// }
|
||||
//
|
||||
// public void ReplaceFirstPixelColorWithTransparency()
|
||||
// {
|
||||
// ReplaceFirstPixelColor(new Color32(0, 0, 0, 0));
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,340 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Cpk
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Lzo;
|
||||
using Utils;
|
||||
|
||||
/// <summary>
|
||||
/// Load and create a structural mapping of the internal
|
||||
/// file system model within the CPK archive for accessing
|
||||
/// the file entities stored inside the archive.
|
||||
/// </summary>
|
||||
public sealed class CpkArchive
|
||||
{
|
||||
private const uint SUPPORTED_CPK_VERSION = 1;
|
||||
private const uint CPK_HEADER_MAGIC = 0x_1A_54_53_52; // CPK header magic label
|
||||
private const int CPK_DEFAULT_MAX_NUM_OF_FILE = 32768; // Max number of files per archive
|
||||
|
||||
private readonly string _filePath;
|
||||
private readonly Crc32Hash _crcHash;
|
||||
private readonly int _codepage;
|
||||
private Dictionary<uint, CpkTableEntity> _tableEntities;
|
||||
|
||||
private readonly Dictionary<uint, byte[]> _fileNameMap = new ();
|
||||
private readonly Dictionary<uint, uint> _crcToTableIndexMap = new ();
|
||||
private readonly Dictionary<uint, HashSet<uint>> _fatherCrcToChildCrcTableIndexMap = new ();
|
||||
|
||||
private bool _archiveInMemory;
|
||||
private byte[] _archiveData;
|
||||
|
||||
public CpkArchive(string cpkFilePath, Crc32Hash crcHash, int codepage)
|
||||
{
|
||||
if (!File.Exists(cpkFilePath))
|
||||
{
|
||||
throw new ArgumentException($"游戏数据加载失败,游戏原CPK压缩包不存在: {cpkFilePath}");
|
||||
}
|
||||
|
||||
_filePath = cpkFilePath;
|
||||
_crcHash = crcHash;
|
||||
_codepage = codepage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the CPK file from file system and read header + index table.
|
||||
/// </summary>
|
||||
public void Init()
|
||||
{
|
||||
using var stream = new FileStream(_filePath,
|
||||
FileMode.Open,
|
||||
FileAccess.Read,
|
||||
FileShare.ReadWrite,
|
||||
bufferSize: 8196,
|
||||
FileOptions.SequentialScan); // Use SequentialScan option to increase reading speed
|
||||
|
||||
var header = Utility.ReadStruct<CpkHeader>(stream);
|
||||
|
||||
if (!IsValidCpkHeader(header))
|
||||
{
|
||||
throw new InvalidDataException($"File: {_filePath} is not a valid CPK file.");
|
||||
}
|
||||
|
||||
var cpkTableEntitySize = Marshal.SizeOf(typeof(CpkTableEntity));
|
||||
var indexTableSize = cpkTableEntitySize * CPK_DEFAULT_MAX_NUM_OF_FILE;
|
||||
Span<byte> indexTableBuffer = new byte[indexTableSize];
|
||||
// Read the whole index table into memory before processing
|
||||
// to avoid I/O overhead
|
||||
_ = stream.Read(indexTableBuffer);
|
||||
|
||||
_tableEntities = new Dictionary<uint, CpkTableEntity>((int)header.FileNum);
|
||||
|
||||
var numOfFiles = header.FileNum;
|
||||
var maxFileCount = header.MaxFileNum;
|
||||
var filesFound = 0;
|
||||
var indexTableOffset = 0;
|
||||
for (uint i = 0; i < maxFileCount; i++)
|
||||
{
|
||||
var tableEntity = Utility.ReadStruct<CpkTableEntity>(indexTableBuffer, indexTableOffset);
|
||||
indexTableOffset += cpkTableEntitySize;
|
||||
if (tableEntity.IsEmpty() || tableEntity.IsDeleted()) continue;
|
||||
|
||||
_tableEntities[i] = tableEntity;
|
||||
filesFound++;
|
||||
if (numOfFiles == filesFound) break;
|
||||
}
|
||||
|
||||
BuildCrcIndexMap();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract the complete archive to the specified destination
|
||||
/// </summary>
|
||||
public void ExtractTo(string outputFolder)
|
||||
{
|
||||
ExtractToInternal(outputFolder, GetRootEntries());
|
||||
}
|
||||
|
||||
private void ExtractToInternal(string outputFolder, IEnumerable<CpkEntry> nodes)
|
||||
{
|
||||
foreach (CpkEntry node in nodes)
|
||||
{
|
||||
var relativePath = node.VirtualPath.Replace(
|
||||
CpkConstants.DirectorySeparatorChar, Path.DirectorySeparatorChar);
|
||||
|
||||
if (node.IsDirectory)
|
||||
{
|
||||
new DirectoryInfo(outputFolder + relativePath).Create();
|
||||
ExtractToInternal(outputFolder, node.Children);
|
||||
}
|
||||
else
|
||||
{
|
||||
File.WriteAllBytes(outputFolder + relativePath, ReadAllBytes(node.VirtualPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if file exists inside the archive.
|
||||
/// </summary>
|
||||
/// <param name="fileVirtualPath">Virtualized file path inside CPK archive</param>
|
||||
/// <returns>True if file exists</returns>
|
||||
public bool FileExists(string fileVirtualPath)
|
||||
{
|
||||
var crc = _crcHash.Compute(fileVirtualPath.ToLower(), _codepage);
|
||||
return _crcToTableIndexMap.ContainsKey(crc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read all bytes of the give file stored inside the archive.
|
||||
/// </summary>
|
||||
/// <param name="fileVirtualPath">Virtualized file path inside CPK archive</param>
|
||||
/// <returns>File content in byte array</returns>
|
||||
public byte[] ReadAllBytes(string fileVirtualPath)
|
||||
{
|
||||
return _archiveInMemory ?
|
||||
ReadAllBytesUsingInMemoryCache(fileVirtualPath) :
|
||||
GetFileContent(fileVirtualPath);
|
||||
}
|
||||
|
||||
private byte[] ReadAllBytesUsingInMemoryCache(string fileVirtualPath)
|
||||
{
|
||||
CpkTableEntity entity = ValidateAndGetTableEntity(fileVirtualPath);
|
||||
|
||||
byte[] data;
|
||||
|
||||
var start = (int) entity.StartPos;
|
||||
var end = (int) (entity.StartPos + entity.PackedSize);
|
||||
|
||||
if (entity.IsCompressed())
|
||||
{
|
||||
data = new byte[entity.OriginSize];
|
||||
MiniLzo.Decompress(_archiveData[start..end], data);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _archiveData[start..end];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private byte[] GetFileContent(string fileVirtualPath)
|
||||
{
|
||||
CpkTableEntity entity = ValidateAndGetTableEntity(fileVirtualPath);
|
||||
return GetFileContentInternal(entity);
|
||||
}
|
||||
|
||||
private byte[] GetFileContentInternal(CpkTableEntity entity)
|
||||
{
|
||||
byte[] rawData;
|
||||
|
||||
if (_archiveInMemory)
|
||||
{
|
||||
var start = (int) entity.StartPos;
|
||||
var end = (int) (entity.StartPos + entity.PackedSize);
|
||||
rawData = _archiveData[start..end];
|
||||
}
|
||||
else
|
||||
{
|
||||
using var stream = new FileStream(_filePath, FileMode.Open, FileAccess.Read);
|
||||
stream.Seek(entity.StartPos, SeekOrigin.Begin);
|
||||
var buffer = new byte[entity.PackedSize];
|
||||
_ = stream.Read(buffer, 0, (int)entity.PackedSize);
|
||||
rawData = buffer;
|
||||
}
|
||||
|
||||
if (!entity.IsCompressed()) return rawData;
|
||||
|
||||
var decompressedData = new byte[entity.OriginSize];
|
||||
MiniLzo.Decompress(rawData, decompressedData);
|
||||
return decompressedData;
|
||||
}
|
||||
|
||||
private CpkTableEntity ValidateAndGetTableEntity(string fileVirtualPath)
|
||||
{
|
||||
var crc = _crcHash.Compute(fileVirtualPath.ToLower(), _codepage);
|
||||
if (!_crcToTableIndexMap.ContainsKey(crc))
|
||||
{
|
||||
throw new ArgumentException($"<{fileVirtualPath}> does not exists in the archive.");
|
||||
}
|
||||
|
||||
CpkTableEntity entity = _tableEntities[_crcToTableIndexMap[crc]];
|
||||
|
||||
if (entity.IsDirectory())
|
||||
{
|
||||
throw new InvalidOperationException($"Cannot open <{fileVirtualPath}> since it is a directory.");
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Preload archive into memory for faster read performance.
|
||||
/// </summary>
|
||||
public void LoadArchiveIntoMemory()
|
||||
{
|
||||
_archiveData = File.ReadAllBytes(_filePath);
|
||||
_archiveInMemory = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose in-memory archive data.
|
||||
/// </summary>
|
||||
public void DisposeInMemoryArchive()
|
||||
{
|
||||
_archiveInMemory = false;
|
||||
_archiveData = null;
|
||||
}
|
||||
|
||||
private static bool IsValidCpkHeader(CpkHeader header)
|
||||
{
|
||||
if (header.Label != CPK_HEADER_MAGIC) return false;
|
||||
if (header.Version != SUPPORTED_CPK_VERSION) return false;
|
||||
if (header.TableStart == 0) return false;
|
||||
if (header.FileNum > header.MaxFileNum) return false;
|
||||
if (header.ValidTableNum > header.MaxTableNum) return false;
|
||||
if (header.FileNum > header.ValidTableNum) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void BuildCrcIndexMap()
|
||||
{
|
||||
foreach ((var index, CpkTableEntity entity) in _tableEntities)
|
||||
{
|
||||
_crcToTableIndexMap[entity.CRC] = index;
|
||||
|
||||
if (_fatherCrcToChildCrcTableIndexMap.TryGetValue(entity.FatherCRC, out var childCrcTable))
|
||||
{
|
||||
childCrcTable.Add(entity.CRC);
|
||||
}
|
||||
else
|
||||
{
|
||||
_fatherCrcToChildCrcTableIndexMap[entity.FatherCRC] = new HashSet<uint> {entity.CRC};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build a tree structure map of the internal file system
|
||||
/// and return the root nodes in CpkEntry format.
|
||||
/// </summary>
|
||||
/// <returns>Root level CpkEntry nodes</returns>
|
||||
public IEnumerable<CpkEntry> GetRootEntries()
|
||||
{
|
||||
if (_fileNameMap.Count == 0) BuildFileNameMap();
|
||||
return GetChildren(0);
|
||||
}
|
||||
|
||||
private void BuildFileNameMap()
|
||||
{
|
||||
Stream stream;
|
||||
if (_archiveInMemory)
|
||||
{
|
||||
stream = new MemoryStream(_archiveData);
|
||||
}
|
||||
else
|
||||
{
|
||||
stream = new FileStream(_filePath,
|
||||
FileMode.Open,
|
||||
FileAccess.Read,
|
||||
FileShare.ReadWrite,
|
||||
bufferSize: 8196,
|
||||
FileOptions.RandomAccess);
|
||||
}
|
||||
|
||||
foreach (CpkTableEntity entity in _tableEntities.Values)
|
||||
{
|
||||
long extraInfoOffset = entity.StartPos + entity.PackedSize;
|
||||
var extraInfo = new byte[entity.ExtraInfoSize];
|
||||
stream.Seek(extraInfoOffset, SeekOrigin.Begin);
|
||||
_ = stream.Read(extraInfo);
|
||||
|
||||
var fileName = Utility.TrimEnd(extraInfo, new byte[] { 0x00, 0x00 });
|
||||
_fileNameMap[entity.CRC] = fileName;
|
||||
}
|
||||
|
||||
stream.Close();
|
||||
stream.Dispose();
|
||||
}
|
||||
|
||||
private IEnumerable<CpkEntry> GetChildren(uint fatherCrc, string rootPath = "")
|
||||
{
|
||||
if (!_fatherCrcToChildCrcTableIndexMap.ContainsKey(fatherCrc))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(rootPath))
|
||||
{
|
||||
rootPath += CpkConstants.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
foreach (var childCrc in _fatherCrcToChildCrcTableIndexMap[fatherCrc])
|
||||
{
|
||||
var index = _crcToTableIndexMap[childCrc];
|
||||
CpkTableEntity child = _tableEntities[index];
|
||||
var fileName = Encoding.GetEncoding(_codepage).GetString(_fileNameMap[child.CRC]);
|
||||
|
||||
var virtualPath = rootPath + fileName;
|
||||
|
||||
if (child.IsDirectory())
|
||||
{
|
||||
yield return new CpkEntry(virtualPath, true, GetChildren(child.CRC, virtualPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return new CpkEntry(virtualPath, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Dat
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public struct EffectGroupInfo
|
||||
{
|
||||
public int EffGroupId; // 特效组Id
|
||||
public bool IsCenteredAroundCaster; // 以发动方中心
|
||||
public bool IsCenteredAroundReceiver; // 以接收方中心
|
||||
public bool IsCasterActor; // 发动方是人物
|
||||
public bool IsReceiverActor; // 接收方是人物
|
||||
public Vector3 Position; // 特效位置
|
||||
public float WaitDurationInSeconds; // 等待时间
|
||||
public float EffectDurationInSeconds; // 特效时间
|
||||
}
|
||||
|
||||
public struct EffectLinker
|
||||
{
|
||||
public uint SkillId;
|
||||
public EffectGroupInfo[] EffectGroupInfos;
|
||||
}
|
||||
|
||||
public sealed class EffectLinkerFile
|
||||
{
|
||||
public EffectLinkerFile(EffectLinker[] effectLinkers)
|
||||
{
|
||||
EffectLinkers = effectLinkers;
|
||||
}
|
||||
|
||||
public EffectLinker[] EffectLinkers { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,314 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Gdb
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[Flags]
|
||||
public enum WuLingType
|
||||
{
|
||||
Water = 0, // 水
|
||||
Fire = 1, // 火
|
||||
Wind = 2, // 风
|
||||
Thunder = 4, // 雷
|
||||
Earth = 8, // 土
|
||||
}
|
||||
|
||||
public enum ItemType
|
||||
{
|
||||
None = 0,
|
||||
Healing, // 治疗
|
||||
Throwable, // 投掷
|
||||
Treasure, // 仙宝
|
||||
Antique, // 古董
|
||||
Ore, // 矿石
|
||||
Plot, // 剧情
|
||||
Cloth, // 衣服
|
||||
Hat, // 帽子
|
||||
Shoes, // 鞋子
|
||||
Wearable, // 饰品
|
||||
Weapon, // 武器
|
||||
Corpse, // 尸块
|
||||
Blueprint, // 蓝图(梦溪杂录,美食方)
|
||||
}
|
||||
|
||||
public enum WeaponType
|
||||
{
|
||||
None = 0,
|
||||
Spear, // 长矛
|
||||
Sword, // 剑
|
||||
Staff, // 杖
|
||||
Machete, // 刀
|
||||
Bow, // 弓
|
||||
Spine, // 刺
|
||||
Sickle, // 镰刀
|
||||
}
|
||||
|
||||
public enum SpecialType
|
||||
{
|
||||
None = 0,
|
||||
Poison, // 随机中毒
|
||||
Flee, // 100%逃跑
|
||||
Navigation, // 引路蜂类
|
||||
LevelUp, // 升级类(等级提高1)
|
||||
}
|
||||
|
||||
public enum TargetRangeType
|
||||
{
|
||||
None = 0,
|
||||
FirstParty, // 我方单体
|
||||
FirstPartyAll, // 我方全体
|
||||
EnemyParty, // 敌方单体
|
||||
EnemyPartyAll, // 敌方全体
|
||||
EnemyPartyRow, // 敌方一排
|
||||
EnemyPartyColumn, // 敌方一列
|
||||
}
|
||||
|
||||
public enum PlaceOfUseType
|
||||
{
|
||||
None = 0,
|
||||
Combat, // 战斗中
|
||||
OutOfCombat, // 非战斗中
|
||||
Anywhere, // 任何地方
|
||||
}
|
||||
|
||||
public enum ActorAttributeType
|
||||
{
|
||||
Hp, // 精
|
||||
Sp, // 气
|
||||
Mp, // 神
|
||||
Attack, // 攻击
|
||||
Defense, // 防御
|
||||
Speed, // 速度
|
||||
Luck, // 幸运
|
||||
Water, // 水
|
||||
Fire, // 火
|
||||
Wind, // 风
|
||||
Thunder, // 雷
|
||||
Earth, // 土
|
||||
}
|
||||
|
||||
public enum CombatActorType
|
||||
{
|
||||
MainActor = 0, // 主角
|
||||
Human, // 人
|
||||
Monster, // 妖
|
||||
Fairy, // 仙
|
||||
God, // 神
|
||||
Ghost, // 鬼
|
||||
Demon // 魔
|
||||
}
|
||||
|
||||
public enum ActorCombatState
|
||||
{
|
||||
PoisonWind = 0, // 风毒
|
||||
PoisonThunder, // 雷毒
|
||||
PoisonWater, // 水毒
|
||||
PoisonFire, // 火毒
|
||||
PoisonEarth, // 土毒
|
||||
AttackIncrease, // 武 临时增加10%
|
||||
AttackDecrease, // 武 临时降低10%
|
||||
DefenseIncrease, // 防 临时增加10%
|
||||
DefenseDecrease, // 防 临时降低10%
|
||||
LuckIncrease, // 运 临时增加10%
|
||||
LuckDecrease, // 运 临时降低10%
|
||||
SpeedIncrease, // 速 临时增加10%
|
||||
SpeedDecrease, // 速 临时降低10%
|
||||
Paralysis, // 定(麻痹)
|
||||
Seal, // 封(封咒)
|
||||
Forbidden, // 禁(禁忌)
|
||||
Sleep, // 眠(催眠)
|
||||
Chaos, // 乱(混乱)
|
||||
Madness, // 狂(疯狂)
|
||||
Reflection, // 镜(攻击反射)
|
||||
Evade, // 避(防避,物理攻击无效)
|
||||
Barrier, // 界(结界,仙术攻击无效)
|
||||
Invisible, // 隐形
|
||||
Dying, // 濒死
|
||||
Death, // 死亡
|
||||
PoisonResist, // 避毒
|
||||
PoisonAny, // 任意毒
|
||||
EvilResist, // 辟邪
|
||||
DemonResist, // 退魔
|
||||
GodsEye, // 神眼
|
||||
ExpIncrease, // 精进
|
||||
}
|
||||
|
||||
public enum SkillType
|
||||
{
|
||||
StandardMagic = 0, // 标准技能
|
||||
AssistMagic, // 辅助技能
|
||||
DamageMagic, // 伤害法术
|
||||
RecoverMagic, // 恢复法术
|
||||
WeaponMagic, // 武器技
|
||||
}
|
||||
|
||||
public struct GameItemInfo
|
||||
{
|
||||
public uint Id; // 物品ID
|
||||
|
||||
public string Name; // 物品名称
|
||||
public string ModelName; // 物品模型名称
|
||||
public string IconName; // 物品图标名称
|
||||
public string Description; // 物品描述
|
||||
public int Price; // 物品价格
|
||||
|
||||
public ItemType Type; // 物品类型
|
||||
public WeaponType WeaponType; // 武器类型(只有物品为武器的时候有意义)
|
||||
|
||||
public byte[] MainActorCanUse; // 主角可使用信息
|
||||
public byte[] WuLing; // 五灵属性
|
||||
|
||||
public int AncientValue; // 古董价值
|
||||
|
||||
public SpecialType SpecialType; // 特殊类型
|
||||
public TargetRangeType TargetRangeType; // 目标范围类型
|
||||
public PlaceOfUseType PlaceOfUseType; // 使用地点类型
|
||||
|
||||
public byte[] AttributeImpactType; // 角色属性影响类型 (0绝对值,1百分比值,2恢复到上限,3增加上限值)
|
||||
public short[] AttributeImpactValue; // 角色属性影响值
|
||||
|
||||
public byte[] CombatStateImpactType; // 战斗状态影响类型(0不影响,1增加,2解除)
|
||||
public short[] CombatStateImpactValue; // 战斗状态值
|
||||
|
||||
public int ComboCount; // 连击次数
|
||||
|
||||
// 装备属性
|
||||
public short SpSavingPercentage; // 气消耗减少百分比
|
||||
public short MpSavingPercentage; // 神消耗减少百分比
|
||||
public short CriticalAttackAmplifyPercentage; // 暴击伤害增加百分比
|
||||
public short SpecialSkillSuccessRate; // 特技成功率增加百分比
|
||||
|
||||
// 尸块属性
|
||||
public uint OreId; // 矿石ID
|
||||
public uint ProductId; // 炼制出的物品ID
|
||||
public int ProductPrice; // 炼制出的物品价格
|
||||
|
||||
// 合成属性
|
||||
public uint[] SynthesisMaterialIds; // 两种合成材料的ID
|
||||
public uint SynthesisProductId; // 合成出的物品ID
|
||||
}
|
||||
|
||||
public struct CombatActorInfo
|
||||
{
|
||||
public uint Id; // 战斗角色ID
|
||||
|
||||
public CombatActorType Type; // 战斗角色类型
|
||||
public string Description; // 战斗角色描述
|
||||
public string ModelId; // 战斗角色模型ID
|
||||
public string IconId; // 战斗角色图标ID
|
||||
|
||||
public int[] WuLing; // 五灵属性
|
||||
public string Name; // 战斗角色名称
|
||||
public int Level; // 战斗角色等级
|
||||
public int[] AttributeValue; // 角色属性值
|
||||
public byte[] CombatStateImpactType; // 战斗状态影响类型(0不影响,1增加,2解除)
|
||||
public int RoundNumber; // 指定回合数
|
||||
public int SpecialActionId; // 特殊动作ID
|
||||
public float EscapeRate; // 逃跑概率
|
||||
public ushort[] MainActorFavor; // 对每个主角的好感
|
||||
public int Experience; // 经验值
|
||||
public ushort Money; // 金钱
|
||||
public uint NormalAttackActionId; // 普通攻击动作ID
|
||||
|
||||
public byte HeightLevel; // 迷宫高度 0-2 对应 低 中 高
|
||||
public byte MoveRangeLevel; // 运动范围 0-3 对应 不动 小 中 大
|
||||
public byte AttackRangeLevel; // 索敌范围 0-2 对应 小 中 大
|
||||
public byte MoveSpeedLevel; // 运动速度 0-3 对应 不动 小 中 大
|
||||
public byte ChaseSpeedLevel; // 追踪速度 0-2 对应 小 中 大
|
||||
public uint[] SkillIds; // 怪物所会的仙术ID [0-2] [3]为Boss级法术
|
||||
public byte[] SkillLevels; // 怪物所会的3种法术的等级 boss级法术无此属性
|
||||
public int SpImpactValue; // 物理攻击对我方气的影响值
|
||||
|
||||
public float[] Properties; // 附加属性,主要用于战斗音效类型的判断
|
||||
|
||||
public uint NormalLoot; // 普通战利品
|
||||
public short NormalLootCount; // 普通战利品数量
|
||||
public uint CorpseId; // 尸块ID
|
||||
public uint CorpseSkillId; // 触发尸块的技能ID
|
||||
public short CorpseSuccessRate; // 尸块获得成功率
|
||||
public short StealableMoneyAmount; // 可偷多少钱
|
||||
public uint StealableItemId; // 可偷物品ID
|
||||
public short StealableItemCount; // 可偷物品数量
|
||||
public short MoneyWhenKilled; // 被击败时可得钱数
|
||||
}
|
||||
|
||||
public struct SkillInfo
|
||||
{
|
||||
public uint Id; // 技能ID
|
||||
public SkillType Type; // 技能类型
|
||||
public int[] WuLing; // 五灵属性
|
||||
public string Name; // 技能名称
|
||||
public string Description; // 技能描述
|
||||
public byte[] MainActorCanUse; // 主角是否可以使用
|
||||
|
||||
public TargetRangeType TargetRangeType; // 目标范围类型
|
||||
public byte SpecialSkillId; // 特殊技能ID 0为无特殊效果 1开头为偷敌人东西
|
||||
public byte[] AttributeImpactType; // 属性影响类型 增加(或减少)数值的类型(0为绝对值,1为百分数,2为恢复到上限,3为增加上限值)
|
||||
public short[] AttributeImpactValue; // 属性影响数值
|
||||
|
||||
public byte SuccessRateLevel; // 施法成功率 0~10对应不约定的计算方式 其他为百分比
|
||||
public short[] CombatStateImpactType; // 战斗状态影响类型(0不影响,1增加,2解除)
|
||||
public int[] ConsumeAttributeType; // 消耗属性类型
|
||||
public int[] ConsumeAttributeKind; // 消耗属性种类数值 0-消耗气,1-消耗神,2-特殊消耗[精气神武防,情经速运级,钱水火风雷土蛊];
|
||||
public byte SpecialConsumeType; // 特殊消耗类型 增加(或减少)数值的类型(0为绝对值,1为百分数,2为恢复到上限,3为增加上限值)
|
||||
public int SpecialConsumeValue; // 特殊消耗数值
|
||||
|
||||
public byte Level; // 技能等级
|
||||
public byte[] TimesBeforeLevelUp; // 升级前需使用次数
|
||||
public byte RequiredActorLevel; // 使用所需角色等级
|
||||
public byte MagicLevel; // 本级法术等级
|
||||
public uint NextLevelSkillId; // 下一级法术ID
|
||||
public byte IsUsableOutsideCombat; // 是否可以在战斗外使用
|
||||
|
||||
public uint[] CompositeSkillIds; // 可以合成的法术ID
|
||||
public uint[] CompositeRequiredSkillIds; // 合成所需其他法术ID
|
||||
public byte[] CompositeRequiredSkillLevels; // 合成所需其他法术等级
|
||||
public byte[] CompositeRequiredCurrentSkillLevels; // 合成所需法术当前等级
|
||||
public byte[] CompositeRequiredActorLevels; // 合成所需角色等级
|
||||
public byte CanTriggerComboSkill; // 是否可以触发合击技
|
||||
}
|
||||
|
||||
public struct ComboSkillInfo
|
||||
{
|
||||
public string Name; // 合击技名称
|
||||
public uint Id; // 合击技ID
|
||||
public uint[] MainActorRequirements; // 需要的人
|
||||
public byte[] WuLingPositionRequirements; // 需要每个人的五灵位置,于上面数组一一对应[0-任意 1-水...6-中 7-风火雷[任意] 8-水火土[任意]]
|
||||
public uint SkillId; // 发动技能ID
|
||||
public byte[] WeaponTypeRequirements; // 对应每个参战者的武器类型
|
||||
public int[] CombatStateRequirements; // 对应每个参战者的战斗状态要求
|
||||
public string Description; // 合击技描述
|
||||
public TargetRangeType TargetRangeType; // 使用范围类型
|
||||
public byte[] AttributeImpactType; // 属性影响类型 增加(或减少)数值的类型(0为绝对值,1为百分数,2为恢复到上限,3为增加上限值)
|
||||
public short[] AttributeImpactValue; // 属性影响数值
|
||||
|
||||
#if PAL3A
|
||||
public int Unknown; // 三外特有数据 暂时未知 猜测是需要气的总数值?
|
||||
#endif
|
||||
}
|
||||
|
||||
// Pal3 Game Database file
|
||||
public sealed class GdbFile
|
||||
{
|
||||
public IDictionary<int, CombatActorInfo> CombatActorInfos { get; }
|
||||
public IDictionary<int, SkillInfo> SkillInfos { get; }
|
||||
public IDictionary<int, GameItemInfo> GameItemInfos { get; }
|
||||
public IDictionary<int, ComboSkillInfo> ComboSkillInfos { get; }
|
||||
|
||||
public GdbFile(IDictionary<int, CombatActorInfo> combatActorInfos,
|
||||
IDictionary<int, SkillInfo> skillInfos,
|
||||
IDictionary<int, GameItemInfo> gameItemInfos,
|
||||
IDictionary<int, ComboSkillInfo> comboSkillInfos)
|
||||
{
|
||||
CombatActorInfos = combatActorInfos;
|
||||
SkillInfos = skillInfos;
|
||||
GameItemInfos = gameItemInfos;
|
||||
ComboSkillInfos = comboSkillInfos;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Gdb
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
public sealed class GdbFileReader : IFileReader<GdbFile>
|
||||
{
|
||||
public GdbFile Read(IBinaryReader reader, int codepage)
|
||||
{
|
||||
_ = reader.ReadString(128, codepage); // header string
|
||||
|
||||
uint combatActorDataOffset = reader.ReadUInt32();
|
||||
int numOfActors = reader.ReadInt32();
|
||||
|
||||
uint skillDataOffset = reader.ReadUInt32();
|
||||
int numOfSkills = reader.ReadInt32();
|
||||
|
||||
uint itemDataOffset = reader.ReadUInt32();
|
||||
int numOfItems = reader.ReadInt32();
|
||||
|
||||
uint comboSkillDataOffset = reader.ReadUInt32();
|
||||
int numOfComboSkills = reader.ReadInt32();
|
||||
|
||||
reader.Seek(combatActorDataOffset, SeekOrigin.Begin);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
var comboSkillInfos = new Dictionary<int, ComboSkillInfo>();
|
||||
for (var i = 0; i < numOfComboSkills; i++)
|
||||
{
|
||||
ComboSkillInfo comboSkill = ReadComboSkillInfo(reader, codepage);
|
||||
comboSkillInfos[(int) comboSkill.Id] = comboSkill;
|
||||
}
|
||||
|
||||
return new GdbFile(combatActorInfos,
|
||||
skillInfos,
|
||||
gameItems,
|
||||
comboSkillInfos);
|
||||
}
|
||||
|
||||
private static CombatActorInfo ReadCombatActorInfo(IBinaryReader reader, int codepage)
|
||||
{
|
||||
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 wuLing = reader.ReadInt32s(5);
|
||||
var name = reader.ReadString(32, codepage);
|
||||
var level = reader.ReadInt32();
|
||||
var attributeValue = reader.ReadInt32s(12);
|
||||
var combatStateImpactType = reader.ReadBytes(31);
|
||||
_ = reader.ReadByte(); // padding
|
||||
var roundNumber = 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
|
||||
var normalAttackActionId = 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
|
||||
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
|
||||
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()
|
||||
{
|
||||
Id = id,
|
||||
Type = type,
|
||||
Description = description,
|
||||
ModelId = modelId,
|
||||
IconId = iconId,
|
||||
WuLing = wuLing,
|
||||
Name = name,
|
||||
Level = level,
|
||||
AttributeValue = attributeValue,
|
||||
CombatStateImpactType = combatStateImpactType,
|
||||
RoundNumber = roundNumber,
|
||||
SpecialActionId = specialActionId,
|
||||
EscapeRate = escapeRate,
|
||||
MainActorFavor = mainActorFavor,
|
||||
Experience = experience,
|
||||
Money = money,
|
||||
NormalAttackActionId = normalAttackActionId,
|
||||
HeightLevel = heightLevel,
|
||||
MoveRangeLevel = moveRangeLevel,
|
||||
AttackRangeLevel = attackRangeLevel,
|
||||
MoveSpeedLevel = moveSpeedLevel,
|
||||
ChaseSpeedLevel = chaseSpeed,
|
||||
SkillIds = skillIds,
|
||||
SkillLevels = skillLevels,
|
||||
SpImpactValue = spImpactValue,
|
||||
Properties = properties,
|
||||
NormalLoot = normalLoot,
|
||||
NormalLootCount = normalLootCount,
|
||||
CorpseId = corpseId,
|
||||
CorpseSkillId = corpseSkillId,
|
||||
CorpseSuccessRate = corpseSuccessRate,
|
||||
StealableMoneyAmount = stealableMoneyAmount,
|
||||
StealableItemId = stealableItemId,
|
||||
StealableItemCount = stealableItemCount,
|
||||
MoneyWhenKilled = moneyWhenKilled,
|
||||
};
|
||||
}
|
||||
|
||||
private SkillInfo ReadSkillInfo(IBinaryReader reader, int codepage)
|
||||
{
|
||||
var id = reader.ReadUInt32();
|
||||
var type = (SkillType)reader.ReadByte();
|
||||
_ = reader.ReadBytes(3); // padding
|
||||
var wuLing = reader.ReadInt32s(5);
|
||||
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
|
||||
var attributeImpactValue = reader.ReadInt16s(12);
|
||||
var successRateLevel = reader.ReadByte();
|
||||
_ = reader.ReadByte(); // padding
|
||||
var combatStateImpactType = reader.ReadInt16s(31);
|
||||
var consumeAttributeType = reader.ReadInt32s(2);
|
||||
var consumeAttributeKind = reader.ReadInt32s(3);
|
||||
var specialConsumeType = reader.ReadByte();
|
||||
_ = reader.ReadBytes(3); // padding
|
||||
var specialConsumeValue = reader.ReadInt32();
|
||||
var level = reader.ReadByte();
|
||||
var timesBeforeLevelUp = reader.ReadBytes(4);
|
||||
var requiredActorLevel = reader.ReadByte();
|
||||
var magicLevel = reader.ReadByte();
|
||||
_ = reader.ReadByte(); // padding
|
||||
var nextLevelSkillId = reader.ReadUInt32();
|
||||
var isUsableOutsideCombat = reader.ReadByte();
|
||||
_ = reader.ReadBytes(3); // padding
|
||||
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()
|
||||
{
|
||||
Id = id,
|
||||
Type = type,
|
||||
WuLing = wuLing,
|
||||
Name = name,
|
||||
Description = description,
|
||||
MainActorCanUse = mainActorCanUse,
|
||||
TargetRangeType = targetRangeType,
|
||||
SpecialSkillId = specialSkillId,
|
||||
AttributeImpactType = attributeImpactType,
|
||||
AttributeImpactValue = attributeImpactValue,
|
||||
SuccessRateLevel = successRateLevel,
|
||||
CombatStateImpactType = combatStateImpactType,
|
||||
ConsumeAttributeType = consumeAttributeType,
|
||||
ConsumeAttributeKind = consumeAttributeKind,
|
||||
SpecialConsumeType = specialConsumeType,
|
||||
SpecialConsumeValue = specialConsumeValue,
|
||||
Level = level,
|
||||
TimesBeforeLevelUp = timesBeforeLevelUp,
|
||||
RequiredActorLevel = requiredActorLevel,
|
||||
MagicLevel = magicLevel,
|
||||
NextLevelSkillId = nextLevelSkillId,
|
||||
IsUsableOutsideCombat = isUsableOutsideCombat,
|
||||
CompositeSkillIds = compositeSkillIds,
|
||||
CompositeRequiredSkillIds = compositeRequiredSkillIds,
|
||||
CompositeRequiredSkillLevels = compositeRequiredSkillLevels,
|
||||
CompositeRequiredCurrentSkillLevels = compositeRequiredCurrentSkillLevels,
|
||||
CompositeRequiredActorLevels = compositeRequiredActorLevels,
|
||||
CanTriggerComboSkill = canTriggerComboSkill,
|
||||
};
|
||||
}
|
||||
|
||||
private static GameItemInfo ReadGameItemInfo(IBinaryReader reader, int codepage)
|
||||
{
|
||||
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 wuLing = reader.ReadBytes(5);
|
||||
var ancientValue = reader.ReadInt32();
|
||||
var specialType = (SpecialType) reader.ReadByte();
|
||||
var targetRangeType = (TargetRangeType) reader.ReadByte();
|
||||
var placeOfUseType = (PlaceOfUseType) reader.ReadByte();
|
||||
var attributeImpactType = reader.ReadBytes(12);
|
||||
_ = reader.ReadByte(); // padding
|
||||
var attributeImpactValue = reader.ReadInt16s(12);
|
||||
var combatStateImpactType = reader.ReadBytes(31);
|
||||
_ = reader.ReadByte(); // padding
|
||||
var combatStateImpactValue = reader.ReadInt16s(31);
|
||||
_ = reader.ReadBytes(2); // padding
|
||||
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();
|
||||
|
||||
return new GameItemInfo()
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
ModelName = modelName,
|
||||
IconName = iconName,
|
||||
Description = description,
|
||||
Price = price,
|
||||
Type = type,
|
||||
WeaponType = weaponType,
|
||||
MainActorCanUse = mainActorCanUse,
|
||||
WuLing = wuLing,
|
||||
AncientValue = ancientValue,
|
||||
SpecialType = specialType,
|
||||
TargetRangeType = targetRangeType,
|
||||
PlaceOfUseType = placeOfUseType,
|
||||
AttributeImpactType = attributeImpactType,
|
||||
AttributeImpactValue = attributeImpactValue,
|
||||
CombatStateImpactType = combatStateImpactType,
|
||||
CombatStateImpactValue = combatStateImpactValue,
|
||||
ComboCount = comboCount,
|
||||
SpSavingPercentage = spSavingPercentage,
|
||||
MpSavingPercentage = mpSavingPercentage,
|
||||
CriticalAttackAmplifyPercentage = criticalAttackAmplifyPercentage,
|
||||
SpecialSkillSuccessRate = specialSkillSuccessRate,
|
||||
OreId = oreId,
|
||||
ProductId = productId,
|
||||
ProductPrice = productPrice,
|
||||
SynthesisMaterialIds = synthesisMaterialIds,
|
||||
SynthesisProductId = synthesisProductId,
|
||||
};
|
||||
}
|
||||
|
||||
private ComboSkillInfo ReadComboSkillInfo(IBinaryReader reader, int codepage)
|
||||
{
|
||||
var name = reader.ReadString(32, codepage);
|
||||
var id = reader.ReadUInt32();
|
||||
var mainActorRequirements = reader.ReadUInt32s(4);
|
||||
var wuLingPositionRequirements = reader.ReadBytes(4);
|
||||
var skillId = reader.ReadUInt32();
|
||||
var weaponTypeRequirements = reader.ReadBytes(4);
|
||||
_ = reader.ReadBytes(4); // not used
|
||||
var combatStateRequirements = reader.ReadInt32s(3);
|
||||
var description = reader.ReadString(512, codepage);
|
||||
var targetRangeType = (TargetRangeType)reader.ReadByte();
|
||||
var attributeImpactType = reader.ReadBytes(12);
|
||||
_ = reader.ReadBytes(3); // padding
|
||||
var attributeImpactValue = reader.ReadInt16s(12);
|
||||
#if PAL3A
|
||||
var unknown = reader.ReadInt32();
|
||||
#endif
|
||||
|
||||
return new ComboSkillInfo()
|
||||
{
|
||||
Name = name,
|
||||
Id = id,
|
||||
MainActorRequirements = mainActorRequirements,
|
||||
WuLingPositionRequirements = wuLingPositionRequirements,
|
||||
SkillId = skillId,
|
||||
WeaponTypeRequirements = weaponTypeRequirements,
|
||||
CombatStateRequirements = combatStateRequirements,
|
||||
Description = description,
|
||||
TargetRangeType = targetRangeType,
|
||||
AttributeImpactType = attributeImpactType,
|
||||
AttributeImpactValue = attributeImpactValue,
|
||||
#if PAL3A
|
||||
Unknown = unknown,
|
||||
#endif
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Binary reader interface for reading data from binary file
|
||||
/// with extension methods for reading various data types.
|
||||
/// </summary>
|
||||
public interface IBinaryReader : IDisposable
|
||||
{
|
||||
long Position { get; }
|
||||
long Length { get; }
|
||||
void Seek(long offset, SeekOrigin seekOrigin);
|
||||
short ReadInt16();
|
||||
int ReadInt32();
|
||||
long ReadInt64();
|
||||
ushort ReadUInt16();
|
||||
uint ReadUInt32();
|
||||
ulong ReadUInt64();
|
||||
float ReadSingle();
|
||||
double ReadDouble();
|
||||
bool ReadBoolean();
|
||||
byte ReadByte();
|
||||
byte[] ReadBytes(int count);
|
||||
|
||||
#region Helper Extensions (Default Implementation)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
float[] ReadSingles(int count)
|
||||
{
|
||||
var array = new float[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
array[i] = ReadSingle();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
double[] ReadDoubles(int count)
|
||||
{
|
||||
var array = new double[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
array[i] = ReadDouble();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
short[] ReadInt16s(int count)
|
||||
{
|
||||
var array = new short[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
array[i] = ReadInt16();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
ushort[] ReadUInt16s(int count)
|
||||
{
|
||||
var array = new ushort[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
array[i] = ReadUInt16();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
int[] ReadInt32s(int count)
|
||||
{
|
||||
var array = new int[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
array[i] = ReadInt32();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
uint[] ReadUInt32s(int count)
|
||||
{
|
||||
var array = new uint[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
array[i] = ReadUInt32();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
long[] ReadInt64s(int count)
|
||||
{
|
||||
var array = new long[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
array[i] = ReadInt64();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
ulong[] ReadUInt64s(int count)
|
||||
{
|
||||
var array = new ulong[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
array[i] = ReadUInt64();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public char[] ReadChars(int count)
|
||||
{
|
||||
return Encoding.ASCII.GetChars(ReadBytes(count));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
string ReadString(int count) => new (ReadChars(count));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
string ReadString(int count, int codepage)
|
||||
{
|
||||
var strBytes = ReadBytes(count);
|
||||
int length = Array.IndexOf(strBytes, (byte)0);
|
||||
if (length == -1) length = strBytes.Length; // If no null byte is found, use the full length
|
||||
return Encoding.GetEncoding(codepage).GetString(strBytes, 0, length);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
Vector2 ReadVector2() => new (ReadSingle(), ReadSingle());
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
Vector3 ReadVector3() => new (ReadSingle(), ReadSingle(), ReadSingle());
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
Vector3[] ReadVector3s(int count)
|
||||
{
|
||||
var array = new Vector3[count];
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
array[i] = ReadVector3();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Nav
|
||||
{
|
||||
using GameBox;
|
||||
using UnityEngine;
|
||||
|
||||
// NAV (.nav) file header
|
||||
internal struct NavHeader
|
||||
{
|
||||
public string Label; // 4 char
|
||||
public byte Version;
|
||||
public byte NumberOfLayers;
|
||||
public uint TileOffset;
|
||||
public uint FaceOffset;
|
||||
}
|
||||
|
||||
public enum NavFloorKind
|
||||
{
|
||||
Default = 0, // 不可跳
|
||||
Jumpable, // 可跳过
|
||||
Soil, // 土
|
||||
Mud, // 泥
|
||||
River, // 水道(船状态)
|
||||
Snow, // 雪
|
||||
Wet, // 水浸
|
||||
Grass, // 草
|
||||
Wood, // 竹木
|
||||
Plant, // 植物
|
||||
Wetland, // 沼泽
|
||||
Sand, // 沙
|
||||
Metal, // 金属
|
||||
Rock1, // 熔岩
|
||||
Rock2, // 岩石基底地面
|
||||
Rock3, // 人工石地面
|
||||
Brick, // 砖
|
||||
DevilWorld1, // 异空间A
|
||||
DevilWorld2, // 异空间B
|
||||
DevilWorld3, // 异空间C
|
||||
Other, // 其它
|
||||
Ice, // 冰
|
||||
Blood, // 血池
|
||||
Water, // 水域
|
||||
}
|
||||
|
||||
public struct NavTile
|
||||
{
|
||||
public float GameBoxYPosition; // 格子地板高度(原GameBox引擎下的Y坐标单位)
|
||||
public byte DistanceToNearestObstacle; // 格子距离周边障碍物的距离 (0最小-7最大)
|
||||
public NavFloorKind FloorKind; // 格子地板类型:0~128索引普通地面属性(土草雪等),128~255索引机关序号
|
||||
|
||||
public bool IsObstacle; // 是否为障碍物
|
||||
|
||||
public bool IsWalkable()
|
||||
{
|
||||
return !IsObstacle && DistanceToNearestObstacle > 0 && FloorKind != NavFloorKind.Jumpable;
|
||||
}
|
||||
}
|
||||
|
||||
// public struct NavLayerNode
|
||||
// {
|
||||
// public GameBoxAABBox BoundBox;
|
||||
// public Vector3[] Triangles;
|
||||
// public int Level; // 0: root, child level = parent level + 1
|
||||
// public NavLayerNode[] Children; // 4
|
||||
// }
|
||||
|
||||
public struct NavTileLayer
|
||||
{
|
||||
public GameBoxRect[] Portals; // Max of 8
|
||||
public Vector3 Max;
|
||||
public Vector3 Min;
|
||||
public int Width;
|
||||
public int Height;
|
||||
public NavTile[] Tiles;
|
||||
}
|
||||
|
||||
public struct NavFaceLayer
|
||||
{
|
||||
public Vector3[] Vertices;
|
||||
public int[] Triangles;
|
||||
//public NavLayerNode[] Nodes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// NAV (.nav) file model
|
||||
/// </summary>
|
||||
public sealed class NavFile
|
||||
{
|
||||
public NavTileLayer[] TileLayers { get; }
|
||||
public NavFaceLayer[] FaceLayers { get; }
|
||||
|
||||
public NavFile(NavTileLayer[] tileLayers, NavFaceLayer[] faceLayers)
|
||||
{
|
||||
TileLayers = tileLayers;
|
||||
FaceLayers = faceLayers;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader.Nav
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using GameBox;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
public sealed class NavFileReader : IFileReader<NavFile>
|
||||
{
|
||||
public NavFile Read(IBinaryReader reader, int codepage)
|
||||
{
|
||||
var header = reader.ReadChars(4);
|
||||
var headerStr = new string(header[..^1]);
|
||||
|
||||
if (headerStr != "NAV")
|
||||
{
|
||||
throw new InvalidDataException("Invalid NAV(.nav) file: header != NAV");
|
||||
}
|
||||
|
||||
var version = reader.ReadByte();
|
||||
var numberOfLayers = reader.ReadByte();
|
||||
var tileOffset = reader.ReadUInt32();
|
||||
var faceOffset = reader.ReadUInt32();
|
||||
|
||||
reader.Seek(tileOffset, SeekOrigin.Begin);
|
||||
var tileLayers = new NavTileLayer[numberOfLayers];
|
||||
for (var i = 0; i < numberOfLayers; i++)
|
||||
{
|
||||
tileLayers[i] = ReadTileLayer(reader, version);
|
||||
}
|
||||
|
||||
reader.Seek(faceOffset, SeekOrigin.Begin);
|
||||
var faceLayers = new NavFaceLayer[numberOfLayers];
|
||||
for (var i = 0; i < numberOfLayers; i++)
|
||||
{
|
||||
faceLayers[i] = ReadFaceLayer(reader);
|
||||
}
|
||||
|
||||
return new NavFile(tileLayers, faceLayers);
|
||||
}
|
||||
|
||||
private static NavTileLayer ReadTileLayer(IBinaryReader reader, byte version)
|
||||
{
|
||||
var portals = Array.Empty<GameBoxRect>();
|
||||
|
||||
if (version == 2)
|
||||
{
|
||||
portals = new GameBoxRect[8];
|
||||
for (var i = 0; i < 8; i++)
|
||||
{
|
||||
portals[i] = new GameBoxRect()
|
||||
{
|
||||
Left = reader.ReadInt32(),
|
||||
Top = reader.ReadInt32(),
|
||||
Right = reader.ReadInt32(),
|
||||
Bottom = reader.ReadInt32(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 max = reader.ReadVector3();
|
||||
Vector3 min = reader.ReadVector3();
|
||||
|
||||
var width = reader.ReadInt32();
|
||||
var height = reader.ReadInt32();
|
||||
|
||||
var navMapSize = width * height;
|
||||
if (navMapSize <= 0)
|
||||
{
|
||||
throw new Exception($"Invalid NAV(.nav) file: Map size is in valid: {navMapSize}");
|
||||
}
|
||||
|
||||
var tiles = new NavTile[navMapSize];
|
||||
for (var i = 0; i < navMapSize; i++)
|
||||
{
|
||||
tiles[i] = new NavTile
|
||||
{
|
||||
GameBoxYPosition = reader.ReadSingle(),
|
||||
DistanceToNearestObstacle = reader.ReadByte(), //---| 1
|
||||
FloorKind = (NavFloorKind) reader.ReadByte() //----| 2
|
||||
};
|
||||
_ = reader.ReadBytes(2); //-----------------------------| ^ to complete 4-byte alignment
|
||||
}
|
||||
|
||||
return new NavTileLayer()
|
||||
{
|
||||
Portals = portals,
|
||||
Max = max,
|
||||
Min = min,
|
||||
Width = width,
|
||||
Height = height,
|
||||
Tiles = tiles
|
||||
};
|
||||
}
|
||||
|
||||
private static NavFaceLayer ReadFaceLayer(IBinaryReader reader)
|
||||
{
|
||||
var numberOfVertices = reader.ReadUInt16();
|
||||
var numberOfFaces = reader.ReadUInt16();
|
||||
var vertices = new Vector3[numberOfVertices];
|
||||
for (var i = 0; i < numberOfVertices; i++)
|
||||
{
|
||||
vertices[i] = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3());
|
||||
}
|
||||
|
||||
var triangles = new int[numberOfFaces * 3];
|
||||
for (var i = 0; i < numberOfFaces; i++)
|
||||
{
|
||||
var index = i * 3;
|
||||
triangles[index] = reader.ReadUInt16();
|
||||
triangles[index + 1] = reader.ReadUInt16();
|
||||
triangles[index + 2] = reader.ReadUInt16();
|
||||
}
|
||||
|
||||
// Some of the nav meshes in the original game are upside down (don't know why),
|
||||
// so we need to flip them if that's the case. You might argue that we can just
|
||||
// make the mesh double sided, but that would cause some other issues (trust me).
|
||||
{
|
||||
Vector3[] normals = Utility.CalculateNormals(vertices, triangles);
|
||||
|
||||
for (var i = 0; i < numberOfFaces; i++)
|
||||
{
|
||||
var index = i * 3;
|
||||
|
||||
// Determine if the face is pointing downwards.
|
||||
if (normals[triangles[index]].y +
|
||||
normals[triangles[index + 1]].y +
|
||||
normals[triangles[index + 2]].y < 0)
|
||||
{
|
||||
// Change the winding order of the face to make it point upwards.
|
||||
(triangles[index], triangles[index + 1]) = (triangles[index + 1], triangles[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new NavFaceLayer()
|
||||
{
|
||||
Vertices = vertices,
|
||||
Triangles = triangles,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.DataReader
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a binary reader that reads primitive data types from a byte array or stream using unsafe code.
|
||||
/// </summary>
|
||||
public sealed unsafe class UnsafeBinaryReader : IBinaryReader
|
||||
{
|
||||
private GCHandle _handle;
|
||||
private byte* _startPtr;
|
||||
private byte* _dataPtr;
|
||||
|
||||
public UnsafeBinaryReader(byte[] data)
|
||||
{
|
||||
Init(data);
|
||||
}
|
||||
|
||||
public UnsafeBinaryReader(Stream stream)
|
||||
{
|
||||
if (!stream.CanSeek)
|
||||
{
|
||||
throw new ArgumentException("Stream must be seekable", nameof(stream));
|
||||
}
|
||||
|
||||
var length = stream.Length;
|
||||
var data = new byte[length];
|
||||
_ = stream.Read(data, 0, (int)length);
|
||||
|
||||
Init(data);
|
||||
}
|
||||
|
||||
private void Init(byte[] data)
|
||||
{
|
||||
Length = data.Length;
|
||||
_handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
fixed (byte* ptr = &data[0])
|
||||
{
|
||||
_startPtr = ptr;
|
||||
_dataPtr = ptr;
|
||||
}
|
||||
}
|
||||
|
||||
public long Position => _dataPtr - _startPtr;
|
||||
public long Length { get; private set; }
|
||||
|
||||
public void Seek(long offset, SeekOrigin seekOrigin)
|
||||
{
|
||||
switch (seekOrigin)
|
||||
{
|
||||
case SeekOrigin.Begin:
|
||||
_dataPtr = _startPtr + offset;
|
||||
break;
|
||||
case SeekOrigin.Current:
|
||||
_dataPtr += offset;
|
||||
break;
|
||||
case SeekOrigin.End:
|
||||
throw new NotSupportedException("SeekOrigin.End is not supported for UnsafeBinaryReader");
|
||||
default:
|
||||
throw new ArgumentException("Invalid SeekOrigin", nameof(seekOrigin));
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public short ReadInt16()
|
||||
{
|
||||
short value = *(short*)_dataPtr;
|
||||
_dataPtr += 2;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int ReadInt32()
|
||||
{
|
||||
int value = *(int*)_dataPtr;
|
||||
_dataPtr += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public long ReadInt64()
|
||||
{
|
||||
long value = *(long*)_dataPtr;
|
||||
_dataPtr += 8;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ushort ReadUInt16()
|
||||
{
|
||||
ushort value = *(ushort*)_dataPtr;
|
||||
_dataPtr += 2;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint ReadUInt32()
|
||||
{
|
||||
uint value = *(uint*)_dataPtr;
|
||||
_dataPtr += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ulong ReadUInt64()
|
||||
{
|
||||
ulong value = *(ulong*)_dataPtr;
|
||||
_dataPtr += 8;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public float ReadSingle()
|
||||
{
|
||||
float value = *(float*)_dataPtr;
|
||||
_dataPtr += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public double ReadDouble()
|
||||
{
|
||||
double value = *(double*)_dataPtr;
|
||||
_dataPtr += 8;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool ReadBoolean()
|
||||
{
|
||||
bool value = *(bool*)_dataPtr;
|
||||
_dataPtr += 1;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public byte ReadByte()
|
||||
{
|
||||
byte value = *_dataPtr;
|
||||
_dataPtr += 1;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public byte[] ReadBytes(int count)
|
||||
{
|
||||
var value = new byte[count];
|
||||
Marshal.Copy(new IntPtr(_dataPtr), value, 0, count);
|
||||
_dataPtr += count;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public float[] ReadSingles(int count)
|
||||
{
|
||||
var value = new float[count];
|
||||
Marshal.Copy(new IntPtr(_dataPtr), value, 0, count);
|
||||
_dataPtr += count * 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public double[] ReadDoubles(int count)
|
||||
{
|
||||
var value = new double[count];
|
||||
Marshal.Copy(new IntPtr(_dataPtr), value, 0, count);
|
||||
_dataPtr += count * 8;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public short[] ReadInt16s(int count)
|
||||
{
|
||||
var value = new short[count];
|
||||
Marshal.Copy(new IntPtr(_dataPtr), value, 0, count);
|
||||
_dataPtr += count * 2;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int[] ReadInt32s(int count)
|
||||
{
|
||||
var value = new int[count];
|
||||
Marshal.Copy(new IntPtr(_dataPtr), value, 0, count);
|
||||
_dataPtr += count * 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public long[] ReadInt64s(int count)
|
||||
{
|
||||
var value = new long[count];
|
||||
Marshal.Copy(new IntPtr(_dataPtr), value, 0, count);
|
||||
_dataPtr += count * 8;
|
||||
return value;
|
||||
}
|
||||
|
||||
private bool _disposedValue;
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
_handle.Free();
|
||||
_disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
~UnsafeBinaryReader()
|
||||
{
|
||||
Dispose(disposing: false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(disposing: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.Extensions
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
public static class GameObjectExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper method to get or add a component to the GameObject.
|
||||
/// </summary>
|
||||
/// <param name="gameObject">this</param>
|
||||
/// <typeparam name="T">Type of the component</typeparam>
|
||||
/// <returns>Component</returns>
|
||||
public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
|
||||
{
|
||||
var component = gameObject.GetComponent<T>();
|
||||
|
||||
// Since ?? operation does not work well with UnityObject
|
||||
// so I have to use the old fashion here checking if it is null.
|
||||
if (component == null)
|
||||
{
|
||||
component = gameObject.AddComponent<T>();
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0ec5ec379844647a98ae11e28d88f21
|
||||
timeCreated: 1642759044
|
||||
@@ -1,285 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.FileSystem
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DataReader.Cpk;
|
||||
using UnityEngine;
|
||||
using Utils;
|
||||
|
||||
/// <summary>
|
||||
/// File system wrapper for CPack archives
|
||||
/// </summary>
|
||||
public class CpkFileSystem : ICpkFileSystem
|
||||
{
|
||||
private readonly string _rootPath;
|
||||
private readonly ConcurrentDictionary<string, CpkArchive> _cpkArchives = new();
|
||||
private readonly Crc32Hash _crcHash;
|
||||
|
||||
private CpkFileSystem() {} // Hide default constructor
|
||||
|
||||
public CpkFileSystem(string rootPath, Crc32Hash crcHash)
|
||||
{
|
||||
rootPath = Requires.IsNotNullOrEmpty(rootPath, nameof(rootPath));
|
||||
crcHash = Requires.IsNotNull(crcHash, nameof(crcHash));
|
||||
|
||||
if (!rootPath.EndsWith(Path.DirectorySeparatorChar))
|
||||
{
|
||||
rootPath += Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(rootPath))
|
||||
{
|
||||
var error = $"游戏数据加载失败,原始游戏数据根目录不存在: {rootPath}";
|
||||
Debug.LogError(error);
|
||||
throw new ArgumentException(error);
|
||||
}
|
||||
|
||||
_rootPath = rootPath;
|
||||
_crcHash = crcHash;
|
||||
}
|
||||
|
||||
public string GetRootPath()
|
||||
{
|
||||
return _rootPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mount a Cpk archive to the file system.
|
||||
/// </summary>
|
||||
/// <param name="cpkFileRelativePath">CPK file relative path</param>
|
||||
/// <param name="codepage">Codepage CPK file uses for encoding text info</param>
|
||||
public void Mount(string cpkFileRelativePath, int codepage)
|
||||
{
|
||||
var cpkFileName = Utility.GetFileName(cpkFileRelativePath, Path.DirectorySeparatorChar).ToLower();
|
||||
|
||||
if (_cpkArchives.ContainsKey(cpkFileName))
|
||||
{
|
||||
Debug.LogWarning($"[{nameof(CpkFileSystem)}] {cpkFileRelativePath} already mounted.");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log($"[{nameof(CpkFileSystem)}] Mounting: {_rootPath + cpkFileRelativePath}");
|
||||
var cpkArchive = new CpkArchive(_rootPath + cpkFileRelativePath, _crcHash, codepage);
|
||||
cpkArchive.Init();
|
||||
_cpkArchives[cpkFileName] = cpkArchive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if file exists in any of the segmented archives using virtual path.
|
||||
/// </summary>
|
||||
/// <param name="fileVirtualPath">File virtual path {Cpk file name}\{File relative path inside archive}</param>
|
||||
/// <param name="segmentedArchiveName">Name of the segmented archive if exists</param>
|
||||
/// <returns>True if file exists in segmented archive</returns>
|
||||
public bool FileExistsInSegmentedArchive(string fileVirtualPath, out string segmentedArchiveName)
|
||||
{
|
||||
ParseFileVirtualPath(fileVirtualPath, out var cpkFileName, out var relativeVirtualPath);
|
||||
|
||||
if (_cpkArchives.ContainsKey(cpkFileName))
|
||||
{
|
||||
segmentedArchiveName = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the file exists in any of the segmented cpk archives.
|
||||
foreach (var subCpkPath in _cpkArchives.Keys
|
||||
.Where(_ => _.StartsWith(cpkFileName[..^CpkConstants.FileExtension.Length] + '_', StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var relativePathInSubCpk = relativeVirtualPath.Replace(cpkFileName, subCpkPath);
|
||||
if (_cpkArchives[subCpkPath].FileExists(relativePathInSubCpk))
|
||||
{
|
||||
segmentedArchiveName = subCpkPath;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
segmentedArchiveName = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if file exists in the archive using virtual path.
|
||||
/// </summary>
|
||||
/// <param name="fileVirtualPath">File virtual path {Cpk file name}\{File relative path inside archive}
|
||||
/// Example: music.cpk\music\PI01.mp3</param>
|
||||
/// <returns>True if file exists</returns>
|
||||
public bool FileExists(string fileVirtualPath)
|
||||
{
|
||||
ParseFileVirtualPath(fileVirtualPath, out var cpkFileName, out var relativeVirtualPath);
|
||||
|
||||
if (_cpkArchives.TryGetValue(cpkFileName, out CpkArchive archive))
|
||||
{
|
||||
return archive.FileExists(relativeVirtualPath);
|
||||
}
|
||||
|
||||
// Check if the file exists in any of the segmented cpk archives.
|
||||
foreach (var subCpkPath in _cpkArchives.Keys
|
||||
.Where(_ => _.StartsWith(cpkFileName[..^CpkConstants.FileExtension.Length] + '_', StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var relativePathInSubCpk = relativeVirtualPath.Replace(cpkFileName, subCpkPath);
|
||||
if (_cpkArchives[subCpkPath].FileExists(relativePathInSubCpk))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read all bytes of the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileVirtualPath">File virtual path inside CPK archive</param>
|
||||
/// <returns>Decompressed, ready-to-go file content in byte array</returns>
|
||||
public byte[] ReadAllBytes(string fileVirtualPath)
|
||||
{
|
||||
ParseFileVirtualPath(fileVirtualPath, out var cpkFileName, out var relativeVirtualPath);
|
||||
|
||||
if (_cpkArchives.TryGetValue(cpkFileName, out CpkArchive archive))
|
||||
{
|
||||
return archive.ReadAllBytes(relativeVirtualPath);
|
||||
}
|
||||
|
||||
// Find and read the file content in segmented cpk archives.
|
||||
foreach (var subCpkPath in _cpkArchives.Keys
|
||||
.Where(_ => _.StartsWith(cpkFileName[..^CpkConstants.FileExtension.Length] + '_', StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var relativePathInSubCpk = relativeVirtualPath.Replace(cpkFileName, subCpkPath);
|
||||
if (_cpkArchives[subCpkPath].FileExists(relativePathInSubCpk))
|
||||
{
|
||||
return _cpkArchives[subCpkPath].ReadAllBytes(relativePathInSubCpk);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception($"{fileVirtualPath} not found.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Preload archive into memory for faster read performance.
|
||||
/// </summary>
|
||||
public void LoadArchiveIntoMemory(string cpkFileName)
|
||||
{
|
||||
if (_cpkArchives.ContainsKey(cpkFileName.ToLower()))
|
||||
{
|
||||
Debug.Log($"[{nameof(CpkFileSystem)}] Caching {cpkFileName} archive into memory.");
|
||||
_cpkArchives[cpkFileName.ToLower()].LoadArchiveIntoMemory();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{cpkFileName} archive not mounted yet.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose in-memory archive data.
|
||||
/// </summary>
|
||||
public void DisposeInMemoryArchive(string cpkFileName)
|
||||
{
|
||||
if (_cpkArchives.ContainsKey(cpkFileName.ToLower()))
|
||||
{
|
||||
Debug.Log($"[{nameof(CpkFileSystem)}] Disposing in-memory cache: {cpkFileName}");
|
||||
_cpkArchives[cpkFileName.ToLower()].DisposeInMemoryArchive();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{cpkFileName} archive not mounted yet.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose all in-memory archive data.
|
||||
/// </summary>
|
||||
public void DisposeAllInMemoryArchives()
|
||||
{
|
||||
foreach (CpkArchive cpkArchive in _cpkArchives.Values)
|
||||
{
|
||||
cpkArchive.DisposeInMemoryArchive();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract all archives to the specified destination
|
||||
/// </summary>
|
||||
public void ExtractTo(string outputFolder)
|
||||
{
|
||||
foreach ((string cpkFileName, CpkArchive cpkArchive) in _cpkArchives)
|
||||
{
|
||||
var outputDir = outputFolder + cpkFileName + Path.DirectorySeparatorChar;
|
||||
|
||||
if (!Directory.Exists(outputDir))
|
||||
{
|
||||
Directory.CreateDirectory(outputDir);
|
||||
}
|
||||
|
||||
cpkArchive.ExtractTo(outputDir);
|
||||
Debug.Log($"[{nameof(CpkFileSystem)}] {cpkFileName} extracted to {outputDir}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search files using keyword.
|
||||
/// </summary>
|
||||
/// <param name="keyword"></param>
|
||||
/// <returns>File path enumerable</returns>
|
||||
public IEnumerable<string> Search(string keyword = "")
|
||||
{
|
||||
var results = new ConcurrentBag<IEnumerable<string>>();
|
||||
|
||||
Parallel.ForEach(_cpkArchives, archive =>
|
||||
{
|
||||
var rootNodes = archive.Value.GetRootEntries();
|
||||
results.Add(from result in SearchInternal(rootNodes, keyword)
|
||||
select archive.Key + CpkConstants.DirectorySeparatorChar + result);
|
||||
});
|
||||
|
||||
var resultList = new List<string>();
|
||||
foreach (var result in results)
|
||||
{
|
||||
resultList.AddRange(result);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse file virtual path into cpk file name and relative virtual path.
|
||||
/// </summary>
|
||||
/// <param name="fullVirtualPath">File virtual path {Cpk file name}\{File relative path inside archive}</param>
|
||||
/// <param name="cpkFileName">{Cpk file name}</param>
|
||||
/// <param name="relativeVirtualPath">{File relative path inside archive}</param>
|
||||
private void ParseFileVirtualPath(string fullVirtualPath, out string cpkFileName, out string relativeVirtualPath)
|
||||
{
|
||||
if (!fullVirtualPath.Contains(CpkConstants.DirectorySeparatorChar))
|
||||
{
|
||||
throw new ArgumentException($"[{nameof(CpkFileSystem)}] File virtual path is invalid: {fullVirtualPath}.");
|
||||
}
|
||||
|
||||
cpkFileName = fullVirtualPath[..fullVirtualPath.IndexOf(CpkConstants.DirectorySeparatorChar)].ToLower();
|
||||
relativeVirtualPath = fullVirtualPath[(fullVirtualPath.IndexOf(CpkConstants.DirectorySeparatorChar) + 1)..];
|
||||
}
|
||||
|
||||
private IEnumerable<string> SearchInternal(IEnumerable<CpkEntry> nodes, string keyword)
|
||||
{
|
||||
foreach (CpkEntry node in nodes)
|
||||
{
|
||||
if (node.IsDirectory)
|
||||
{
|
||||
foreach (var result in SearchInternal(node.Children, keyword))
|
||||
{
|
||||
yield return result;
|
||||
}
|
||||
}
|
||||
else if (node.VirtualPath.ToLower().Contains(keyword.ToLower()))
|
||||
{
|
||||
yield return node.VirtualPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.GameBox
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Interpreter/convertor to convert GameBox specific rendering related metrics to Unity standard units that fits
|
||||
/// well with the engine and editor.
|
||||
/// </summary>
|
||||
public static class GameBoxInterpreter
|
||||
{
|
||||
public const float GameBoxUnitToUnityUnit = 20f;
|
||||
public const float GameBoxMv3UnitToUnityUnit = 1270f;
|
||||
public const uint GameBoxTicksPerSecond = 4800;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 ToUnityVertex(Vector3 vertex, float scale)
|
||||
{
|
||||
return ToUnityVector3(vertex, scale);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 ToUnityPosition(Vector3 position, float scale = GameBoxUnitToUnityUnit)
|
||||
{
|
||||
return ToUnityVector3(position, scale);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float ToUnityDistance(float gameBoxDistance)
|
||||
{
|
||||
return gameBoxDistance / GameBoxUnitToUnityUnit;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float ToUnityXPosition(float gameBoxXPosition)
|
||||
{
|
||||
return -gameBoxXPosition / GameBoxUnitToUnityUnit;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float ToUnityYPosition(float gameBoxYPosition)
|
||||
{
|
||||
return gameBoxYPosition / GameBoxUnitToUnityUnit;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float ToUnityZPosition(float gameBoxZPosition)
|
||||
{
|
||||
return gameBoxZPosition / GameBoxUnitToUnityUnit;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float ToGameBoxXRotation(float eulerAnglesX)
|
||||
{
|
||||
return eulerAnglesX;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float ToGameBoxYRotation(float eulerAnglesY)
|
||||
{
|
||||
return -eulerAnglesY;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float ToGameBoxZRotation(float eulerAnglesZ)
|
||||
{
|
||||
return eulerAnglesZ;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Quaternion ToUnityRotation(Vector3 gameBoxEulerAngles)
|
||||
{
|
||||
return Quaternion.Euler(
|
||||
gameBoxEulerAngles.x,
|
||||
-gameBoxEulerAngles.y,
|
||||
gameBoxEulerAngles.z);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 ToGameBoxPosition(Vector3 position, float scale = GameBoxUnitToUnityUnit)
|
||||
{
|
||||
return new Vector3(
|
||||
-position.x * scale,
|
||||
position.y * scale,
|
||||
position.z * scale);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 CvdPositionToUnityPosition(Vector3 cvdPosition, float scale = GameBoxUnitToUnityUnit)
|
||||
{
|
||||
return new Vector3(
|
||||
-cvdPosition.x / scale,
|
||||
cvdPosition.z / scale,
|
||||
-cvdPosition.y / scale);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 CvdScaleToUnityScale(Vector3 scale)
|
||||
{
|
||||
return new Vector3(
|
||||
scale.x,
|
||||
scale.z,
|
||||
scale.y);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Vector3 ToUnityNormal(Vector3 normal)
|
||||
{
|
||||
return new Vector3(
|
||||
-normal.x,
|
||||
normal.y,
|
||||
normal.z);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Quaternion CvdQuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
|
||||
{
|
||||
return new Quaternion(-quaternion.X, quaternion.Z, -quaternion.Y, quaternion.W);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Quaternion Mv3QuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
|
||||
{
|
||||
return new Quaternion(-quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Quaternion MovQuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
|
||||
{
|
||||
return new Quaternion(-quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Quaternion MshQuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
|
||||
{
|
||||
return new Quaternion(-quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Quaternion LgtQuaternionToUnityQuaternion(GameBoxQuaternion quaternion)
|
||||
{
|
||||
var rotation = new Quaternion(quaternion.X, quaternion.Y, -quaternion.Z, quaternion.W);
|
||||
rotation.eulerAngles = new Vector3(rotation.eulerAngles.x + 90f,
|
||||
-rotation.eulerAngles.y,
|
||||
rotation.eulerAngles.z);
|
||||
return rotation;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Quaternion ToUnityRotation(float pitch, float yaw, float roll)
|
||||
{
|
||||
return Quaternion.Euler(pitch - 180, yaw, roll -180);
|
||||
}
|
||||
|
||||
// Since GameBox engine uses different internal axis system.
|
||||
// Here we are flipping the x here to minor it back to the Unity axis.
|
||||
// Also we want to scale it to proper unity unit.
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static Vector3 ToUnityVector3(Vector3 vector3, float scale)
|
||||
{
|
||||
return new Vector3(
|
||||
-vector3.x / scale,
|
||||
vector3.y / scale,
|
||||
vector3.z / scale);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ToUnityTriangles(List<int> triangles)
|
||||
{
|
||||
triangles.Reverse();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ToUnityTriangles(int[] triangles)
|
||||
{
|
||||
Array.Reverse(triangles);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsPointInsideRect(GameBoxRect rect, Vector2Int point)
|
||||
{
|
||||
return point.x >= rect.Left &&
|
||||
point.x <= rect.Right &&
|
||||
point.y >= rect.Top &&
|
||||
point.y <= rect.Bottom;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static Matrix4x4 ToUnityMatrix4x4(GameBoxMatrix4X4 matrix)
|
||||
{
|
||||
return new Matrix4x4(
|
||||
new Vector4(matrix.Xx, matrix.Xy, matrix.Xz, matrix.Xw),
|
||||
new Vector4(matrix.Yx, matrix.Yy, matrix.Yz, matrix.Yw),
|
||||
new Vector4(matrix.Zx, matrix.Zy, matrix.Zz, matrix.Zw),
|
||||
new Vector4(matrix.Tx, matrix.Ty, matrix.Tz, matrix.Tw));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static uint SecondsToTick(float seconds)
|
||||
{
|
||||
return (uint)(seconds * GameBoxTicksPerSecond);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static float TickToSeconds(uint tick)
|
||||
{
|
||||
return (float)tick / GameBoxTicksPerSecond;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.GameBox
|
||||
{
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public struct GameBoxMaterial
|
||||
{
|
||||
public Color Diffuse;
|
||||
public Color Ambient;
|
||||
public Color Specular;
|
||||
public Color Emissive;
|
||||
public float SpecularPower;
|
||||
public string[] TextureFileNames;
|
||||
}
|
||||
|
||||
// To meet opengl, use this order instead:
|
||||
// float xx , yx , zx , tx;
|
||||
// float xy , yy , zy , ty;
|
||||
// float xz , yz , zz , tz;
|
||||
// float xw , yw , zw , tw;
|
||||
public struct GameBoxMatrix4X4
|
||||
{
|
||||
public float Xx, Xy, Xz, Xw;
|
||||
public float Yx, Yy, Yz, Yw;
|
||||
public float Zx, Zy, Zz, Zw;
|
||||
public float Tx, Ty, Tz, Tw;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct GameBoxQuaternion
|
||||
{
|
||||
public float X;
|
||||
public float Y;
|
||||
public float Z;
|
||||
public float W;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct GameBoxRect
|
||||
{
|
||||
public int Left;
|
||||
public int Top;
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
|
||||
public bool IsEmpty => Left == 0 &&
|
||||
Top == 0 &&
|
||||
Right == 0 &&
|
||||
Bottom == 0;
|
||||
}
|
||||
|
||||
public static class GameBoxVertexType
|
||||
{
|
||||
public const int Null = 0;
|
||||
public const int MaxUvSet = 4;
|
||||
public const int XYZ = (1 << 0);
|
||||
public const int Normal = (1 << 1);
|
||||
public const int Diffuse = (1 << 2);
|
||||
public const int Specular = (1 << 3);
|
||||
public const int UV0 = (1 << 4);
|
||||
public const int UV1 = (1 << 5);
|
||||
public const int UV2 = (1 << 6);
|
||||
public const int UV3 = (1 << 7);
|
||||
public const int XYZRHW = (1 << 8);
|
||||
public const int FlagMask = (1 << 31);
|
||||
}
|
||||
|
||||
public enum GameBoxBlendFlag
|
||||
{
|
||||
Opaque, // opaque
|
||||
AlphaBlend, // src.alpha, 1-src.alpha, +
|
||||
InvertColorBlend, // srcAlpha, One , +
|
||||
AdditiveBlend, //
|
||||
}
|
||||
|
||||
public enum GameBoxLightType
|
||||
{
|
||||
Omni, // point light
|
||||
Spot, // spot light
|
||||
Directional, // directional light
|
||||
}
|
||||
|
||||
public enum GameBoxLightDecayType
|
||||
{
|
||||
None,
|
||||
Distance,
|
||||
Square,
|
||||
}
|
||||
|
||||
public enum GameBoxLightShapeType
|
||||
{
|
||||
Cone,
|
||||
Square,
|
||||
}
|
||||
|
||||
public static class GameBoxVertex
|
||||
{
|
||||
public static int GetSize(uint vertexType)
|
||||
{
|
||||
var size = 0;
|
||||
|
||||
if ((vertexType & GameBoxVertexType.FlagMask) != 0) return (int) (vertexType&~GameBoxVertexType.FlagMask);
|
||||
if ((vertexType & GameBoxVertexType.XYZ) != 0) size += 3 * sizeof(float);
|
||||
if ((vertexType & GameBoxVertexType.XYZRHW) != 0) size += 4 * sizeof(float);
|
||||
if ((vertexType & GameBoxVertexType.Normal) != 0) size += 3 * sizeof(float);
|
||||
if ((vertexType & GameBoxVertexType.Diffuse) != 0) size += 4;
|
||||
if ((vertexType & GameBoxVertexType.Specular) != 0) size += 4;
|
||||
if ((vertexType & GameBoxVertexType.UV0) != 0) size += 2 * sizeof(float);
|
||||
if ((vertexType & GameBoxVertexType.UV1) != 0) size += 2 * sizeof(float);
|
||||
if ((vertexType & GameBoxVertexType.UV2) != 0) size += 2 * sizeof(float);
|
||||
if ((vertexType & GameBoxVertexType.UV3) != 0) size += 2 * sizeof(float);
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8691ab40dd7c44e9b4c0acdbe90b738b
|
||||
timeCreated: 1641755187
|
||||
@@ -1,57 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.Renderer
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class SkyBoxRenderer : MonoBehaviour
|
||||
{
|
||||
private Skybox _skybox;
|
||||
|
||||
private static readonly int RightTexturePropertyID = Shader.PropertyToID("_RightTex");
|
||||
private static readonly int BackTexturePropertyID = Shader.PropertyToID("_BackTex");
|
||||
private static readonly int LeftTexturePropertyID = Shader.PropertyToID("_LeftTex");
|
||||
private static readonly int FrontTexturePropertyID = Shader.PropertyToID("_FrontTex");
|
||||
private static readonly int UpTexturePropertyID = Shader.PropertyToID("_UpTex");
|
||||
private static readonly int DownTexturePropertyID = Shader.PropertyToID("_DownTex");
|
||||
|
||||
public void Render(Camera targetCamera,
|
||||
Texture2D rightTex,
|
||||
Texture2D backTex,
|
||||
Texture2D leftTex,
|
||||
Texture2D frontTex,
|
||||
Texture2D upTex,
|
||||
Texture2D downTex)
|
||||
{
|
||||
Material material = CreateSkyboxMaterial(rightTex, backTex, leftTex, frontTex, upTex, downTex);
|
||||
_skybox = targetCamera.gameObject.AddComponent<Skybox>();
|
||||
_skybox.material = material;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_skybox != null) Destroy(_skybox);
|
||||
}
|
||||
|
||||
private static Material CreateSkyboxMaterial(Texture2D rightTex,
|
||||
Texture2D backTex,
|
||||
Texture2D leftTex,
|
||||
Texture2D frontTex,
|
||||
Texture2D upTex,
|
||||
Texture2D downTex)
|
||||
{
|
||||
var material = new Material(Shader.Find("Skybox/6 Sided"));
|
||||
material.SetTexture(RightTexturePropertyID, rightTex);
|
||||
material.SetTexture(BackTexturePropertyID, backTex);
|
||||
material.SetTexture(LeftTexturePropertyID, leftTex);
|
||||
material.SetTexture(FrontTexturePropertyID, frontTex);
|
||||
material.SetTexture(UpTexturePropertyID, upTex);
|
||||
material.SetTexture(DownTexturePropertyID, downTex);
|
||||
return material;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.Renderer
|
||||
{
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public sealed class StaticMeshRenderer : MonoBehaviour, IDisposable
|
||||
{
|
||||
private MeshRenderer _meshRenderer;
|
||||
private MeshFilter _meshFilter;
|
||||
|
||||
public Mesh Render(ref Vector3[] vertices,
|
||||
ref int[] triangles,
|
||||
ref Vector3[] normals,
|
||||
ref Vector2[] mainTextureUvs,
|
||||
ref Vector2[] secondaryTextureUvs,
|
||||
ref Material[] materials,
|
||||
bool isDynamic)
|
||||
{
|
||||
Dispose();
|
||||
|
||||
_meshRenderer = gameObject.AddComponent<MeshRenderer>();
|
||||
_meshRenderer.sharedMaterials = materials;
|
||||
|
||||
_meshFilter = gameObject.AddComponent<MeshFilter>();
|
||||
var mesh = new Mesh();
|
||||
if (isDynamic)
|
||||
{
|
||||
mesh.MarkDynamic();
|
||||
}
|
||||
|
||||
mesh.SetVertices(vertices);
|
||||
mesh.SetTriangles(triangles, 0);
|
||||
mesh.SetNormals(normals);
|
||||
mesh.SetUVs(0, mainTextureUvs);
|
||||
mesh.SetUVs(1, secondaryTextureUvs);
|
||||
|
||||
if (triangles.Length == 0)
|
||||
{
|
||||
// https://docs.unity3d.com/ScriptReference/Mesh.RecalculateBounds.html
|
||||
// After modifying vertices you should call this function to ensure the
|
||||
// bounding volume is correct. Assigning triangles automatically
|
||||
// recalculates the bounding volume.
|
||||
mesh.RecalculateBounds();
|
||||
}
|
||||
|
||||
_meshFilter.sharedMesh = mesh;
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
public Mesh GetMesh()
|
||||
{
|
||||
return _meshFilter == null ? null : _meshFilter.sharedMesh;
|
||||
}
|
||||
|
||||
public bool IsVisible()
|
||||
{
|
||||
return _meshRenderer != null && _meshRenderer.isVisible;
|
||||
}
|
||||
|
||||
public Bounds GetRendererBounds()
|
||||
{
|
||||
return _meshRenderer.bounds;
|
||||
}
|
||||
|
||||
public Bounds GetMeshBounds()
|
||||
{
|
||||
return _meshFilter.sharedMesh.bounds;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_meshFilter != null)
|
||||
{
|
||||
Destroy(_meshFilter.sharedMesh);
|
||||
Destroy(_meshFilter);
|
||||
}
|
||||
|
||||
if (_meshRenderer != null)
|
||||
{
|
||||
foreach (Material material in _meshRenderer.sharedMaterials)
|
||||
{
|
||||
Destroy(material);
|
||||
}
|
||||
|
||||
Destroy(_meshRenderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,271 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Core.Utils
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using DataReader.Cpk;
|
||||
using UnityEngine;
|
||||
|
||||
public static class Utility
|
||||
{
|
||||
public static Color32 ToColor32(byte[] rgba)
|
||||
{
|
||||
return new Color32(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
}
|
||||
|
||||
public static Color ToColor(float[] rgba)
|
||||
{
|
||||
return new Color(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
}
|
||||
|
||||
// public static unsafe void ApplyTransparencyBasedOnColorLuminance(Texture2D texture)
|
||||
// {
|
||||
// var pixels = texture.GetPixels();
|
||||
//
|
||||
// fixed (float* src = &pixels[0].r)
|
||||
// {
|
||||
// var p = src;
|
||||
// for (var i = 0; i < texture.width * texture.height; i++, p += 4)
|
||||
// {
|
||||
// *(p + 3) = 0.299f * *p + 0.587f * *(p + 1) + 0.114f * *(p + 2);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// texture.SetPixels(pixels);
|
||||
// texture.Apply(updateMipmaps: false);
|
||||
// }
|
||||
|
||||
public static T ReadStruct<T>(Stream stream) where T : struct
|
||||
{
|
||||
var structSize = Marshal.SizeOf(typeof(T));
|
||||
byte[] buffer = new byte[structSize];
|
||||
_ = stream.Read(buffer);
|
||||
return ReadStructInternal<T>(buffer);
|
||||
}
|
||||
|
||||
public static T ReadStruct<T>(ReadOnlySpan<byte> bytes, int offset = 0) where T : struct
|
||||
{
|
||||
return ReadStructInternal<T>(bytes, offset);
|
||||
}
|
||||
|
||||
private static unsafe T ReadStructInternal<T>(ReadOnlySpan<byte> bytes, int offset = 0) where T : struct
|
||||
{
|
||||
fixed (byte* ptr = &bytes[offset])
|
||||
{
|
||||
return (T) (Marshal.PtrToStructure((IntPtr) ptr, typeof(T)) ?? default(T));
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetPatternIndex(ReadOnlySpan<byte> src, ReadOnlySpan<byte> pattern, int startIndex = 0)
|
||||
{
|
||||
var maxFirstCharSlot = src.Length - pattern.Length + 1;
|
||||
for (var i = startIndex; i < maxFirstCharSlot; i++)
|
||||
{
|
||||
if (src[i] != pattern[0])
|
||||
continue;
|
||||
|
||||
for (var j = pattern.Length - 1; j >= 1; j--)
|
||||
{
|
||||
if (src[i + j] != pattern[j]) break;
|
||||
if (j == 1) return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int GetFloorIndex<T>(T[] valuesInIncreasingOrder, T lookUpValue)
|
||||
{
|
||||
/*
|
||||
* The index of the specified value in the specified array, if value is found;
|
||||
* otherwise, a negative number. If value is not found and value is less than
|
||||
* one or more elements in array, the negative number returned is the bitwise
|
||||
* complement of the index of the first element that is larger than value.
|
||||
* If value is not found and value is greater than all elements in array,
|
||||
* the negative number returned is the bitwise complement of
|
||||
* (the index of the last element plus 1).
|
||||
*/
|
||||
var index = Array.BinarySearch(valuesInIncreasingOrder, lookUpValue);
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
return -index - 2;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
public static byte[] TrimEnd(byte[] buffer, ReadOnlySpan<byte> pattern)
|
||||
{
|
||||
var length = GetPatternIndex(buffer, pattern);
|
||||
return length == -1 ? buffer : buffer[..length];
|
||||
}
|
||||
|
||||
public static void Rgb565ToRgb888(ushort rgb565Color, out byte r, out byte g, out byte b)
|
||||
{
|
||||
var temp = (rgb565Color >> 11) * 255 + 16;
|
||||
r = (byte) ((temp / 32 + temp) / 32);
|
||||
temp = ((rgb565Color & 0x07E0) >> 5) * 255 + 32;
|
||||
g = (byte) ((temp / 64 + temp) / 64);
|
||||
temp = (rgb565Color & 0x001F) * 255 + 16;
|
||||
b = (byte) ((temp / 32 + temp) / 32);
|
||||
}
|
||||
|
||||
public static string GetDirectoryName(string filePath, char directorySeparatorChar)
|
||||
{
|
||||
return !filePath.Contains(directorySeparatorChar) ?
|
||||
string.Empty :
|
||||
filePath[..filePath.LastIndexOf(directorySeparatorChar)];
|
||||
}
|
||||
|
||||
public static string GetFileName(string filePath, char directorySeparatorChar)
|
||||
{
|
||||
return !filePath.Contains(directorySeparatorChar) ?
|
||||
string.Empty :
|
||||
filePath[(filePath.LastIndexOf(directorySeparatorChar)+1)..];
|
||||
}
|
||||
|
||||
public static bool IsHandheldDevice()
|
||||
{
|
||||
return SystemInfo.deviceType == DeviceType.Handheld;
|
||||
}
|
||||
|
||||
public static bool IsDesktopDevice()
|
||||
{
|
||||
return SystemInfo.deviceType == DeviceType.Desktop;
|
||||
}
|
||||
|
||||
public static bool IsPointWithinCollider(Collider collider, Vector3 point)
|
||||
{
|
||||
if (collider == null) return false;
|
||||
return collider.ClosestPoint(point) == point;
|
||||
}
|
||||
|
||||
public static bool IsPointWithinCollider(Collider collider, Vector3 point, float tolerance)
|
||||
{
|
||||
if (collider == null) return false;
|
||||
return Vector3.Distance(collider.ClosestPoint(point), point) < tolerance;
|
||||
}
|
||||
|
||||
public static Vector3[] CalculateNormals(Vector3[] vertices, int[] triangles)
|
||||
{
|
||||
Vector3[] normals = new Vector3[vertices.Length];
|
||||
|
||||
for (var face = 0; face < triangles.Length / 3; face++)
|
||||
{
|
||||
int v1 = triangles[face * 3];
|
||||
int v2 = triangles[face * 3 + 1];
|
||||
int v3 = triangles[face * 3 + 2];
|
||||
|
||||
Vector3 pt1 = vertices[v1];
|
||||
Vector3 pt2 = vertices[v2];
|
||||
Vector3 pt3 = vertices[v3];
|
||||
|
||||
Vector3 d1 = pt2 - pt1;
|
||||
Vector3 d2 = pt3 - pt1;
|
||||
Vector3 normal = Vector3.Normalize(Vector3.Cross(d1, d2));
|
||||
|
||||
normals[v1] += normal;
|
||||
normals[v2] += normal;
|
||||
normals[v3] += normal;
|
||||
}
|
||||
|
||||
for (var i = 0; i < normals.Length; i++)
|
||||
{
|
||||
if (normals[i] == Vector3.zero)
|
||||
{
|
||||
normals[i] = Vector3.up;
|
||||
}
|
||||
else
|
||||
{
|
||||
normals[i] = Vector3.Normalize(normals[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return normals;
|
||||
}
|
||||
|
||||
public static void DrawBounds(Bounds b, float duration = 1000)
|
||||
{
|
||||
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);
|
||||
|
||||
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);
|
||||
Debug.DrawLine(p7, p8, Color.yellow, duration);
|
||||
Debug.DrawLine(p8, p5, Color.magenta, duration);
|
||||
|
||||
Debug.DrawLine(p1, p5, Color.white, duration);
|
||||
Debug.DrawLine(p2, p6, Color.gray, duration);
|
||||
Debug.DrawLine(p3, p7, Color.green, duration);
|
||||
Debug.DrawLine(p4, p8, Color.cyan, duration);
|
||||
}
|
||||
|
||||
public static bool IsLegacyMobileDevice()
|
||||
{
|
||||
if (IsAndroidDeviceAndSdkVersionLowerThanOrEqualTo(23)) return true;
|
||||
// TODO: Add iOS legacy mobile device check etc
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsAndroidDeviceAndSdkVersionLowerThanOrEqualTo(int sdkVersion)
|
||||
{
|
||||
if (Application.platform != RuntimePlatform.Android) return false;
|
||||
|
||||
try
|
||||
{
|
||||
int GetAndroidSdkLevel()
|
||||
{
|
||||
IntPtr versionClass = AndroidJNI.FindClass("android.os.Build$VERSION");
|
||||
IntPtr sdkFieldID = AndroidJNI.GetStaticFieldID(versionClass, "SDK_INT", "I");
|
||||
var sdkLevel = AndroidJNI.GetStaticIntField(versionClass, sdkFieldID);
|
||||
return sdkLevel;
|
||||
}
|
||||
|
||||
if (GetAndroidSdkLevel() <= sdkVersion)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsVersionGreater(string latestVersion, string currentVersion)
|
||||
{
|
||||
string[] latestParts = latestVersion.Split('.');
|
||||
string[] currentParts = currentVersion.Split('.');
|
||||
|
||||
for (var i = 0; i < Math.Min(latestParts.Length, currentParts.Length); i++)
|
||||
{
|
||||
int latest = int.Parse(latestParts[i]);
|
||||
int current = int.Parse(currentParts[i]);
|
||||
if (latest == current) continue;
|
||||
return latest > current;
|
||||
}
|
||||
|
||||
return latestParts.Length > currentParts.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Editor
|
||||
{
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Pal3.MetaData;
|
||||
using Pal3.Game.Constants;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEngine;
|
||||
@@ -34,9 +34,9 @@ namespace Editor
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Switch Variant/PAL3", true)]
|
||||
#endif
|
||||
static bool ValidateSwitchToPal3()
|
||||
public static bool ValidateSwitchToPal3()
|
||||
{
|
||||
return !SymbolsHelper.HasSymbol("PAL3");
|
||||
return !SymbolsHelper.IsSymbolDefined("PAL3");
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
@@ -59,9 +59,9 @@ namespace Editor
|
||||
#elif PAL3A
|
||||
[MenuItem("PAL3A/Switch Variant/PAL3A", true)]
|
||||
#endif
|
||||
static bool ValidateSwitchToPal3A()
|
||||
public static bool ValidateSwitchToPal3A()
|
||||
{
|
||||
return !SymbolsHelper.HasSymbol("PAL3A");
|
||||
return !SymbolsHelper.IsSymbolDefined("PAL3A");
|
||||
}
|
||||
|
||||
private static void ApplyPlayerSettingsForVariant(string appName)
|
||||
@@ -69,33 +69,55 @@ namespace Editor
|
||||
PlayerSettings.productName = appName;
|
||||
PlayerSettings.companyName = GameConstants.CompanyName;
|
||||
|
||||
foreach (BuildTargetGroup targetGroup in SymbolsHelper.GetAllSupportedTargetGroups())
|
||||
{
|
||||
PlayerSettings.SetApplicationIdentifier(targetGroup,
|
||||
$"{GameConstants.AppIdentifierPrefix}.{appName}");
|
||||
}
|
||||
|
||||
var gameIconPath = $"UI/game-icon-{appName}";
|
||||
var gameIcon = Resources.Load<Texture2D>(gameIconPath);
|
||||
string gameIconPath = $"UI/game-icon-{appName}";
|
||||
Texture2D gameIcon = Resources.Load<Texture2D>(gameIconPath);
|
||||
if (gameIcon == null) throw new Exception($"Game icon not found: {gameIconPath}");
|
||||
|
||||
foreach (NamedBuildTarget buildTarget in SymbolsHelper.GetAllSupportedNamedBuildTargets())
|
||||
// Set app icons for all supported build targets
|
||||
foreach (NamedBuildTarget target in SymbolsHelper.GetAllSupportedBuildTargets())
|
||||
{
|
||||
PlayerSettings.SetApplicationIdentifier(target,
|
||||
$"{GameConstants.AppIdentifierPrefix}.{appName}");
|
||||
|
||||
// Set app icon
|
||||
var iconSizes = PlayerSettings.GetIconSizes(buildTarget, IconKind.Application);
|
||||
PlayerSettings.SetIcons(buildTarget,
|
||||
Enumerable.Repeat(gameIcon, iconSizes.Length).ToArray(),
|
||||
PlayerSettings.SetIcons(target,
|
||||
Enumerable.Repeat(gameIcon,
|
||||
PlayerSettings.GetIconSizes(target, IconKind.Application).Length).ToArray(),
|
||||
IconKind.Application);
|
||||
|
||||
// Set iOS store icon which is required for store publishing or TestFlight
|
||||
if (buildTarget == NamedBuildTarget.iOS)
|
||||
// Set settings icon
|
||||
PlayerSettings.SetIcons(target,
|
||||
Enumerable.Repeat(gameIcon,
|
||||
PlayerSettings.GetIconSizes(target, IconKind.Settings).Length).ToArray(),
|
||||
IconKind.Settings);
|
||||
|
||||
// Set notification icon
|
||||
PlayerSettings.SetIcons(target,
|
||||
Enumerable.Repeat(gameIcon,
|
||||
PlayerSettings.GetIconSizes(target, IconKind.Notification).Length).ToArray(),
|
||||
IconKind.Notification);
|
||||
|
||||
// Set iOS store and spotlight icon which are required for store publishing or TestFlight
|
||||
if (target == NamedBuildTarget.iOS)
|
||||
{
|
||||
PlayerSettings.SetIcons(buildTarget,
|
||||
PlayerSettings.SetIcons(target,
|
||||
Enumerable.Repeat(gameIcon,
|
||||
PlayerSettings.GetIconSizes(buildTarget, IconKind.Store).Length).ToArray(),
|
||||
PlayerSettings.GetIconSizes(target, IconKind.Store).Length).ToArray(),
|
||||
IconKind.Store);
|
||||
PlayerSettings.SetIcons(target,
|
||||
Enumerable.Repeat(gameIcon,
|
||||
PlayerSettings.GetIconSizes(target, IconKind.Spotlight).Length).ToArray(),
|
||||
IconKind.Spotlight);
|
||||
}
|
||||
}
|
||||
|
||||
// Set default app icon (I don't know why Unity decided to use NamedBuildTarget.Unknown here but it is what it is)
|
||||
{
|
||||
PlayerSettings.SetIcons(NamedBuildTarget.Unknown,
|
||||
Enumerable.Repeat(gameIcon,
|
||||
PlayerSettings.GetIconSizes(NamedBuildTarget.Unknown, IconKind.Application).Length).ToArray(),
|
||||
IconKind.Application);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -9,25 +9,22 @@ namespace Editor
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using Pal3.MetaData;
|
||||
using Pal3.Game.Constants;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_2020_2_OR_NEWER && UNITY_STANDALONE_OSX
|
||||
using UnityEditor.OSXStandalone;
|
||||
#endif
|
||||
|
||||
[Flags]
|
||||
public enum Pal3BuildTarget
|
||||
{
|
||||
Windows_x86 = 1 << 0,
|
||||
Windows_x64 = 1 << 1,
|
||||
Linux_x86_x64 = 1 << 2,
|
||||
macOS_arm64_x64 = 1 << 3,
|
||||
Android = 1 << 4,
|
||||
iOS = 1 << 5,
|
||||
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,
|
||||
}
|
||||
|
||||
public static class ReleaseBuildPipeline
|
||||
@@ -35,7 +32,17 @@ 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
|
||||
@@ -103,7 +110,8 @@ namespace Editor
|
||||
#endif
|
||||
public static void BuildAll()
|
||||
{
|
||||
BuildGame(Pal3BuildTarget.Windows_x86 |
|
||||
BuildGame(Pal3BuildTarget.Windows_arm64 |
|
||||
Pal3BuildTarget.Windows_x86 |
|
||||
Pal3BuildTarget.Windows_x64 |
|
||||
Pal3BuildTarget.Linux_x86_x64 |
|
||||
Pal3BuildTarget.macOS_arm64_x64 |
|
||||
@@ -133,69 +141,98 @@ namespace Editor
|
||||
|
||||
var buildConfigurations = new[]
|
||||
{
|
||||
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 },
|
||||
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 },
|
||||
};
|
||||
|
||||
List<Action> logActions = new List<Action>();
|
||||
List<Action> logActions = new();
|
||||
|
||||
foreach (var config in buildConfigurations)
|
||||
{
|
||||
if (buildTarget.HasFlag(config.Platform))
|
||||
if (buildTarget.HasFlag(config.Target))
|
||||
{
|
||||
Build(config.Platform.ToString(),
|
||||
Build(config.Target,
|
||||
config.Extension,
|
||||
config.Group,
|
||||
config.Target,
|
||||
config.NamedTarget,
|
||||
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(string folderName,
|
||||
private static void Build(Pal3BuildTarget target,
|
||||
string extension,
|
||||
BuildTargetGroup buildTargetGroup,
|
||||
BuildTarget buildTarget,
|
||||
NamedBuildTarget namedBuildTarget,
|
||||
string buildOutputPath,
|
||||
List<Action> logActions,
|
||||
bool deletePdbFiles = true)
|
||||
{
|
||||
string outputFolder = buildOutputPath + $"{GameConstants.AppName}{DirSeparator}" +
|
||||
$"{folderName}{DirSeparator}";
|
||||
$"{target.ToString()}{DirSeparator}";
|
||||
|
||||
if (buildTarget is BuildTarget.StandaloneWindows
|
||||
or BuildTarget.StandaloneWindows64
|
||||
or BuildTarget.StandaloneLinux64)
|
||||
BuildTarget buildTarget = BuildTarget.NoTarget;
|
||||
|
||||
switch (target)
|
||||
{
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
string outputPath = outputFolder + $"{GameConstants.AppName}{extension}";
|
||||
|
||||
PlayerSettings.SetScriptingBackend(buildTargetGroup, ScriptingImplementation.IL2CPP);
|
||||
PlayerSettings.SetScriptingBackend(namedBuildTarget, ScriptingImplementation.IL2CPP);
|
||||
|
||||
BuildReport report = BuildPipeline.BuildPlayer(BuildLevels, outputPath, buildTarget, BuildOptions.None);
|
||||
BuildReport report = BuildPipeline.BuildPlayer(BuildLevels, outputPath, buildTarget, BuildOptions.CleanBuildCache);
|
||||
|
||||
if (deletePdbFiles)
|
||||
{
|
||||
@@ -250,6 +287,7 @@ 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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -52,9 +52,9 @@ namespace Editor.SourceGenerator.Base
|
||||
|
||||
private void WriteIndentInternal()
|
||||
{
|
||||
for (var i = 0; i < _indentLevel; i++)
|
||||
for (int i = 0; i < _indentLevel; i++)
|
||||
{
|
||||
for (var j = 0; j < SpacesPerIndentLevel; j++)
|
||||
for (int j = 0; j < SpacesPerIndentLevel; j++)
|
||||
{
|
||||
Buffer.Append(' ');
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace Editor.SourceGenerator.Base
|
||||
|
||||
public void WriteIndent()
|
||||
{
|
||||
for (var i = 0; i < SpacesPerIndentLevel; i++) Buffer.Append(' ');
|
||||
for (int i = 0; i < SpacesPerIndentLevel; i++) Buffer.Append(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -9,31 +9,32 @@ namespace Editor.SourceGenerator.Base
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
public static class Utility
|
||||
{
|
||||
public static string GetMethodArgumentDefinitionListAsString(PropertyInfo[] properties)
|
||||
{
|
||||
var argListStr = String.Empty;
|
||||
for (var i = 0; i < properties.Length; i++)
|
||||
StringBuilder argListStrBuilder = new ();
|
||||
for (int i = 0; i < properties.Length; i++)
|
||||
{
|
||||
argListStr += properties[i].PropertyType.ToString();
|
||||
argListStr += " ";
|
||||
argListStr += ToLowerFirstChar(properties[i].Name);
|
||||
if (i < properties.Length - 1) argListStr += ", ";
|
||||
argListStrBuilder.Append(properties[i].PropertyType);
|
||||
argListStrBuilder.Append(" ");
|
||||
argListStrBuilder.Append(ToLowerFirstChar(properties[i].Name));
|
||||
if (i < properties.Length - 1) argListStrBuilder.Append(", ");
|
||||
}
|
||||
return argListStr;
|
||||
return argListStrBuilder.ToString();
|
||||
}
|
||||
|
||||
public static string GetMethodArgumentListAsString(PropertyInfo[] properties)
|
||||
{
|
||||
var argListStr = String.Empty;
|
||||
for (var i = 0; i < properties.Length; i++)
|
||||
StringBuilder argListStrBuilder = new ();
|
||||
for (int i = 0; i < properties.Length; i++)
|
||||
{
|
||||
argListStr += ToLowerFirstChar(properties[i].Name);
|
||||
if (i < properties.Length - 1) argListStr += ", ";
|
||||
argListStrBuilder.Append(ToLowerFirstChar(properties[i].Name));
|
||||
if (i < properties.Length - 1) argListStrBuilder.Append(", ");
|
||||
}
|
||||
return argListStr;
|
||||
return argListStrBuilder.ToString();
|
||||
}
|
||||
|
||||
private static string ToLowerFirstChar(string input)
|
||||
@@ -42,15 +43,11 @@ namespace Editor.SourceGenerator.Base
|
||||
return char.ToLower(input[0]) + input[1..];
|
||||
}
|
||||
|
||||
public static Type[] GetTypesOfInterface(Type interfaceType)
|
||||
public static IEnumerable<Type> GetTypesOfInterface(Type interfaceType)
|
||||
{
|
||||
var result = new List<Type>();
|
||||
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
result.AddRange(asm.GetTypes()
|
||||
.Where(t => t.IsClass && t.GetInterfaces().Contains(interfaceType)));
|
||||
}
|
||||
return result.ToArray();
|
||||
return AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(assembly => assembly.GetTypes())
|
||||
.Where(t => t.IsClass && t.GetInterfaces().Contains(interfaceType));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
|
||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -10,7 +10,9 @@ namespace Editor.SourceGenerator
|
||||
using System.Reflection;
|
||||
using Base;
|
||||
using IngameDebugConsole;
|
||||
using Pal3.Command;
|
||||
using Pal3.Core.Command;
|
||||
using Pal3.Core.Command.SceCommands;
|
||||
using Pal3.Game.Command;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
@@ -34,9 +36,10 @@ namespace Editor.SourceGenerator
|
||||
writer.BeginBlock();
|
||||
|
||||
// Begin using.
|
||||
writer.WriteLine("using Core.Command;");
|
||||
writer.WriteLine("using Core.Command.SceCommands;");
|
||||
writer.WriteLine("using Extensions;");
|
||||
writer.WriteLine("using IngameDebugConsole;");
|
||||
writer.WriteLine("using InternalCommands;");
|
||||
writer.WriteLine("using SceCommands;");
|
||||
writer.WriteLine();
|
||||
|
||||
// Begin class.
|
||||
@@ -44,27 +47,25 @@ namespace Editor.SourceGenerator
|
||||
writer.WriteLine($"public static class {className}");
|
||||
writer.BeginBlock();
|
||||
|
||||
Type commandInterfaceType = typeof(TCommand);
|
||||
var commands = Utility.GetTypesOfInterface(commandInterfaceType)
|
||||
Type[] commands = Utility.GetTypesOfInterface(typeof(TCommand))
|
||||
.Where(IsCommandAvailableInConsole).ToArray();
|
||||
|
||||
Debug.Log($"[{nameof(ConsoleCommandsAutoGen<TCommand>)}] Found {commands.Length} available console commands");
|
||||
|
||||
for (var i = 0; i < commands.Length; i++)
|
||||
for (int i = 0; i < commands.Length; i++)
|
||||
{
|
||||
var commandName = commands[i].Name.Replace("Command", string.Empty);
|
||||
var properties = commands[i].GetProperties();
|
||||
string commandName = commands[i].Name.Replace("Command", string.Empty);
|
||||
PropertyInfo[] properties = commands[i].GetProperties();
|
||||
|
||||
writer.WriteLine($"// <auto-generated/>");
|
||||
var attributeName = nameof(ConsoleMethodAttribute);
|
||||
string attributeName = nameof(ConsoleMethodAttribute);
|
||||
writer.WriteLine($"[{attributeName}(\"{commandName}\", \"{GetCommandDescription(commands[i])}\")]");
|
||||
writer.WriteLine($"public static void {commandName}" +
|
||||
$"({Utility.GetMethodArgumentDefinitionListAsString(properties)})");
|
||||
|
||||
writer.BeginBlock();
|
||||
writer.WriteLine($"CommandDispatcher<{typeof(TCommand).Name}>.Instance.Dispatch(");
|
||||
writer.WriteIndent(); writer.WriteLine($"new {commands[i].Name}" +
|
||||
$"({Utility.GetMethodArgumentListAsString(properties)}));");
|
||||
writer.WriteLine($"Pal3.Instance.Execute(new {commands[i].Name}" +
|
||||
$"({Utility.GetMethodArgumentListAsString(properties)}));");
|
||||
writer.EndBlock();
|
||||
|
||||
if (i < commands.Length - 1)
|
||||
@@ -92,7 +93,12 @@ namespace Editor.SourceGenerator
|
||||
|
||||
private static bool IsCommandAvailableInConsole(Type command)
|
||||
{
|
||||
return command.GetCustomAttributes().Any(attribute => attribute is AvailableInConsoleAttribute);
|
||||
// object[] is not supported by InGameDebugConsole.
|
||||
if (command == typeof(DialogueAddSelectionsCommand)) return false;
|
||||
|
||||
// Make all SceCommands available in console + all commands with AvailableInConsoleAttribute.
|
||||
return command.GetCustomAttributes()
|
||||
.Any(attribute => attribute is AvailableInConsoleAttribute or SceCommandAttribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 1428 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user