同步主站 Cocos 当前工程:关卡资源、运行脚本与打包工具。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -238,6 +238,22 @@ HUD_GLOBS = (
|
||||
)
|
||||
|
||||
|
||||
def upscale_hud_png(path: Path, scale: int = 4) -> None:
|
||||
"""把低分辨率 HUD 圆钮放大,避免 100px 原图在 HUD/预览里发糊。"""
|
||||
try:
|
||||
from PIL import Image, ImageFilter, ImageEnhance
|
||||
except ImportError:
|
||||
return
|
||||
im = Image.open(path).convert("RGBA")
|
||||
w, h = im.size
|
||||
if w >= 300 and h >= 300:
|
||||
return
|
||||
hd = im.resize((w * scale, h * scale), Image.Resampling.LANCZOS)
|
||||
hd = hd.filter(ImageFilter.UnsharpMask(radius=1.8, percent=140, threshold=1))
|
||||
hd = ImageEnhance.Contrast(hd).enhance(1.04)
|
||||
hd.save(path, format="PNG", optimize=True)
|
||||
|
||||
|
||||
def copy_hud_assets(unity_tex: Path, out_root: Path, style_key: str, rel: str) -> int:
|
||||
"""拷贝 Unity UI 按钮贴图(原先 rglob 会跳过 anniu_/倍速/声音)"""
|
||||
src = unity_tex if rel == "." else unity_tex / rel
|
||||
@@ -257,6 +273,8 @@ def copy_hud_assets(unity_tex: Path, out_root: Path, style_key: str, rel: str) -
|
||||
seen.add(key)
|
||||
target = dst / png.name
|
||||
shutil.copy2(png, target)
|
||||
if style_key == "numMan" and png.name in ("anniu_03.png", "anniu_17.png", "anniu_19.png"):
|
||||
upscale_hud_png(target)
|
||||
count += 1
|
||||
return count
|
||||
|
||||
@@ -303,6 +321,18 @@ def copy_theme(unity_tex: Path, out_root: Path, style_key: str, rel: str) -> int
|
||||
return count
|
||||
|
||||
|
||||
def copy_direction_gizmo(unity_tex: Path, out_root: Path) -> int:
|
||||
"""生成灰色等距罗盘(不直接拷 Unity 像素图)。"""
|
||||
import sys
|
||||
tools_dir = Path(__file__).resolve().parent
|
||||
if str(tools_dir) not in sys.path:
|
||||
sys.path.insert(0, str(tools_dir))
|
||||
from make_direction_gizmo import write as write_direction_gizmo
|
||||
dst = out_root / "ui" / "ui-direction.png"
|
||||
write_direction_gizmo(dst)
|
||||
return 1
|
||||
|
||||
|
||||
def copy_prop(unity_tex: Path, out_root: Path) -> int:
|
||||
src = unity_tex / "Prop"
|
||||
if not src.is_dir():
|
||||
@@ -347,6 +377,11 @@ def main():
|
||||
print(f" prop: {pn} png")
|
||||
total += pn
|
||||
|
||||
dn = copy_direction_gizmo(unity_tex, out_root)
|
||||
if dn:
|
||||
print(f" ui-direction: {dn} png")
|
||||
total += dn
|
||||
|
||||
print(f"Imported {total} files -> {out_root}")
|
||||
print("请在 Cocos Creator 中刷新 assets/resources/textures,然后运行:")
|
||||
print(" python3 tools/fix_tile_texture_metas.py")
|
||||
|
||||
Reference in New Issue
Block a user