Compare commits

..
Author SHA1 Message Date
Jiaqi (0x7c13) Liu f03c6a38f3 Restore the project README on the repository homepage 2026-11-12 02:46:47 +08:00
794 changed files with 3628 additions and 14556 deletions

No files matched your search

-52
View File
@@ -1,52 +0,0 @@
root = true
[*.cs]
indent_style = space
indent_size = 4
# Match the existing Unity C# sources; keep each file's existing BOM.
end_of_line = crlf
insert_final_newline = true
trim_trailing_whitespace = true
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = false
csharp_indent_switch_labels = true
csharp_indent_labels = one_less_than_current
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_parentheses = none
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_before_comma = false
csharp_space_after_comma = true
csharp_space_before_dot = false
csharp_space_after_dot = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_after_semicolon_in_for_statement = true
csharp_space_before_open_square_brackets = false
csharp_space_between_square_brackets = false
csharp_space_between_empty_square_brackets = false
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = false
# SDK whitespace formatting does not enforce spacing between members.
# These targeted StyleCop rules also run through tools/format-csharp.py.
dotnet_diagnostic.SA1107.severity = warning
dotnet_diagnostic.SA1502.severity = warning
dotnet_diagnostic.SA1507.severity = warning
dotnet_diagnostic.SA1516.severity = warning
+4 -22
View File
@@ -2,34 +2,16 @@
GitHub Actions builds PAL3 and PAL3A with the Unity version in
`ProjectSettings/ProjectVersion.txt`. Each variant covers Android, iOS,
macOS, Linux, and 32-bit/64-bit Windows. The workflows run only on pull requests.
New commits cancel superseded runs for the same pull request and workflow.
Successful desktop/Android builds upload artifacts.
The separate `Code style` workflow verifies changed owned C# files with the SDK's
`dotnet format`, using `.editorconfig` and the SDK pinned in `global.json`.
It combines whitespace formatting with pinned StyleCop layout rules SA1107, SA1502,
SA1507 and SA1516 to enforce separate statements, multiline blocks and blank lines
between members. StyleCop is restored only into the temporary formatting project.
It parses both PAL3 and PAL3A conditional branches without Unity or game data.
Run `python3 tools/format-csharp.py` locally to format current changes, then
`python3 tools/format-csharp.py --check` to verify them. CI selects PR changes with
`--check --base <base-sha>`; `--all` is an explicit full-source audit, not the default.
Default and `--base` runs apply formatting only to changed lines and deletion
boundaries, preserving existing formatting elsewhere. Explicit file/directory
paths and `--all` format whole files. Check mode operates on temporary copies.
This checks whitespace and layout, not semantic correctness or Unity behavior.
macOS, Linux, and 32-bit/64-bit Windows. The workflows run on pushes and pull
requests, and successful desktop/Android builds upload artifacts.
Codacy is not part of this repository's CI. Its repository webhook is disabled;
there is no Codacy workflow or Codacy-required branch protection check. Re-enabling
that external integration would resume its checks independently of these workflows.
The workflows use checkout v7.0.1, cache v6.1.0, and unity-builder v6.0.0.
The builder CLI is pinned to v0.1.73 so its behavior does not change independently
of the workflow. Update and validate this pin together with builder upgrades.
Keep the committed project configured for PAL3. PAL3A workflows switch their own
checkout before building. Do not add original game data to CI inputs.
checkout before building. Public builds reject imported private VFX and legacy Toon assets;
do not add them or original game data to CI inputs.
When investigating a failure, inspect the failed job's Unity/build logs first.
Retry an isolated runner or network failure after checking the log; fix reproducible
+5 -10
View File
@@ -1,10 +1,6 @@
name: Builds - PAL3 - Mono - Android
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
on: [push, pull_request]
jobs:
build_pal3_mono_android:
@@ -25,16 +21,16 @@ jobs:
large-packages: true
docker-images: true
swap-storage: true
- uses: actions/checkout@v7.0.1
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v6.1.0
- uses: actions/cache@v5.0.5
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- uses: game-ci/unity-builder@v6.0.0
- uses: game-ci/unity-builder@v5
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
@@ -43,9 +39,8 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3
versioning: Semantic
cliVersion: v0.1.73
- uses: actions/upload-artifact@v7.0.1
with:
name: PAL3-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
retention-days: 14
retention-days: 14
+5 -10
View File
@@ -1,10 +1,6 @@
name: Builds - PAL3 - Mono - iOS
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
on: [push, pull_request]
jobs:
build_pal3_mono_ios:
@@ -16,16 +12,16 @@ jobs:
targetPlatform:
- iOS # Build an iOS player.
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v6.1.0
- uses: actions/cache@v5.0.5
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- uses: game-ci/unity-builder@v6.0.0
- uses: game-ci/unity-builder@v5
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
@@ -34,5 +30,4 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3
versioning: Semantic
cliVersion: v0.1.73
# do not upload artifacts for iOS builds
# do not upload artifacts for iOS builds
+5 -10
View File
@@ -1,10 +1,6 @@
name: Builds - PAL3 - Mono - Linux
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
on: [push, pull_request]
jobs:
build_pal3_mono_linux:
@@ -16,16 +12,16 @@ jobs:
targetPlatform:
- StandaloneLinux64 # Build a Linux 64-bit standalone.
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v6.1.0
- uses: actions/cache@v5.0.5
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- uses: game-ci/unity-builder@v6.0.0
- uses: game-ci/unity-builder@v5
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
@@ -34,9 +30,8 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3
versioning: Semantic
cliVersion: v0.1.73
- uses: actions/upload-artifact@v7.0.1
with:
name: PAL3-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
retention-days: 14
retention-days: 14
+5 -10
View File
@@ -1,10 +1,6 @@
name: Builds - PAL3 - Mono - MacOS
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
on: [push, pull_request]
jobs:
build_pal3_mono_macos:
@@ -16,16 +12,16 @@ jobs:
targetPlatform:
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v6.1.0
- uses: actions/cache@v5.0.5
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- uses: game-ci/unity-builder@v6.0.0
- uses: game-ci/unity-builder@v5
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
@@ -34,9 +30,8 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3
versioning: Semantic
cliVersion: v0.1.73
- uses: actions/upload-artifact@v7.0.1
with:
name: PAL3-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
retention-days: 14
retention-days: 14
+5 -10
View File
@@ -1,10 +1,6 @@
name: Builds - PAL3 - Mono - Windows
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
on: [push, pull_request]
jobs:
build_pal3_mono_windows:
@@ -17,16 +13,16 @@ jobs:
- StandaloneWindows # Build a Windows standalone.
- StandaloneWindows64 # Build a Windows 64-bit standalone.
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
lfs: true
- uses: actions/cache@v6.1.0
- uses: actions/cache@v5.0.5
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- uses: game-ci/unity-builder@v6.0.0
- uses: game-ci/unity-builder@v5
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
@@ -35,9 +31,8 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3
versioning: Semantic
cliVersion: v0.1.73
- uses: actions/upload-artifact@v7.0.1
with:
name: PAL3-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
retention-days: 14
retention-days: 14
+5 -10
View File
@@ -1,10 +1,6 @@
name: Builds - PAL3A - Mono - Android
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
on: [push, pull_request]
jobs:
build_pal3a_mono_android:
@@ -25,7 +21,7 @@ jobs:
large-packages: true
docker-images: true
swap-storage: true
- uses: actions/checkout@v7.0.1
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
lfs: true
@@ -41,12 +37,12 @@ jobs:
find: "6b32649dccc45df4ebe8e3f8eccee249"
replace: "d03d417e5660d5849939c8fe43732dbd"
include: "**ProjectSettings.asset"
- uses: actions/cache@v6.1.0
- uses: actions/cache@v5.0.5
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- uses: game-ci/unity-builder@v6.0.0
- uses: game-ci/unity-builder@v5
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
@@ -56,9 +52,8 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3A
versioning: Semantic
cliVersion: v0.1.73
- uses: actions/upload-artifact@v7.0.1
with:
name: PAL3A-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
retention-days: 14
retention-days: 14
+5 -10
View File
@@ -1,10 +1,6 @@
name: Builds - PAL3A - Mono - iOS
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
on: [push, pull_request]
jobs:
build_pal3a_mono_ios:
@@ -16,7 +12,7 @@ jobs:
targetPlatform:
- iOS # Build an iOS player.
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
lfs: true
@@ -32,12 +28,12 @@ jobs:
find: "6b32649dccc45df4ebe8e3f8eccee249"
replace: "d03d417e5660d5849939c8fe43732dbd"
include: "**ProjectSettings.asset"
- uses: actions/cache@v6.1.0
- uses: actions/cache@v5.0.5
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- uses: game-ci/unity-builder@v6.0.0
- uses: game-ci/unity-builder@v5
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
@@ -47,5 +43,4 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3A
versioning: Semantic
cliVersion: v0.1.73
# do not upload artifacts for iOS builds
# do not upload artifacts for iOS builds
+5 -10
View File
@@ -1,10 +1,6 @@
name: Builds - PAL3A - Mono - Linux
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
on: [push, pull_request]
jobs:
build_pal3a_mono_linux:
@@ -16,7 +12,7 @@ jobs:
targetPlatform:
- StandaloneLinux64 # Build a Linux 64-bit standalone.
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
lfs: true
@@ -32,12 +28,12 @@ jobs:
find: "6b32649dccc45df4ebe8e3f8eccee249"
replace: "d03d417e5660d5849939c8fe43732dbd"
include: "**ProjectSettings.asset"
- uses: actions/cache@v6.1.0
- uses: actions/cache@v5.0.5
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- uses: game-ci/unity-builder@v6.0.0
- uses: game-ci/unity-builder@v5
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
@@ -47,9 +43,8 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3A
versioning: Semantic
cliVersion: v0.1.73
- uses: actions/upload-artifact@v7.0.1
with:
name: PAL3A-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
retention-days: 14
retention-days: 14
+5 -10
View File
@@ -1,10 +1,6 @@
name: Builds - PAL3A - Mono - MacOS
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
on: [push, pull_request]
jobs:
build_pal3a_mono_macos:
@@ -16,7 +12,7 @@ jobs:
targetPlatform:
- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
lfs: true
@@ -32,12 +28,12 @@ jobs:
find: "6b32649dccc45df4ebe8e3f8eccee249"
replace: "d03d417e5660d5849939c8fe43732dbd"
include: "**ProjectSettings.asset"
- uses: actions/cache@v6.1.0
- uses: actions/cache@v5.0.5
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- uses: game-ci/unity-builder@v6.0.0
- uses: game-ci/unity-builder@v5
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
@@ -47,9 +43,8 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3A
versioning: Semantic
cliVersion: v0.1.73
- uses: actions/upload-artifact@v7.0.1
with:
name: PAL3A-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
retention-days: 14
retention-days: 14
+5 -10
View File
@@ -1,10 +1,6 @@
name: Builds - PAL3A - Mono - Windows
on: [pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
on: [push, pull_request]
jobs:
build_pal3a_mono_windows:
@@ -17,7 +13,7 @@ jobs:
- StandaloneWindows # Build a Windows standalone.
- StandaloneWindows64 # Build a Windows 64-bit standalone.
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/checkout@v6.0.3
with:
fetch-depth: 0
lfs: true
@@ -33,12 +29,12 @@ jobs:
find: "6b32649dccc45df4ebe8e3f8eccee249"
replace: "d03d417e5660d5849939c8fe43732dbd"
include: "**ProjectSettings.asset"
- uses: actions/cache@v6.1.0
- uses: actions/cache@v5.0.5
with:
path: Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: Library-
- uses: game-ci/unity-builder@v6.0.0
- uses: game-ci/unity-builder@v5
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
@@ -48,9 +44,8 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
buildName: PAL3A
versioning: Semantic
cliVersion: v0.1.73
- uses: actions/upload-artifact@v7.0.1
with:
name: PAL3A-Mono-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
retention-days: 14
retention-days: 14
-29
View File
@@ -1,29 +0,0 @@
name: Code style
on:
pull_request:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
csharp-format:
name: C# formatting (PAL3 and PAL3A)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v5.3.0
with:
global-json-file: global.json
- name: Test formatter enforcement
run: python3 tools/tests/test-format-csharp.py
- name: Verify changed C# formatting
env:
BASE_REF: ${{ github.event.pull_request.base.sha }}
run: python3 tools/format-csharp.py --check --base "$BASE_REF"
+15 -10
View File
@@ -77,15 +77,20 @@ crashlytics-build.properties
# Unity StreamingAssets folder
/Assets/StreamingAssets
# 3rd party plugin/assets
/Assets/Hovl Studio
/Assets/Hovl Studio.meta
/Assets/RealToon
/Assets/RealToon.meta
# VFX prefabs that are using 3rd party assets
/Assets/Resources/Prefabs/VFX/PAL3/*.prefab
/Assets/Resources/Prefabs/VFX/PAL3/*.meta
/Assets/Resources/Prefabs/VFX/PAL3A/*.prefab
/Assets/Resources/Prefabs/VFX/PAL3A/*.meta
# Materials that are using 3rd party assets
/Assets/Resources/Materials/
# VS Conde config file
.vsconfig
# Local asset imports
/Assets/Hovl Studio/
/Assets/Hovl Studio.meta
/Assets/RealToon/
/Assets/RealToon.meta
/Assets/Resources/Prefabs/VFX/
/Assets/Resources/Prefabs/VFX.meta
/Assets/Resources/Materials/
/Assets/Resources/Materials.meta
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
/*
reference: https://www.shadertoy.com/view/MsKXDh
@@ -1,8 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// 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
@@ -1,8 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// 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"
+1 -4
View File
@@ -1,7 +1,4 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// See LICENSE in the project root.
#include "Pal3ToonInput.hlsl"
+1 -4
View File
@@ -1,7 +1,4 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// See LICENSE in the project root.
#include "Pal3ToonInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
+1 -4
View File
@@ -1,7 +1,4 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// See LICENSE in the project root.
#ifndef PAL3_TOON_INPUT_INCLUDED
#define PAL3_TOON_INPUT_INCLUDED
+1 -4
View File
@@ -1,7 +1,4 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// See LICENSE in the project root.
#include "Pal3ToonInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
@@ -1,7 +1,4 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// See LICENSE in the project root.
Shader "Pal3/ToonCutout"
{
@@ -1,7 +1,4 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// See LICENSE in the project root.
Shader "Pal3/ToonOpaque"
{
@@ -1,7 +1,4 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// See LICENSE in the project root.
Shader "Pal3/ToonTransparent"
{
@@ -1,7 +1,4 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// See LICENSE in the project root.
Shader "Pal3/ToonWater"
{
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 333f40dc46c4a48e994e0f12147fd805
guid: 0b0b27c9e5e4d2e4fbc9b6584f828f7b
folderAsset: yes
DefaultImporter:
externalObjects: {}
@@ -1,6 +1,7 @@
fileFormatVersion: 2
guid: 1ad62311850a34be3a646a9a9cb5cd0e
TextScriptImporter:
guid: 2eaeb845461401e488e4640caf779ddf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b93923849ec63ad4ea52f79bf5bc9cb6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,45 @@
因为当前特效的实现方式使用了第三方插件和素材,所以此文件夹内的所有prefab均添加进了gitignore里。
请联系作者了解插件获取方式和特效prefab的获取方式。
0 => 传送法阵特效
15 => 单人传送特效
98 => 重楼施法帮龙葵恢复肉身时的特效
175 => 邪剑仙迷倒众人的特效
224 => 丁小侠剧情狼妖受击特效
251 => 邪剑仙变身特效
252 => 邪剑仙传送离开时的特效
254 => 重楼传送法术特效
255 => 龙葵穿衣服的特效
256 => 龙葵治疗他人特效
257 => 治疗咒施法特效
259 => 大型传送法施法前奏特效
260 => 大型传送法阵特效收尾
261 => 大型传送法阵特效开始
262 => 重楼当剑的时候剑插入地面的火光特效
263 => 火鬼王消失特效
264 => 古藤精施法特效
265 => 人物受到法术作用时候的特效
266 => 邪剑仙施法特效
270 => 天鬼皇复活后灵魂出窍特效
275 => 重楼创建的用来禁锢雪见/龙葵的法阵特效
276 => 迴魂施法结束特效
277 => 迴魂施法完全结束特效
278 => 迴魂施法特效
290 => 雪见传送出现时特效
295 => 重楼施法治疗特效
297 => 紫萱施法召唤水灵特效
337 => 古藤精风系法术特效
341 => 邪剑仙给镇妖剑施法特效
368 => 雷击单体施法特效
369 => 雷击范围施法特效
376 => 紫萱的土系法术特效
389 => 紫萱给江姑娘施法特效
452 => 花楹治疗他人特效
453 => 人物施法蓄力时的特效
454 => 龙葵施法让众人御剑飞行的特效
456 => 老婆婆施法特效
457 => 夕瑶给景天施法时的特效
458 => 灵力溢出特效
467 => 邪剑仙灰飞烟灭特效
468 => 蓝龙葵变红龙葵的特效
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 76dd240ef64804e0c93835be467d22fa
guid: 815b64a4a03e7b949bd85e1e5c19deb3
TextScriptImporter:
externalObjects: {}
userData:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a637ebcead3359c4f849f936d41707ee
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,67 @@
因为当前特效的实现方式使用了第三方插件和素材,所以此文件夹内的所有prefab均添加进了gitignore里。
请联系作者了解插件获取方式和特效prefab的获取方式。
0 => 传送法阵特效
9 => 茅山道士封印法术特效
40 => 单体风咒特效
50 => 单体雷咒特效
91 => 封印法术特效
157 => 角色传送出现特效
164 => 南宫煌变身狼形态时的特效
170 => 王蓬絮变身特效
171 => 人物施法特效
172 => 人物受到法术作用时候的特效
173 => 人物受到法术作用时候的特效
174 => 治疗特效
175 => 茅山术士打乱三杯盏特效
176 => 南宫煌打乱三杯盏特效
177 => 角色传送消失时的特效
178 => 南宫煌使关桃子的笼子消失的特效
179 => 南宫煌变出法桌的特效
181 => 南宫煌变出小东西的特效
182 => 南宫煌变出大东西的特效
186 => 大石块砸下后的尘土特效
189 => 地脉石门封印打开时的特效
198 => 南宫煌变出东西的特效
201 => 魁妖变小特效
205 => 照妖镜发光的特效
209 => 五灵轮特效
211 => 洒金笺特效
230 => 重楼施法消灭怪物的特效
254 => 重楼传送特效
257 => 隔空取物特效
258 => 迴魂传送特效
259 => 大型传送法施法前奏特效
260 => 大型传送法阵特效收尾
261 => 大型传送法阵特效开始
281 => 角色传送消失时的特效
282 => 雷咒特效
283 => 物品消失时的特效
285 => 南宫煌施法特效
287 => 土灵珠特效
289 => 血魂姬施法特效
290 => 回复法阵特效
292 => 五灵轮发光特效
299 => 重楼传送众人特效
314 => 倾国银弹波特效
315 => 南宫煌切换为人形态特效
316 => 魔物出现特效
318 => 千凝魔艮特效
320 => 幽娘变身特效
322 => 幽娘吸收怨气特效
323 => 幽娘收集怨气特效
325 => 陆北亭变身特效
328 => 风雅颂开心的特效
333 => 感月出现特效
355 => 王蓬絮治疗特效
359 => 蝎魃消失特效
360 => 星璇给南宫煌输入内力时的特效
367 => 五毒珠治疗特效
388 => 迴魂传送特效
389 => 迴魂传送特效
397 => 燎日变身特效
401 => 魔尊帮星璇灵肉合一的特效
404 => 思堂消失特效
408 => 星璇燎日变换时特效
424 => 王蓬絮对南宫煌施法特效
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: f681ca82a61e64565a8a7a3352a5b2c8
guid: f1d950c46b3119043a1919074fdc27c5
TextScriptImporter:
externalObjects: {}
userData:
+3 -3
View File
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
Shader "Pal3/Dev"
{
+3 -3
View File
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
Shader "Pal3/Opaque"
{
@@ -1,78 +0,0 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
Shader "Pal3/OriginalEffect"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("Source blend", Float) = 1
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("Destination blend", Float) = 1
[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest ("Depth test", Float) = 4
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", Float) = 0
_AlphaMode ("Original alpha operation", Float) = 0
}
SubShader
{
Tags
{
"RenderPipeline" = "UniversalPipeline"
"Queue" = "Transparent"
"RenderType" = "Transparent"
}
Pass
{
Tags { "LightMode" = "SRPDefaultUnlit" }
Blend [_SrcBlend] [_DstBlend]
ZTest [_ZTest]
ZWrite Off
Cull [_Cull]
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct Attributes
{
float3 positionOS : POSITION;
float2 uv : TEXCOORD0;
half4 color : COLOR;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
half4 color : COLOR;
};
TEXTURE2D(_MainTex);
SAMPLER(sampler_MainTex);
CBUFFER_START(UnityPerMaterial)
float _AlphaMode;
CBUFFER_END
Varyings Vert(Attributes i)
{
Varyings o;
o.positionCS = TransformObjectToHClip(i.positionOS);
o.uv = i.uv;
o.color = i.color;
return o;
}
half4 Frag(Varyings i) : SV_Target
{
half4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
half4 col = tex * i.color;
if (_AlphaMode > 1.5)
{
col.a = tex.a;
}
else if (_AlphaMode > 0.5)
{
col.a = saturate(tex.a + i.color.a);
}
return col;
}
ENDHLSL
}
}
}
@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: dd7af60dc97334317a8bf7d560ba0f71
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
+3 -3
View File
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
Shader "Pal3/Sprite"
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
Shader "Pal3/Transparent"
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
Shader "Pal3/TransparentOpaquePart"
{
+3 -3
View File
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
Shader "Pal3/Water"
{
@@ -1,42 +0,0 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
Shader "Pal3/SkyboxEffect"
{
Properties { _MainTex ("Sequence frame", 2D) = "black" {} }
SubShader
{
Tags { "RenderPipeline"="UniversalPipeline" "Queue"="Transparent-10" "RenderType"="Transparent" }
Pass
{
Blend SrcAlpha One
ZWrite Off
Cull Off
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
struct Attributes { float4 positionOS : POSITION; float2 uv : TEXCOORD0; };
struct Varyings { float4 positionCS : SV_POSITION; float2 uv : TEXCOORD0; };
Varyings vert(Attributes input)
{
Varyings output;
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
// Sky effects must remain behind all scene geometry, including
// mountains farther away than the effect cube's actual mesh.
#if UNITY_REVERSED_Z
output.positionCS.z = 0.0;
#else
output.positionCS.z = output.positionCS.w;
#endif
output.uv = input.uv;
return output;
}
half4 frag(Varyings input) : SV_Target { return SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv); }
ENDHLSL
}
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 0d3ce4f585ff416caf911181f6f5dd56
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
#if UNITY_EDITOR_OSX && UNITY_IOS
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
#if UNITY_EDITOR_OSX && UNITY_STANDALONE_OSX
-681
View File
@@ -1,681 +0,0 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
namespace Editor
{
using System;
using System.IO;
using System.Linq;
using Pal3.Core.DataReader.Cpk;
using Pal3.Core.DataReader.Data;
using Pal3.Core.DataReader.Par;
using Pal3.Core.FileSystem;
using Pal3.Game.Effect.Original;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
public sealed class EffectEditor : EditorWindow
{
private OriginalEffectResources _resources;
private OriginalEffectPlayer _player;
private OriginalPortalEffect _portal;
private uint _portalType;
[SerializeField] private OriginalEffectOverrides _edits;
[SerializeField] private string _assetPath = "", _savedJson;
private GameObject _root;
private Scene _scene;
private Camera _camera;
private RenderTexture _target;
private string _dataPath, _search = "", _error;
[SerializeField] private bool _pal3a;
private string Variant => _pal3a ? "PAL3A" : "PAL3";
private int _codepage = 936;
[SerializeField] private int _id = 98, _objectIndex;
private Vector2 _listScroll, _inspectorScroll, _orbit = new(135, 15);
private float _distance = 14, _speed = 1, _duration = 15;
[SerializeField] private float _time;
private bool _playing, _loop;
private uint _seed = 1;
private bool _emitterCurve;
private int _particleIndex, _curveIndex;
private double _lastUpdate;
private string _previewJson;
private float? _pendingSeek;
private double _seekAfter;
[MenuItem("PAL3/Effect Editor")]
public static void Open()
{
var window = GetWindow<EffectEditor>("Effects");
window.ChangeVariant(false);
}
[MenuItem("PAL3A/Effect Editor")]
public static void OpenPal3A()
{
var window = GetWindow<EffectEditor>("Effects");
window.ChangeVariant(true);
}
private void ChangeVariant(bool pal3a)
{
if (_pal3a == pal3a || !CanReplaceEdits())
return;
_pal3a = pal3a;
_id = pal3a ? 160 : 98;
_time = 0;
LoadOverrides(Resources.Load<OriginalEffectOverrides>($"Effects/{Variant}Overrides"));
LoadPreferences();
LoadData();
}
private void LoadPreferences()
{
_dataPath = EditorPrefs.GetString($"{Variant}.OriginalEffect.DataPath", Path.GetFullPath(Path.Combine(Application.dataPath, $"../../Game Data/{Variant}")));
_codepage = EditorPrefs.GetInt($"{Variant}.OriginalEffect.Codepage", 936) == 950 ? 950 : 936;
}
public void CreateGUI() => rootVisualElement.Add(new IMGUIContainer(DrawWindow) { style = { flexGrow = 1 } });
private void OnEnable()
{
minSize = new Vector2(1050, 640);
LoadPreferences();
if (_edits == null)
LoadOverrides(Resources.Load<OriginalEffectOverrides>($"Effects/{Variant}Overrides"));
_edits.hideFlags = HideFlags.HideInHierarchy | HideFlags.DontSave;
saveChangesMessage = "Save the original effect overrides before closing?";
_scene = EditorSceneManager.NewPreviewScene();
var cameraObject = new GameObject("Effect preview camera") { hideFlags = HideFlags.HideAndDontSave };
SceneManager.MoveGameObjectToScene(cameraObject, _scene);
_camera = cameraObject.AddComponent<Camera>();
_camera.enabled = false;
_camera.clearFlags = CameraClearFlags.SolidColor;
_camera.backgroundColor = new Color(0.07f, 0.08f, 0.1f);
_camera.fieldOfView = 40;
_camera.nearClipPlane = 0.01f;
_camera.farClipPlane = 500;
_camera.scene = _scene;
_lastUpdate = EditorApplication.timeSinceStartup;
EditorApplication.update += Tick;
Undo.undoRedoPerformed += RefreshAfterUndo;
if (Directory.Exists(_dataPath))
LoadData();
}
private void OnDisable()
{
EditorApplication.update -= Tick;
Undo.undoRedoPerformed -= RefreshAfterUndo;
ClearPreview();
_resources?.Dispose();
_resources = null;
if (_target != null)
{
_target.Release();
DestroyImmediate(_target);
}
if (_scene.IsValid())
EditorSceneManager.ClosePreviewScene(_scene);
}
private void OnDestroy()
{
if (_edits != null)
{
Undo.ClearUndo(_edits);
DestroyImmediate(_edits);
}
}
private void LoadOverrides(OriginalEffectOverrides asset)
{
if (_edits != null)
{
Undo.ClearUndo(_edits);
DestroyImmediate(_edits);
}
_edits = asset != null ? Instantiate(asset) : CreateInstance<OriginalEffectOverrides>();
_edits.hideFlags = HideFlags.HideInHierarchy | HideFlags.DontSave;
_assetPath = asset != null ? AssetDatabase.GetAssetPath(asset) : "";
_savedJson = JsonUtility.ToJson(_edits);
hasUnsavedChanges = false;
}
private void MarkChanged() => hasUnsavedChanges = JsonUtility.ToJson(_edits) != _savedJson;
public override void SaveChanges()
{
if (SaveOverrides())
base.SaveChanges();
}
public override void DiscardChanges()
{
LoadOverrides(_assetPath.Length > 0 ? AssetDatabase.LoadAssetAtPath<OriginalEffectOverrides>(_assetPath) : null);
base.DiscardChanges();
RefreshAfterUndo();
}
private bool CanReplaceEdits()
{
if (!hasUnsavedChanges)
return true;
int choice = EditorUtility.DisplayDialogComplex("Original effect overrides", "Save your current edits before loading another asset?", "Save", "Cancel", "Discard");
return choice == 2 || choice == 0 && SaveOverrides();
}
private bool SaveOverrides()
{
string path = EditorUtility.SaveFilePanelInProject($"Save {Variant} effect overrides",
_assetPath.Length > 0 ? Path.GetFileNameWithoutExtension(_assetPath) : $"{Variant}Overrides", "asset",
$"Use Assets/Resources/Effects/{Variant}Overrides.asset for runtime loading.");
if (path.Length == 0)
return false;
var existing = AssetDatabase.LoadMainAssetAtPath(path);
if (existing != null && existing is not OriginalEffectOverrides)
{
_error = "Choose an OriginalEffectOverrides asset or a new path.";
return false;
}
var saved = existing as OriginalEffectOverrides;
if (saved != null)
{
Undo.RecordObject(saved, $"Save {Variant} effect overrides");
EditorUtility.CopySerialized(_edits, saved);
saved.hideFlags = HideFlags.None;
EditorUtility.SetDirty(saved);
}
else
{
saved = Instantiate(_edits);
saved.hideFlags = HideFlags.None;
AssetDatabase.CreateAsset(saved, path);
}
saved.name = Path.GetFileNameWithoutExtension(path);
EditorUtility.SetDirty(saved);
AssetDatabase.SaveAssets();
_assetPath = path;
_savedJson = JsonUtility.ToJson(_edits);
hasUnsavedChanges = false;
return true;
}
private void LoadData()
{
float time = _time;
ClearPreview();
_resources?.Dispose();
_resources = null;
_error = null;
try
{
var hash = new Crc32Hash();
hash.Init();
var fs = new CpkFileSystem(_dataPath, hash, _codepage);
fs.Mount("basedata/basedata.cpk", _codepage);
_resources = new OriginalEffectResources(fs, _codepage);
if (_resources.GameVariant != Variant)
throw new InvalidDataException($"The selected directory contains {_resources.GameVariant} data; select the matching variant first.");
EditorPrefs.SetString($"{Variant}.OriginalEffect.DataPath", _dataPath);
Restart();
Seek(time);
}
catch (Exception ex)
{
_resources?.Dispose();
_resources = null;
_error = ex.ToString();
}
}
private void ClearPreview()
{
if (_root != null)
DestroyImmediate(_root);
_player = null;
_portal = null;
}
private void Restart()
{
ClearPreview();
_time = 0;
_pendingSeek = null;
_error = null;
_previewJson = JsonUtility.ToJson(_edits);
if (_resources == null)
return;
try
{
_root = new GameObject("Original effect preview") { hideFlags = HideFlags.HideAndDontSave };
SceneManager.MoveGameObjectToScene(_root, _scene);
if (_id < 0)
{
_portal = _root.AddComponent<OriginalPortalEffect>();
_portal.AutoAdvance = false;
_portal.Initialize(_resources, _portalType);
}
else
{
string[] issues = _resources.Diagnose(_id, _edits);
if (issues.Length > 0)
_error = string.Join("\n", issues);
else
{
_player = _root.AddComponent<OriginalEffectPlayer>();
_player.AutoAdvance = false;
_player.Initialize(_resources, _id, _seed, _edits);
_player.Loop = false;
if (_player.Error != null)
_error = _player.Error;
}
}
}
catch (Exception ex)
{
ClearPreview();
_error = ex.ToString();
}
}
private void Tick()
{
double now = EditorApplication.timeSinceStartup;
float dt = Mathf.Min(0.1f, (float)(now - _lastUpdate));
_lastUpdate = now;
if (_pendingSeek.HasValue && now >= _seekAfter)
{
Seek(_pendingSeek.Value);
Repaint();
}
if (_playing)
{
Advance(dt * _speed);
if (_time >= _duration)
{
if (_loop)
Restart();
else
_playing = false;
}
Repaint();
}
}
private void Advance(float delta)
{
_time += delta;
_player?.Advance(delta);
_portal?.Sample(_time);
}
private void Seek(float time)
{
_pendingSeek = null;
_time = time;
_player?.Seek(time);
_portal?.Sample(time);
}
private void QueueSeek(float time)
{
_playing = false;
_pendingSeek = time;
_seekAfter = EditorApplication.timeSinceStartup + 0.05;
Repaint();
}
private void RefreshAfterUndo()
{
MarkChanged();
if (_previewJson == JsonUtility.ToJson(_edits))
return;
float time = _time;
Restart();
Seek(time);
Repaint();
}
private void DrawWindow()
{
using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar))
{
int variant = EditorGUILayout.Popup(_pal3a ? 1 : 0, new[] { "PAL3", "PAL3A" }, GUILayout.Width(80));
if ((variant == 1) != _pal3a)
ChangeVariant(variant == 1);
_dataPath = EditorGUILayout.TextField(_dataPath);
int codepage = EditorGUILayout.Popup(_codepage == 950 ? 1 : 0, new[] { "GBK (936)", "Big5 (950)" }, GUILayout.Width(105)) == 0 ? 936 : 950;
if (codepage != _codepage)
{
_codepage = codepage;
EditorPrefs.SetInt($"{Variant}.OriginalEffect.Codepage", _codepage);
LoadData();
}
if (GUILayout.Button("Browse", EditorStyles.toolbarButton, GUILayout.Width(60)))
{
string path = EditorUtility.OpenFolderPanel($"{Variant} data (contains basedata)", _dataPath, "");
if (path.Length > 0)
{
_dataPath = path;
LoadData();
}
}
if (GUILayout.Button("Reload", EditorStyles.toolbarButton, GUILayout.Width(55)))
LoadData();
}
var asset = _assetPath.Length > 0 ? AssetDatabase.LoadAssetAtPath<OriginalEffectOverrides>(_assetPath) : null;
var selected = (OriginalEffectOverrides)EditorGUILayout.ObjectField("Overrides", asset, typeof(OriginalEffectOverrides), false);
if (selected != asset && CanReplaceEdits())
{
LoadOverrides(selected);
Restart();
}
if (_resources == null)
{
EditorGUILayout.HelpBox(_error ?? "Choose the PAL3 game data directory.", MessageType.Info);
return;
}
using (new EditorGUILayout.HorizontalScope())
{
using (new EditorGUILayout.VerticalScope(GUILayout.Width(185)))
{
_search = EditorGUILayout.TextField(_search, EditorStyles.toolbarSearchField);
_listScroll = EditorGUILayout.BeginScrollView(_listScroll);
if (GUILayout.Button("Scene: Transport point"))
Select(-1);
for (int id = 0; id < _resources.Definitions.Groups.Length; id++)
{
EffectGroup g = _resources.Definitions.Groups[id];
if (g.Objects.Length == 0)
continue;
string label = $"{id} ({g.Objects.Length})";
if (_search.Length > 0 && !label.Contains(_search) && !g.Objects.Any(o => _resources.Definitions.TryGetType(o.TypeCrc, out var d) && d.TypeName.Contains(_search)))
continue;
if (GUILayout.Toggle(_id == id, label, "Button") && _id != id)
Select(id);
}
EditorGUILayout.EndScrollView();
}
using (new EditorGUILayout.VerticalScope())
{
if (_id < 0 && _pal3a)
{
int style = EditorGUILayout.Popup("Transport style", (int)_portalType, new[] { "Default", "1 (trans_s)", "2 (trans_m)", "3 (trans_l)", "4 (trans_f)", "5 (trans_t)", "6 (trans_p)" });
if ((uint)style != _portalType)
{
_portalType = (uint)style;
Restart();
}
}
using (new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Button(_playing ? "Pause" : "Play", GUILayout.Width(60)))
_playing = !_playing;
if (GUILayout.Button("Reset", GUILayout.Width(55)))
Restart();
if (GUILayout.Button("Step", GUILayout.Width(50)))
{
_playing = false;
Advance(OriginalEffectPlayer.FixedStep);
Repaint();
}
GUILayout.Label("Speed", GUILayout.Width(40));
_speed = EditorGUILayout.FloatField(_speed, GUILayout.Width(45));
_speed = float.IsFinite(_speed) ? Mathf.Clamp(_speed, 0, 16) : 1;
_loop = GUILayout.Toggle(_loop, "Loop");
}
Rect preview = GUILayoutUtility.GetRect(200, 200, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
DrawPreview(preview);
float displayedTime = _pendingSeek ?? _time;
float time = EditorGUILayout.Slider("Time", displayedTime, 0, _duration);
if (Mathf.Abs(time - displayedTime) > 0.00001f)
QueueSeek(time);
using (new EditorGUILayout.HorizontalScope())
{
_duration = EditorGUILayout.FloatField("Preview duration", _duration);
_duration = float.IsFinite(_duration) ? Mathf.Clamp(_duration, 0.1f, 600) : 15;
uint seed = (uint)Mathf.Max(1, EditorGUILayout.IntField("Seed", (int)_seed));
if (seed != _seed)
{
_seed = seed;
Restart();
}
}
EditorGUILayout.LabelField($"Objects: {_player?.NodeCount ?? 0} Quads/particles: {_player?.QuadCount ?? 0} {_player?.Error}");
EditorGUILayout.LabelField("Drag to orbit · Scroll to zoom", EditorStyles.miniLabel);
if (_error != null)
EditorGUILayout.HelpBox(_error, MessageType.Warning);
}
using (new EditorGUILayout.VerticalScope(GUILayout.Width(310)))
DrawInspector();
}
}
private void Select(int id)
{
_id = id;
_objectIndex = 0;
Restart();
}
private void DrawPreview(Rect rect)
{
Event e = Event.current;
if (rect.Contains(e.mousePosition))
{
if (e.type == EventType.MouseDrag && e.button == 0)
{
_orbit += e.delta * new Vector2(0.5f, -0.5f);
e.Use();
Repaint();
}
if (e.type == EventType.ScrollWheel)
{
_distance = Mathf.Clamp(_distance * Mathf.Exp(e.delta.y * 0.08f), 0.3f, 200);
e.Use();
Repaint();
}
}
if (e.type != EventType.Repaint || rect.width < 1 || rect.height < 1)
return;
int w = Mathf.Max(1, (int)rect.width), h = Mathf.Max(1, (int)rect.height);
if (_target == null || _target.width != w || _target.height != h)
{
if (_target != null)
{
_target.Release();
DestroyImmediate(_target);
}
_target = new RenderTexture(w, h, 24) { hideFlags = HideFlags.HideAndDontSave };
_target.Create();
}
_camera.transform.position = Quaternion.Euler(_orbit.y, _orbit.x, 0) * new Vector3(0, 0, -_distance) + Vector3.up * 1.5f;
_camera.transform.LookAt(Vector3.up * 1.5f);
_camera.aspect = (float)w / h;
_player?.Render(_camera);
RenderPipeline.SubmitRenderRequest(_camera, new UniversalRenderPipeline.SingleCameraRequest { destination = _target });
GUI.DrawTexture(rect, _target, ScaleMode.StretchToFill, false);
GUI.Label(new Rect(rect.x + 8, rect.y + 8, rect.width - 16, 25), $"{Variant} effect data", EditorStyles.whiteBoldLabel);
}
private void DrawInspector()
{
EditorGUILayout.LabelField("Object / task parameters", EditorStyles.boldLabel);
if (_id < 0)
{
EditorGUILayout.HelpBox("MXTransport: original two cones and rotating plane. This is separate from flexeff group 0.", MessageType.Info);
return;
}
EffectGroup group = _resources.Definitions.Groups[_id];
if (group.Objects.Length == 0)
return;
_objectIndex = EditorGUILayout.IntSlider("Object", _objectIndex, 0, group.Objects.Length - 1);
EffectGroupObject source = group.Objects[_objectIndex];
_resources.Definitions.TryGetType(source.TypeCrc, out EffectDefinition d);
EditorGUILayout.LabelField($"{d.TypeName} / {EffectClass.Name(d.ClassNameCrc)}");
EditorGUILayout.SelectableLabel(d.TextureName ?? "", GUILayout.Height(35));
OriginalEffectObjectOverride edit = _edits.Find(_id, _objectIndex);
if (edit == null && GUILayout.Button("Edit this object"))
{
Undo.RecordObject(_edits, "Edit original effect");
edit = new OriginalEffectObjectOverride
{
GroupId = _id,
ObjectIndex = _objectIndex,
Definition = JsonUtility.FromJson<EffectDefinition>(JsonUtility.ToJson(d)),
Tasks = source.Tasks.Select(t => JsonUtility.FromJson<EffectTask>(JsonUtility.ToJson(t))).ToArray()
};
_edits.Objects.Add(edit);
MarkChanged();
}
_inspectorScroll = EditorGUILayout.BeginScrollView(_inspectorScroll);
if (edit != null)
{
var so = new SerializedObject(_edits);
so.Update();
SerializedProperty entry = so.FindProperty("Objects").GetArrayElementAtIndex(_edits.Objects.IndexOf(edit));
EditorGUILayout.PropertyField(entry.FindPropertyRelative("Hidden"));
EditorGUILayout.PropertyField(entry.FindPropertyRelative("Definition"), true);
EditorGUILayout.PropertyField(entry.FindPropertyRelative("Tasks"), true);
if (so.ApplyModifiedProperties())
{
MarkChanged();
float time = _time;
Restart();
Seek(time);
}
}
else
foreach (EffectTask t in source.Tasks)
EditorGUILayout.LabelField($"{t.StartTime:0.###}s + {t.Duration:0.###}s loops={t.RequireLoops}");
EffectDefinition effective = edit?.Definition ?? d;
if (EffectClass.Name(effective.ClassNameCrc) == "S-Particle")
{
try
{
SparFile spar = _resources.Spar(effective.ParticleFileName);
EditorGUILayout.LabelField($"SPar: {spar.Groups.Length} groups / shader {spar.Shader}");
foreach (SparGroup sg in spar.Groups)
{
EditorGUILayout.LabelField($"{sg.Name}: capacity {sg.Capacity}, {sg.Keyframes.Length} keys", EditorStyles.wordWrappedLabel);
EditorGUILayout.SelectableLabel(sg.Texture, GUILayout.Height(30));
}
EditorGUILayout.HelpBox("Native SPar playback: keyframes, emitter paths, particle controllers and original shader blending. SPar fields are read-only here.", MessageType.Info);
}
catch (Exception ex)
{
EditorGUILayout.HelpBox(ex.Message, MessageType.Warning);
}
}
if (EffectClass.Name(effective.ClassNameCrc) == "particle")
DrawParticleCurves(effective.ParticleFileName);
EditorGUILayout.EndScrollView();
if (GUILayout.Button("Save overrides for game…"))
SaveOverrides();
if (GUILayout.Button("Discard edits for this object") && edit != null)
{
Undo.RecordObject(_edits, "Discard original effect override");
_edits.Objects.Remove(edit);
MarkChanged();
Restart();
}
}
private void DrawParticleCurves(string path)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Particle resource curves", EditorStyles.boldLabel);
ParticleFile file;
try
{
file = _resources.Particle(path);
}
catch (Exception ex)
{
EditorGUILayout.HelpBox(ex.Message, MessageType.Warning);
return;
}
_emitterCurve = EditorGUILayout.Toggle("Emitter curves", _emitterCurve);
int count = _emitterCurve ? file.Emitters.Length : file.Particles.Length;
if (count == 0)
return;
_particleIndex = EditorGUILayout.IntSlider("Resource index", _particleIndex, 0, count - 1);
string[] names = _emitterCurve ? new[] { "Direction", "RandomVelocity", "Emission", "Life" } : new[] { "Size", "Rotation", "Alpha", "Color" };
_curveIndex = EditorGUILayout.Popup("Curve", Mathf.Clamp(_curveIndex, 0, names.Length - 1), names);
string name = names[_curveIndex];
ParticleCurve source = OriginalEffectOverrides.FindCurve(file, _emitterCurve, _particleIndex, name);
var entry = _edits.ParticleCurves.Find(c => string.Equals(c.File, path, StringComparison.OrdinalIgnoreCase)
&& c.Emitter == _emitterCurve && c.Index == _particleIndex && c.Parameter == name);
bool validEntry = entry == null || entry.Channels != null && entry.Channels.Length == source.Channels && entry.Channels.All(c => c != null);
if (!validEntry)
EditorGUILayout.HelpBox("This curve override has invalid channels. Restore the original curve to repair it.", MessageType.Warning);
for (int channel = 0; channel < source.Channels; channel++)
{
if (!validEntry)
break;
AnimationCurve curve = entry != null ? CopyCurve(entry.Channels[channel]) : SampleCurve(source, channel);
EditorGUI.BeginChangeCheck();
AnimationCurve changed = EditorGUILayout.CurveField($"Channel {channel}", curve);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(_edits, "Edit particle curve");
if (entry == null)
{
entry = new OriginalParticleCurveOverride
{
File = path,
Parameter = name,
Index = _particleIndex,
Emitter = _emitterCurve,
Channels = Enumerable.Range(0, source.Channels).Select(c => SampleCurve(source, c)).ToArray()
};
_edits.ParticleCurves.Add(entry);
}
entry.Channels[channel] = CopyCurve(changed);
MarkChanged();
float time = _time;
Restart();
Seek(time);
}
}
EditorGUILayout.LabelField(entry == null ? "Original sampled curve (unchanged)" : "Unity curve override for this particle resource", EditorStyles.wordWrappedMiniLabel);
if (entry != null && GUILayout.Button("Restore original particle curve"))
{
Undo.RecordObject(_edits, "Restore particle curve");
_edits.ParticleCurves.Remove(entry);
MarkChanged();
float time = _time;
Restart();
Seek(time);
}
}
private static AnimationCurve CopyCurve(AnimationCurve curve) =>
new(curve.keys)
{
preWrapMode = curve.preWrapMode,
postWrapMode = curve.postWrapMode
};
private static AnimationCurve SampleCurve(ParticleCurve source, int channel)
{
var curve = new AnimationCurve(Enumerable.Range(0, 101).Select(i => new Keyframe(i / 100f, source.Evaluate(i / 100f, channel))).ToArray());
for (int i = 0; i < curve.length; i++)
{
AnimationUtility.SetKeyLeftTangentMode(curve, i, AnimationUtility.TangentMode.Linear);
AnimationUtility.SetKeyRightTangentMode(curve, i, AnimationUtility.TangentMode.Linear);
}
return curve;
}
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 28e20becd27fe4cc3b3151897935cd30
+3 -3
View File
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Editor
{
@@ -0,0 +1,61 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Editor
{
using System;
using System.Linq;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
internal sealed class PrivateAssetBuildGuard : IPreprocessBuildWithReport
{
private const string PrivateBuildVariable = "PAL3_ALLOW_PRIVATE_ASSETS";
private const string StoryVfxPath = "/Resources/Prefabs/VFX/";
private const string HovlStudioPath = "/Hovl Studio/";
private const string RealToonPath = "/RealToon/";
private const string LegacyToonMaterialsPath = "Assets/Resources/Materials/";
private const string Pal3VfxReadme = "Assets/Resources/Prefabs/VFX/PAL3/README.txt";
private const string Pal3AVfxReadme = "Assets/Resources/Prefabs/VFX/PAL3A/README.txt";
internal static bool PrivateBuildEnabled =>
Environment.GetEnvironmentVariable(PrivateBuildVariable) == "1" &&
string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CI")) &&
string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTIONS"));
public int callbackOrder => int.MaxValue;
public void OnPreprocessBuild(BuildReport report) => Validate();
internal static void Validate()
{
if (PrivateBuildEnabled) return;
string privateAsset = AssetDatabase.GetAllAssetPaths().FirstOrDefault(IsPrivateAsset);
if (privateAsset == null) return;
throw new BuildFailedException(
$"Local optional VFX or legacy Toon assets are installed ({privateAsset}). " +
"Use a clean checkout for public builds. " +
$"For a private local build, launch Unity with {PrivateBuildVariable}=1.");
}
private static bool IsPrivateAsset(string assetPath)
{
if (assetPath.IndexOf(HovlStudioPath, StringComparison.OrdinalIgnoreCase) < 0 &&
assetPath.IndexOf(RealToonPath, StringComparison.OrdinalIgnoreCase) < 0 &&
!assetPath.StartsWith(LegacyToonMaterialsPath, StringComparison.OrdinalIgnoreCase) &&
assetPath.IndexOf(StoryVfxPath, StringComparison.OrdinalIgnoreCase) < 0)
{
return false;
}
return !assetPath.Equals(Pal3VfxReadme, StringComparison.OrdinalIgnoreCase) &&
!assetPath.Equals(Pal3AVfxReadme, StringComparison.OrdinalIgnoreCase) &&
!AssetDatabase.IsValidFolder(assetPath);
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ac41b9b3ac5641d98126273f7efb452f
+14 -10
View File
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Editor
{
@@ -131,13 +131,15 @@ namespace Editor
private static void BuildGame(Pal3BuildTarget buildTarget)
{
PrivateAssetBuildGuard.Validate();
BuildTargetGroup targetGroupBeforeBuild = EditorUserBuildSettings.selectedBuildTargetGroup;
BuildTarget targetBeforeBuild = EditorUserBuildSettings.activeBuildTarget;
string buildOutputPath = EditorUtility.SaveFolderPanel("Choose Location of Built Game", "", "");
if (string.IsNullOrWhiteSpace(buildOutputPath)) return;
string versionFolder = GetVersionFolderName();
string versionFolder = GetVersionFolderName(PrivateAssetBuildGuard.PrivateBuildEnabled);
buildOutputPath += $"{DirSeparator}{versionFolder}{DirSeparator}";
var buildConfigurations = new[]
@@ -269,14 +271,14 @@ namespace Editor
}
}
private static string GetVersionFolderName()
private static string GetVersionFolderName(bool privateBuild)
{
return PlayerSettings.bundleVersion;
return PlayerSettings.bundleVersion + (privateBuild ? "-Private" : "");
}
private static void ZipReleaseFiles()
{
string versionFolder = GetVersionFolderName();
string versionFolder = GetVersionFolderName(PrivateAssetBuildGuard.PrivateBuildEnabled);
string buildOutputPath = EditorUtility.SaveFolderPanel("Choose Location of Built Game",
versionFolder, versionFolder);
if (string.IsNullOrWhiteSpace(buildOutputPath)) return;
@@ -287,10 +289,12 @@ namespace Editor
{
string selectedFolder = Path.GetFileName(buildOutputPath.TrimEnd(
Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
if (selectedFolder != GetVersionFolderName())
bool privateBuild = selectedFolder == GetVersionFolderName(true);
if (!privateBuild && selectedFolder != GetVersionFolderName(false))
{
Debug.LogError($"Invalid build output path: {buildOutputPath}. " +
$"Please choose the current release build folder \"{GetVersionFolderName()}\".");
$"Please choose the current release build folder \"{GetVersionFolderName(false)}\" " +
$"or \"{GetVersionFolderName(true)}\".");
return;
}
@@ -309,7 +313,7 @@ namespace Editor
foreach ((string folderPath, Pal3BuildTarget target) in buildTargets)
{
string fullPath = $"{buildOutputPath}{DirSeparator}{folderPath}";
string zipFileName = $"{GameConstants.AppName}_v{GetVersionFolderName()}_{target.ToString()}.zip";
string zipFileName = $"{GameConstants.AppName}_v{GetVersionFolderName(privateBuild)}_{target.ToString()}.zip";
string zipFilePath = $"{releaseDirPath}{DirSeparator}{zipFileName}";
if (File.Exists(fullPath) || Directory.Exists(fullPath))
@@ -1,7 +1,4 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// See LICENSE in the project root.
namespace Editor
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Editor.SourceGenerator.Base
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Editor.SourceGenerator.Base
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Editor.SourceGenerator.Base
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Editor.SourceGenerator
{
@@ -24,11 +24,11 @@ namespace Editor.SourceGenerator
public void GenerateSourceClass(CodeWriter writer, string className, string nameSpace)
{
// Header.
writer.WriteLine("// ------------------------------------------------------------------------");
writer.WriteLine("// ---------------------------------------------------------------------------------------------");
writer.WriteLine("// <auto-generated>");
writer.WriteLine($"// This code was auto-generated by {GetType().Name}");
writer.WriteLine("// </auto-generated>");
writer.WriteLine("// ------------------------------------------------------------------------");
writer.WriteLine("// ---------------------------------------------------------------------------------------------");
writer.WriteLine();
// Begin namespace.
@@ -1,14 +1,12 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Editor
{
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using Pal3.Core.Command;
using SourceGenerator;
using SourceGenerator.Base;
@@ -41,18 +39,6 @@ namespace Editor
GenerateSourceInternal(OutputFileName, writePath, ClassName, NameSpace, sourceGenerator, true);
}
private static string CopyrightHeader(string writePath)
{
int currentYear = DateTime.Now.Year;
Match previous = Regex.Match(File.Exists(writePath) ? File.ReadAllText(writePath) : string.Empty,
@"Copyright \(c\) (?<first>\d{4})");
int firstYear = previous.Success ? int.Parse(previous.Groups["first"].Value) : currentYear;
string years = firstYear == currentYear ? $"{currentYear}" : $"{firstYear}-{currentYear}";
const string separator = "// ------------------------------------------------------------------------";
return $"{separator}\n// Copyright (c) {years}, Jiaqi (0x7c13) Liu. All rights reserved.\n" +
$"// See LICENSE file in the project root for license information.\n{separator}\n\n";
}
private static void GenerateSourceInternal(string fileName,
string writePath,
string className,
@@ -77,7 +63,7 @@ namespace Editor
sourceGenerator.GenerateSourceClass(writer, className, nameSpace);
// Final output string
string output = CopyrightHeader(writePath) + $"#if {GAME_VARIANT_SYMBOL}\n\n{writer.Buffer}\n#endif";
string output = $"#if {GAME_VARIANT_SYMBOL}\n\n{writer.Buffer}\n#endif";
// Write to file
using StreamWriter sw = new(writePath);
+3 -3
View File
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Editor
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Animation
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
@@ -1,43 +0,0 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
using System;
public enum TextureDataFormat
{
Rgba32,
Bc1,
Bc2,
}
/// <summary>
/// Texture pixels and mip layout, independent of a file container or graphics API.
/// The caller owns this source and disposes it after synchronous texture creation.
/// Upload buffers must remain unchanged until then and may be pooled.
/// </summary>
public interface ITextureDataSource : IDisposable
{
int Width { get; }
int Height { get; }
int MipCount { get; }
TextureDataFormat Format { get; }
/// <summary>Conservative indication that alpha coverage must be preserved.</summary>
bool HasTransparency { get; }
/// <summary>Borrow one tightly packed mip in Format encoding; do not modify its data.</summary>
ArraySegment<byte> GetMipData(int mip);
/// <summary>Copy or decode one mip to RGBA32 in a caller-owned buffer.</summary>
void CopyMipToRgba32(int mip, byte[] destination);
/// <summary>
/// Create a reader whose backing data remains valid after this source is disposed.
/// The texture retains the reader until Destroy; owned immutable data may be shared.
/// </summary>
ITexturePixelReader CreatePixelReader();
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 336875a34c8a40fdb3e81bea05b5db7f
@@ -1,31 +1,29 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
/// <summary>Creates graphics textures from CPU-side pixel data.</summary>
/// <summary>
/// Interface for a texture factory that creates textures.
/// </summary>
public interface ITextureFactory
{
/// <summary>Create a readable, base-only RGBA32 texture from a borrowed buffer.</summary>
/// <param name="width">Positive texture width in pixels.</param>
/// <param name="height">Positive texture height in pixels.</param>
/// <param name="rgba32DataBuffer">At least width * height * 4 bytes in RGBA order.
/// The caller may reuse the buffer after this call returns.</param>
/// <returns>The created texture, owned by the caller.</returns>
ITexture2D CreateTexture(int width, int height, byte[] rgba32DataBuffer);
/// <summary>
/// Creates a new texture with the specified width, height, and RGBA data.
/// </summary>
/// <param name="width">The width of the texture.</param>
/// <param name="height">The height of the texture.</param>
/// <param name="rgba32DataBuffer">The RGBA32 data of the texture to be read from.
/// Size should be greater than or equal to width * height * 4.</param>
/// <returns>The created texture.</returns>
public ITexture2D CreateTexture(int width, int height, byte[] rgba32DataBuffer);
/// <summary>
/// Synchronously upload a format-neutral data source using resolved creation options.
/// The caller still owns the source and may dispose it after this call returns.
/// Creates a new white texture.
/// </summary>
/// <param name="source">Borrowed pixel data and mip layout; remains caller-owned.</param>
/// <param name="options">Resolved mip, compression and CPU-readability requirements.</param>
/// <returns>The created texture, which retains any required independent pixel reader.</returns>
ITexture2D CreateTexture(ITextureDataSource source, TextureCreateOptions options);
/// <summary>Create a new white texture.</summary>
ITexture2D CreateWhiteTexture();
/// <returns>The created texture.</returns>
public ITexture2D CreateWhiteTexture();
}
}
}
@@ -1,19 +1,31 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
/// <summary>Decode a file into CPU-side data without creating graphics objects.</summary>
/// <summary>
/// Texture loader and ITexture2D creator interface.
/// The reason we have a separate Load method interface is because
/// uploading texture to GPU is single threaded (upload texture to VRAM),
/// while the loading and decoding part can run in parallel and it should
/// be thread-safe in general. This two-step approach gives caller
/// more flexibility.
/// </summary>
public interface ITextureLoader
{
/// <summary>
/// Load texture data. The caller disposes the returned source after uploading it.
/// This operation may run off the graphics thread; loaders hold no per-image state.
/// Load and decode texture data.
/// </summary>
/// <param name="data">Owned file bytes, which must not be modified after loading.</param>
/// <param name="hasAlphaChannel">Legacy material classification, independent of sampling policy.</param>
ITextureDataSource Load(byte[] data, out bool hasAlphaChannel);
/// <param name="data">Raw texture data in byte array</param>
/// <param name="hasAlphaChannel">True if texture has alpha channel</param>
public void Load(byte[] data, out bool hasAlphaChannel);
/// <summary>
/// Convert loaded data into ITexture2D instance.
/// </summary>
/// <returns>ITexture2D instance</returns>
public ITexture2D ToTexture();
}
}
}
@@ -1,14 +0,0 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
/// <summary>Owned, immutable CPU pixel data, independent of upload-buffer lifetime.</summary>
public interface ITexturePixelReader
{
/// <summary>Read an in-bounds base-level pixel in RGBA byte order.</summary>
(byte r, byte g, byte b, byte a) GetPixel(int x, int y);
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: c24ebc56cb2a45bca760e20bded1ab02
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
@@ -1,32 +0,0 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
namespace Engine.Core.Abstraction
{
public enum TextureMipMode
{
BaseOnly,
Preserve,
GenerateIfMissing,
}
/// <summary>Resolved creation requirements; contains no game-specific sampling policy.</summary>
public readonly struct TextureCreateOptions
{
public TextureMipMode Mipmaps { get; }
public bool PreferNativeCompression { get; }
public bool KeepCpuReadable { get; }
public TextureCreateOptions(TextureMipMode mipmaps, bool preferNativeCompression, bool keepCpuReadable)
{
Mipmaps = mipmaps;
PreferNativeCompression = preferNativeCompression;
KeepCpuReadable = keepCpuReadable;
}
public static TextureCreateOptions Readable => new(TextureMipMode.BaseOnly,
preferNativeCompression: false, keepCpuReadable: true);
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: e86d1e0ca8f948be888eb88254554127
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Implementation
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Implementation
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Implementation
{
@@ -1,96 +0,0 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
namespace Engine.Core.Implementation
{
using System;
using System.Buffers;
using Abstraction;
/// <summary>A base-level RGBA32 upload buffer, optionally owned by the shared array pool.</summary>
public sealed class Rgba32TextureDataSource : ITextureDataSource
{
public int Width { get; }
public int Height { get; }
public int MipCount => 1;
public TextureDataFormat Format => TextureDataFormat.Rgba32;
public bool HasTransparency { get; }
private byte[] _data;
private readonly int _length;
private readonly bool _returnToPool;
/// <summary>Borrow a buffer; the caller must keep it unchanged until upload completes.</summary>
public Rgba32TextureDataSource(int width, int height, byte[] data, bool hasTransparency = true)
: this(width, height, data, hasTransparency, returnToPool: false) { }
private Rgba32TextureDataSource(int width, int height, byte[] data,
bool hasTransparency, bool returnToPool)
{
if (width <= 0 || height <= 0) throw new ArgumentOutOfRangeException(nameof(width));
_length = checked(width * height * 4);
if (data == null || data.Length < _length) throw new ArgumentException("Incomplete RGBA32 data", nameof(data));
Width = width;
Height = height;
HasTransparency = hasTransparency;
_data = data;
_returnToPool = returnToPool;
}
/// <summary>Transfer a rented buffer to this source, which returns it on Dispose.</summary>
internal static Rgba32TextureDataSource TakePooledBuffer(int width, int height, byte[] data,
bool hasTransparency) => new(width, height, data, hasTransparency, returnToPool: true);
public ArraySegment<byte> GetMipData(int mip)
{
if (mip != 0) throw new ArgumentOutOfRangeException(nameof(mip));
if (_data == null) throw new ObjectDisposedException(nameof(Rgba32TextureDataSource));
return new ArraySegment<byte>(_data, 0, _length);
}
public void CopyMipToRgba32(int mip, byte[] destination)
{
var data = GetMipData(mip);
Buffer.BlockCopy(data.Array, data.Offset, destination, 0, data.Count);
}
public ITexturePixelReader CreatePixelReader()
{
var data = GetMipData(0);
var ownedPixels = new byte[data.Count];
Buffer.BlockCopy(data.Array, data.Offset, ownedPixels, 0, data.Count);
return new PixelReader(Width, Height, ownedPixels);
}
public void Dispose()
{
if (_data == null) return;
if (_returnToPool) ArrayPool<byte>.Shared.Return(_data);
_data = null;
}
private sealed class PixelReader : ITexturePixelReader
{
private readonly int _width;
private readonly int _height;
private readonly byte[] _pixels;
public PixelReader(int width, int height, byte[] pixels)
{
_width = width;
_height = height;
_pixels = pixels;
}
public (byte r, byte g, byte b, byte a) GetPixel(int x, int y)
{
if ((uint)x >= (uint)_width || (uint)y >= (uint)_height)
throw new ArgumentOutOfRangeException(nameof(x));
int offset = (y * _width + x) * 4;
return (_pixels[offset], _pixels[offset + 1], _pixels[offset + 2], _pixels[offset + 3]);
}
}
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: fc5fd6d3991f4cc29604a6fc6303fe36
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Implementation
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Implementation
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Implementation
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Implementation
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Implementation
{
@@ -16,12 +16,10 @@ namespace Engine.Core.Implementation
public bool IsNativeObjectDisposed => _texture2D == null;
private Texture2D _texture2D;
private ITexturePixelReader _pixelReader;
public UnityTexture2D(Texture2D texture2D, ITexturePixelReader pixelReader = null)
public UnityTexture2D(Texture2D texture2D)
{
_texture2D = texture2D;
_pixelReader = pixelReader;
}
public int Width => _texture2D.width;
@@ -40,15 +38,6 @@ namespace Engine.Core.Implementation
public (float r, float g, float b, float a) GetPixel(int x, int y)
{
if (_pixelReader != null)
{
x = _texture2D.wrapMode == TextureWrapMode.Clamp
? Mathf.Clamp(x, 0, Width - 1) : (x % Width + Width) % Width;
y = _texture2D.wrapMode == TextureWrapMode.Clamp
? Mathf.Clamp(y, 0, Height - 1) : (y % Height + Height) % Height;
var rgba = _pixelReader.GetPixel(x, y);
return (rgba.r / 255f, rgba.g / 255f, rgba.b / 255f, rgba.a / 255f);
}
Color pixel = _texture2D.GetPixel(x, y);
return (pixel.r, pixel.g, pixel.b, pixel.a);
}
@@ -75,7 +64,6 @@ namespace Engine.Core.Implementation
}
_texture2D = null;
_pixelReader = null;
}
}
}
}
@@ -1,94 +1,29 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Implementation
{
using System;
using System.Buffers;
using Abstraction;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
public sealed class UnityTextureFactory : ITextureFactory
{
public ITexture2D CreateTexture(int width, int height, byte[] rgba32DataBuffer)
{
using var source = new Rgba32TextureDataSource(width, height, rgba32DataBuffer);
return CreateTexture(source, TextureCreateOptions.Readable);
}
if (rgba32DataBuffer.Length < width * height * 4)
{
throw new ArgumentException("rgba32DataBuffer.Length < width * height * 4");
}
public ITexture2D CreateTexture(ITextureDataSource source, TextureCreateOptions options)
{
if (source == null) throw new ArgumentNullException(nameof(source));
int mipCount = options.Mipmaps switch
{
TextureMipMode.BaseOnly => 1,
TextureMipMode.Preserve or TextureMipMode.GenerateIfMissing => source.MipCount,
_ => throw new ArgumentOutOfRangeException(nameof(options)),
};
bool generateMips = options.Mipmaps == TextureMipMode.GenerateIfMissing && mipCount == 1;
GraphicsFormat format = source.Format switch
{
TextureDataFormat.Rgba32 => GraphicsFormat.R8G8B8A8_SRGB,
TextureDataFormat.Bc1 => GraphicsFormat.RGBA_DXT1_SRGB,
TextureDataFormat.Bc2 => GraphicsFormat.RGBA_DXT3_SRGB,
_ => throw new NotSupportedException($"Unsupported texture data format: {source.Format}"),
};
Texture2D texture = null;
try
{
// Native blocks cannot synthesize missing mips or serve readable sprite pixels.
bool uploadCompressed = source.Format != TextureDataFormat.Rgba32 &&
options.PreferNativeCompression && !options.KeepCpuReadable && !generateMips &&
source.Width % 4 == 0 && source.Height % 4 == 0 &&
SystemInfo.IsFormatSupported(format, GraphicsFormatUsage.Sample);
if (uploadCompressed)
{
texture = new Texture2D(source.Width, source.Height, format, mipCount, TextureCreationFlags.None);
for (int mip = 0; mip < mipCount; mip++)
{
var data = source.GetMipData(mip);
texture.SetPixelData(data.Array, mip, data.Offset);
}
texture.Apply(updateMipmaps: false, makeNoLongerReadable: true);
}
else
{
texture = new Texture2D(source.Width, source.Height, TextureFormat.RGBA32,
generateMips ? -1 : mipCount, linear: false);
byte[] rgba = source.Format == TextureDataFormat.Rgba32 ? null :
ArrayPool<byte>.Shared.Rent(checked(source.Width * source.Height * 4));
try
{
for (int mip = 0; mip < mipCount; mip++)
{
if (rgba == null)
{
var data = source.GetMipData(mip);
texture.SetPixelData(data.Array, mip, data.Offset);
}
else
{
source.CopyMipToRgba32(mip, rgba);
texture.SetPixelData(rgba, mip);
}
}
texture.Apply(updateMipmaps: generateMips, makeNoLongerReadable: !options.KeepCpuReadable);
}
finally { if (rgba != null) ArrayPool<byte>.Shared.Return(rgba); }
}
if (texture.mipmapCount > 1) texture.filterMode = FilterMode.Trilinear;
return new UnityTexture2D(texture, options.KeepCpuReadable ? null : source.CreatePixelReader());
}
catch
{
if (texture != null) UnityEngine.Object.Destroy(texture);
throw;
}
Texture2D texture = new Texture2D(width, height, TextureFormat.RGBA32, mipChain: false);
texture.LoadRawTextureData(rgba32DataBuffer);
texture.Apply(updateMipmaps: false);
return new UnityTexture2D(texture);
}
public ITexture2D CreateWhiteTexture() => new UnityTexture2D(Texture2D.whiteTexture);
}
}
}
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Core.Implementation
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Coroutine
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.DataLoader
{
@@ -1,50 +1,84 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.DataLoader
{
using System;
using System.Buffers;
using Core.Abstraction;
using Core.Implementation;
using Pal3.Core.DataReader.Bmp;
/// <summary>
/// .bmp file loader and Texture2D converter.
/// </summary>
public sealed class BmpTextureLoader : ITextureLoader
{
public ITextureDataSource Load(byte[] data, out bool hasAlphaChannel)
{
hasAlphaChannel = false;
BmpFile image = new BmpFileReader().Read(data);
int width = image.Info.AbsWidth;
int height = image.Info.AbsHeight;
private readonly ITextureFactory _textureFactory;
private BmpFile _image;
if (image.Info.Height < 0)
public BmpTextureLoader(ITextureFactory textureFactory)
{
_textureFactory = textureFactory;
}
public void Load(byte[] data, out bool hasAlphaChannel)
{
if (_image != null) throw new Exception("BMP texture already loaded");
hasAlphaChannel = false;
_image = new BmpFileReader().Read(data);
}
// Flip image if height is negative
private void FlipImage()
{
if (_image.Info.Height > 0) return;
int width = _image.Info.AbsWidth;
int height = _image.Info.AbsHeight;
for (int y = 0; y < height / 2; y++)
{
for (int y = 0; y < height / 2; y++)
for(int x = 0, o1 = y * width, o2 = (height - y - 1) * width; x < width; x++, o1++, o2++)
{
for (int x = 0, o1 = y * width, o2 = (height - y - 1) * width; x < width; x++, o1++, o2++)
(image.ImageData[o1], image.ImageData[o2]) = (image.ImageData[o2], image.ImageData[o1]);
(_image.ImageData[o1], _image.ImageData[o2]) = (_image.ImageData[o2], _image.ImageData[o1]);
}
}
byte[] rgba = ArrayPool<byte>.Shared.Rent(checked(image.ImageData.Length * 4));
_image.Info.Height = height;
}
public ITexture2D ToTexture()
{
if (_image == null) return null;
if (_image.Info.Height < 0)
{
FlipImage();
}
byte[] rawRgbaDataBuffer = ArrayPool<byte>.Shared.Rent(_image.ImageData.Length * 4);
try
{
for (int i = 0; i < image.ImageData.Length; i++)
for (int i = 0; i < _image.ImageData.Length; i++)
{
rgba[i * 4 + 0] = image.ImageData[i].B;
rgba[i * 4 + 1] = image.ImageData[i].G;
rgba[i * 4 + 2] = image.ImageData[i].R;
rgba[i * 4 + 3] = image.ImageData[i].A;
rawRgbaDataBuffer[i * 4 + 0] = _image.ImageData[i].B;
rawRgbaDataBuffer[i * 4 + 1] = _image.ImageData[i].G;
rawRgbaDataBuffer[i * 4 + 2] = _image.ImageData[i].R;
rawRgbaDataBuffer[i * 4 + 3] = _image.ImageData[i].A;
}
return Rgba32TextureDataSource.TakePooledBuffer(width, height, rgba, hasTransparency: false);
// Use the buffer instead of a new array
return _textureFactory.CreateTexture(_image.Info.AbsWidth, _image.Info.AbsHeight, rawRgbaDataBuffer);
}
catch
finally
{
ArrayPool<byte>.Shared.Return(rgba);
throw;
ArrayPool<byte>.Shared.Return(rawRgbaDataBuffer);
_image = null;
}
}
}
}
}
@@ -1,43 +0,0 @@
// ------------------------------------------------------------------------
// Copyright (c) 2026, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
namespace Engine.DataLoader
{
using System;
using Core.Abstraction;
using Pal3.Core.DataReader.Dxt;
/// <summary>Adapts validated DDS data to format-neutral texture blocks and pixel reads.</summary>
internal sealed class DxtTextureDataSource : ITextureDataSource, ITexturePixelReader
{
private readonly DxtImage _image;
public DxtTextureDataSource(DxtImage image) => _image = image;
public int Width => _image.Width;
public int Height => _image.Height;
public int MipCount => _image.MipCount;
public TextureDataFormat Format => _image.HasAlphaChannel ? TextureDataFormat.Bc2 : TextureDataFormat.Bc1;
public bool HasTransparency => _image.HasTransparency;
public ArraySegment<byte> GetMipData(int mip)
{
int offset = _image.GetOffset(mip);
int length = ((_image.GetWidth(mip) + 3) / 4) * ((_image.GetHeight(mip) + 3) / 4) *
(Format == TextureDataFormat.Bc2 ? 16 : 8);
return new ArraySegment<byte>(_image.Data, offset, length);
}
public void CopyMipToRgba32(int mip, byte[] destination) => _image.Decode(mip, destination);
// DDS bytes are owned managed data, never a pooled upload buffer. Sharing this reader
// keeps compressed blocks alive without allocating an uncompressed CPU copy.
public ITexturePixelReader CreatePixelReader() => this;
public (byte r, byte g, byte b, byte a) GetPixel(int x, int y) => _image.GetPixel(x, y);
public void Dispose() { }
}
}
@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 297f6c8fd4754f03b14fd961080d843a
@@ -1,20 +1,81 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.DataLoader
{
using Core.Abstraction;
using Pal3.Core.DataReader.Dxt;
using System;
using System.Buffers;
using System.IO;
using Core.Abstraction;
using Pal3.Core.DataReader.Dxt;
public sealed class DxtTextureLoader : ITextureLoader
{
public ITextureDataSource Load(byte[] data, out bool hasAlphaChannel)
{
var image = new DxtImage(data);
hasAlphaChannel = image.HasAlphaChannel;
return new DxtTextureDataSource(image);
}
}
/// <summary>
/// .dds file loader and Texture2D converter.
/// </summary>
public sealed class DxtTextureLoader : ITextureLoader
{
private readonly ITextureFactory _textureFactory;
private int _width;
private int _height;
private byte[] _rawRgbaDataBuffer;
public DxtTextureLoader(ITextureFactory textureFactory)
{
_textureFactory = textureFactory;
}
public void Load(byte[] data, out bool hasAlphaChannel)
{
if (_rawRgbaDataBuffer != null) throw new Exception("DXT texture already loaded");
using MemoryStream stream = new(data);
using BinaryReader headerReader = new(stream);
if (new string(headerReader.ReadChars(4)) != "DDS ")
{
throw new InvalidDataException("Not a valid DXT file");
}
DxtHeader header = DxtHeader.ReadHeader(headerReader);
_width = header.Width;
_height = header.Height;
_rawRgbaDataBuffer = ArrayPool<byte>.Shared.Rent(_width * _height * 4);
switch (header.DxtPixelFormat.Format)
{
case "DXT1":
hasAlphaChannel = false;
Dxt1Decoder.ToRgba32(data, _width, _height, _rawRgbaDataBuffer);
break;
case "DXT3":
hasAlphaChannel = true;
Dxt3Decoder.ToRgba32(data, _width, _height, _rawRgbaDataBuffer);
break;
case "DXT5":
throw new NotImplementedException("DXT5 decoder not implemented");
default:
throw new Exception($"DXT Texture format: {header.DxtPixelFormat.Format} is not supported");
}
}
public ITexture2D ToTexture()
{
if (_rawRgbaDataBuffer == null) return null;
try
{
return _textureFactory.CreateTexture(_width, _height, _rawRgbaDataBuffer);
}
finally
{
ArrayPool<byte>.Shared.Return(_rawRgbaDataBuffer);
_rawRgbaDataBuffer = null;
}
}
}
}
@@ -1,52 +1,75 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.DataLoader
{
using System;
using System.Buffers;
using Core.Abstraction;
using Core.Implementation;
using Pal3.Core.DataReader.Tga;
/// <summary>
/// .tga file loader and Texture2D converter.
/// </summary>
public sealed class TgaTextureLoader : ITextureLoader
{
public unsafe ITextureDataSource Load(byte[] data, out bool hasAlphaChannel)
private readonly ITextureFactory _textureFactory;
private short _width;
private short _height;
private byte[] _rawRgbaDataBuffer;
public TgaTextureLoader(ITextureFactory textureFactory)
{
short width;
short height;
_textureFactory = textureFactory;
}
public unsafe void Load(byte[] data, out bool hasAlphaChannel)
{
if (_rawRgbaDataBuffer != null) throw new Exception("TGA texture already loaded");
byte bitDepth;
fixed (byte* p = &data[12])
{
width = *(short*)p;
height = *(short*)(p + 2);
_width = *(short*)p;
_height = *(short*)(p + 2);
bitDepth = *(p + 4);
}
byte[] rgba = ArrayPool<byte>.Shared.Rent(checked(width * height * 4));
_rawRgbaDataBuffer = ArrayPool<byte>.Shared.Rent(_width * _height * 4);
switch (bitDepth)
{
case 24:
hasAlphaChannel = false;
TgaDecoder.Decode24BitDataToRgba32(
data, _width, _height, _rawRgbaDataBuffer);
break;
case 32:
TgaDecoder.Decode32BitDataToRgba32(
data, _width, _height, _rawRgbaDataBuffer, out hasAlphaChannel);
break;
default:
throw new Exception("TGA texture had non 32/24 bit depth");
}
}
public ITexture2D ToTexture()
{
if (_rawRgbaDataBuffer == null) return null;
try
{
switch (bitDepth)
{
case 24:
hasAlphaChannel = false;
TgaDecoder.Decode24BitDataToRgba32(data, width, height, rgba);
break;
case 32:
TgaDecoder.Decode32BitDataToRgba32(data, width, height, rgba, out hasAlphaChannel);
break;
default:
throw new Exception("TGA texture had non 32/24 bit depth");
}
return Rgba32TextureDataSource.TakePooledBuffer(width, height, rgba, hasTransparency: true);
return _textureFactory.CreateTexture(_width, _height, _rawRgbaDataBuffer);
}
catch
finally
{
ArrayPool<byte>.Shared.Return(rgba);
throw;
ArrayPool<byte>.Shared.Return(_rawRgbaDataBuffer);
_rawRgbaDataBuffer = null;
}
}
}
}
}
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Extensions
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Extensions
{
@@ -11,16 +11,8 @@ namespace Engine.Extensions
{
if (obj != null)
{
#if UNITY_EDITOR
// Model renderers are also used in isolated editor preview scenes.
if (!UnityEngine.Application.isPlaying)
{
UnityEngine.Object.DestroyImmediate(obj);
return;
}
#endif
UnityEngine.Object.Destroy(obj);
}
}
}
}
}
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Extensions
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Logging
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Navigation
{
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
namespace Engine.Navigation
{
Loaded 100 of 794 files, more files were not shown because too many files have changed in this diff. Show more