unityzgy/CODELY.md
ayuan9957 69641904da fix: 翻译实时更新修复 + 路径检查 + IP选择 + 地形Layer修复
- IconBase: 修复(N)后缀车辆名翻译, 添加OnDestroy取消订阅防止MissingReference
- AnserWindowCtrl: 添加LanguageChanged订阅, 障碍提示实时翻译
- PlanningPlaneCtrl: 修复路径检查Count<0改为<1, 允许单段路径
- CarAIExtendCtrl: 空wayPoints数组防护
- GameObjectCreater: 重复key用索引赋值替代Add
- NetHelper: 优先返回10.x/192.168.x局域网IP, 跳过WSL虚拟网卡
- 海岛/沙漠/丘陵: Terrain Layer设为Floor(8), NavigationStatic
- 沙漠: TerrainLayer smoothness设为0
- 新增本地化条目: 携带装备/搭载人员/装备名称/空袭/维修厂等
2026-07-31 09:30:21 +08:00

7.1 KiB
Raw Blame History

Codely Structured Memories

User

Feedback

  • [2026-07-23 10:59:26] User wants ALL UI text to translate in real-time when switching languages, including: static Text, Dropdown options, InputField placeholders, Toggle labels, popup/prompt windows, 3D text, VR controller tooltips, and operation messages. Any text that doesn't update on language switch is a bug. Why: user has tested every panel and reported missing translations repeatedly. How to apply: when adding any new UI text or popup, always use LocalizationManager.Get/Format/SetFormatted instead of raw strings. For popups with dynamic content, pass key+args (not pre-formatted string) so LanguageChanged can re-translate.
  • [2026-07-27 10:16:48] User does NOT want AI-generated terrain textures to replace existing good ones. Why: AI-generated "seamless" textures had visible seams/tiling artifacts, and user felt replacing all existing textures was unnecessary when original ones were fine. How to apply: For terrain texture optimization, keep existing textures and only adjust parameters (tileSize, smoothness, splatmap distribution, basemap distance). Only generate new textures if user explicitly asks for a specific new texture.
  • [2026-07-30 15:10:58] IconBase.SetName receives names with "(N)" suffix for duplicate vehicles (e.g. "5吨火炮拆装车(2)"). Must strip suffix, translate base name via LocalizationManager.Get(), then re-append suffix. Subscribe to LanguageChanged for real-time update. Why: user reported identical vehicles only translate first one. How to apply: any UI component displaying vehicle/equipment names must handle the "(N)" duplicate suffix pattern.

Project

  • [2026-07-23 10:59:21] User is building a multi-language localization system (Chinese/English/French/Russian) for a Unity 2019.4 military equipment repair simulation training app. Translations are stored in Assets/StreamingAssets/Localization.xml (external XML, ~470 entries). Code fallback in LocalizationManager.cs. Key patterns: SetFormatted() for format strings, InjectOperateMsgLocalized() for operation records, IconBase.SetName() wraps LocalizationManager.Get(), PromptWindowInitData has key+args constructor for real-time translation of popups.

  • [2026-07-27 12:10:20] 海岛.unity terrain: custom Custom/PuzzleTerrain shader (modified to single _MainTex), 9×9 satellite tiles stitched into MountRainier_Stitched.png (8192×8192, DXT1). PermissibleArea MeshRenderer must be disabled (False) in all terrain scenes (山地/海岛/沙漠) — the green start area is shown by UI prefab Image_startArea, NOT by the 3D TOUMING material. Enabling MeshRenderer breaks it. Tile arrangement: x=0 west→x=8 east; y=0 south→y=8 north (NO Y-flip). Terrain registered in project: SQLite AssetBundle table (Type=3), SAMap.txt (海岛=OutAssets/AB/Scenes/海岛.ab, 海岛_Map=OutAssets/Map/海岛_Map.png), localization added. NavMesh baked to Assets/Scenes/海岛/NavMesh.asset. Map images: 海岛_Map.png + 海岛_temp.png saved as JPG (RGB24, ~13MB, marker at PermissibleArea pos). Scene structure mirrors 山地 (same root objects: Directional Light, Terrain+water children, Canvas, TooltipCanvas, EventSystem, CameraPos, PermissibleArea, VRCameraPos+VRTK). StudentWaitingPanel.cs hardcoded "山地" fixed to use dynamic terrainName.

  • [2026-07-24 18:03:18] Student app (VirtualRepairClient) is at test/VirtualRepairClient_Data/. Built 2022, but DLL/resources can be hot-swapped. AB files are at StreamingAssets/OutAssets/AB/Scenes/. Student app loads scenes from AB, UI prefab from baked resources.assets. To deploy code fixes: copy Library/ScriptAssemblies/Assembly-CSharp.dll to test/VirtualRepairClient_Data/Managed/. To deploy scene fixes: rebuild AB with BuildPipeline.BuildAssetBundles and copy to both project's and student app's StreamingAssets. Dropdown options now built at runtime in StudentSub1EditorPanel.Change() to avoid dependency on prefab option order.

  • [2026-07-27 11:06:13] New terrain scene registration process (e.g. 沙漠): 1) Set AssetBundle name via AssetImporter.assetBundleName, 2) Build AB with BuildPipeline.BuildAssetBundles (output file has no .ab extension - rename to match SAMap path), 3) Add to StreamingAssets/SAMap.txt (both 沙漠=OutAssets/AB/Scenes/沙漠.ab and 沙漠_Map=OutAssets/Map/沙漠_Map.png), 4) Add to SQLite VirtualRepairSql.db table AssetBundle (Name, Type=3 for 地形, FilePath, ParentName=NULL) — use C# SqliteCommand with parameters, NOT sqlite3 CLI (CLI mangles Chinese chars), 5) Add localization entry to StreamingAssets/Localization.xml, 6) Generate map image (top-down terrain render with hillshade), 7) Copy AB + map + SAMap.txt + db + Localization.xml to test/VirtualRepairClient_Data/StreamingAssets/. Terrain dropdown reads from DBManager.Instance.GetABNames(ABType.地形).

  • [2026-07-29 09:49:08] Map images for 海岛 and 沙漠 must be 8192×8192 (matching 山地/MyDragMap expectation). Map must include the green PermissibleArea rectangle baked in (matching 山地's satellite map which naturally includes it). For 沙漠: generate from heightmap+splatmap with actual texture colors sampled via RenderTexture (not guessed). For 海岛: use satellite texture MountRainier_Stitched.png as base. PA position: mapX = worldX / terrainSize * res, mapY = worldZ / terrainSize * res (NO Y-flip). PA rotation on map: 360 - paAngle (matching UI code 360 - permissibleArea.angle).

  • [2026-07-29 16:40:45] Terrain scenes registered: 山地 (original AB, old path), 海岛 (OutAssets/AB/Scenes/海岛.ab), 沙漠 (replaced 城市), 丘陵 (replaced 平原). Database AssetBundle table Type=3 now has: 山地, 丘陵, 沙漠, 海岛. SAMap.txt has all 4 terrain AB + Map entries. Localization.xml has all 4 terrain names + map-related strings. 丘陵 terrain: 5 layers (forest ground/grass/dirt/rock/dark sand), 3 tree prototypes (poplar×2 + tree6), 2 grass details, NavMesh baked manually via Navigation window (C# API NavMeshBuilder.BuildNavMesh not available in codely bridge 1.0.73+).

  • [2026-07-30 15:09:55] Student/teacher apps are at 学员/ and 教师/ under C:\Users\27228\Desktop\0520Client\ (NOT test/). Server address config: StreamingAssets/TcpConfig/ServerAdress.txt = 10.0.0.73,8087. Machine has 2 IPv4: 10.0.0.73 (physical) + 172.20.144.1 (WSL virtual). Fixed NetHelper.GetAddressIPV4() to prefer 10.x/192.168.x over 172.x virtual adapters. Deploy DLL+XML to BOTH 教师/ and 学员/ directories.

  • [2026-07-31 09:26:47] Desert (沙漠) terrain appears too bright/yellow at runtime vs editor. Root cause: Enviro weather system ("晴") deletes Directional Light and uses its own strong sun lighting. Desert sand textures are light-colored (avg RGB ~198,164,130), so under Enviro's full sun they look washed out. Mountain (山地) looks fine because its textures are darker (green/brown). This is a visual/aesthetic difference, not a code bug. EnviroSkyRendering + EnviroPostProcessing are added at runtime by MyEnviroManager.ChangeFocus to Camera.main. Camera prefab from Resources/GOPrefab/Camera.prefab does NOT have Enviro components - they're added dynamically.

Reference