using UnityEngine; using UnityEngine.Tilemaps; namespace Platformer.Mechanics { /// /// 게임 시작 시 프레임·렌더·물리 영역 기본 최적화 + One-Way Platform 자동 적용. /// PD 지시 2026-05-07 — 스크롤 버벅임 보완 + 점프·이동 시 지형 통과(One-Way Platform). /// public static class GameOptimizer { [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] static void Init() { Application.targetFrameRate = 60; QualitySettings.vSyncCount = 0; Time.fixedDeltaTime = 1f / 60f; // BT5-Dev #34 — Layer Matrix 영역 = Player(13) ↔ Enemy(14)만 OFF. JumpThrough Layer 8 영역 폐기. // OneWay = PlatformEffector2D 영역 표준 패턴 활용 (Layer Matrix 폐기) Physics2D.IgnoreLayerCollision(13, 14, true); Debug.Log($"[BT34-LayerSep] Player(13) ↔ Enemy(14) collision OFF (Layer 8 영역 폐기·PlatformEffector2D 영역 활용)"); } /// /// BT5-Dev #27 — PD 제안: Layer 8(JumpThrough) + Raycast 동적 충돌. /// PlatformEffector2D 폐기. 모든 일반 BoxCollider2D를 Layer 8로 변환 → 기본 통과 + Player 발 Raycast 시점만 충돌 활성. /// 제외: Tilemap·Player·Enemy·DeathZone·VictoryZone·TokenInstance·AttackHitbox·Trigger Collider. /// [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] static void SetupJumpThroughPlatforms() { // BT5-Dev #44 — 일반 지면(Level Tilemap) Layer 0 일반 충돌 + 공중 발판(Foreground·별개 BoxCollider2D)만 Layer 16 int applied = 0, excluded = 0, levelKept = 0; var allColliders = Object.FindObjectsByType(FindObjectsSortMode.None); var appliedNames = new System.Collections.Generic.List(); foreach (var c in allColliders) { if (c == null) continue; if (c.isTrigger) { excluded++; continue; } if (c.GetComponent() != null || c.GetComponent() != null || c.GetComponent() != null || c.GetComponent() != null || c.GetComponent() != null || c.GetComponent() != null) { excluded++; continue; } // BT44 — Level Tilemap (TilemapCollider2D) = 일반 지면 Layer 0 그대로 (Drop-Through 영역 외) if (c.GetComponent() != null && c.gameObject.name == "Level") { if (c.gameObject.layer == 16) c.gameObject.layer = 0; // BT38·BT40·BT43 잔존 복원 levelKept++; continue; } var effector = c.GetComponent(); if (effector != null) Object.Destroy(effector); c.usedByEffector = false; c.gameObject.layer = 16; applied++; if (appliedNames.Count < 8) appliedNames.Add($"{c.gameObject.name}({c.GetType().Name})"); } // BT44 — Foreground GameObject(시각만·Collider 미부착) → TilemapCollider2D 동적 추가 + Layer 16 (공중 발판) var foreground = GameObject.Find("Foreground"); if (foreground != null) { var fgTc = foreground.GetComponent(); if (fgTc == null) fgTc = foreground.AddComponent(); foreground.layer = 16; Debug.Log($"[BT44-Foreground] TilemapCollider2D + Layer 16 applied to 'Foreground'"); } Debug.Log($"[BT44-DropThrough] Layer16 applied={applied} levelKeptLayer0={levelKept} excluded={excluded} total={allColliders.Length}"); Debug.Log($"[BT44-DropThrough] appliedSamples=[{string.Join(", ", appliedNames)}]"); } } }