unityzgy/CODELY.md
ayuan9957 a57981ea2e fix: 山地改名林地 + 想定深拷贝 + 翻译修复
- 山地→林地: 场景/AB/数据库/SAMap/本地化/旧想定XML全部改名
- 想定编辑: 深拷贝selectRecord防止引用污染, 设置地形下拉框匹配原文件
- 想定下发: 深拷贝后发送独立副本
- XmlHelper: FileStream改using, 新增字符串反序列化重载
- RecordDetailPanel: OnStart重新订阅LanguageChanged, 完整翻译标题/用时/视频/操作记录
- AppraiseWindowBase: OnLanguageChanged重新翻译标题+操作记录
- LocalizeOperateMsg: 旧消息回退Get()翻译
- 分组提示: ShowSetGroupError用Get()翻译, 新增4条分组错误翻译
- 学员端地形名: SetFormatted+DisplayName实时翻译
- 丘陵: 重新生成地图含道路材质, 重建AB
2026-07-31 17:58:41 +08:00

9.0 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.
  • [2026-07-31 10:44:19] When editing 想定文件 (scenario files) in teacher panel, MUST deep-copy selectRecord before passing to editor panel. Why: selectRecord is a reference type; passing it directly means edits modify the original object, polluting subsequent file selections and subject dispatches. How to apply: In TeacherMainPanel.EditorFile(), serialize→deserialize selectRecord to create independent copy before passing to Subject1EditorCtrl/Subject2EditorCtrl.Change().
  • [2026-07-31 11:27:02] Old operation messages recorded before localization system (pre-InjectOperateMsgLocalized) lack the \x01 prefix. LocalizeOperateMsg now falls back to Get() for non-prefixed messages so they translate if the key exists in Localization.xml. Why: user reported history detail panel showing Chinese after language switch. How to apply: any old stored text that should translate but wasn't recorded with InjectOperateMsgLocalized will now attempt Get() translation as fallback.
  • [2026-07-31 15:49:27] BasePanel is NOT a MonoBehaviour — Unity's OnEnable/OnDisable are NOT called. Must use BasePanel's own virtual methods: OnStart() (called every Push), OnDisable() (called when covered), OnDestroy() (called on Pop). For LanguageChanged subscription in BasePanel subclasses, subscribe in InitEvent() (first time only) + OnStart() (every Push), unsubscribe in OnDisable() + OnDestroy(). Why: RecordDetailPanel lost translation subscription after Pop→Push cycle because InitEvent only runs once and Unity lifecycle methods don't fire on non-MonoBehaviour classes.

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.

  • [2026-07-31 10:44:15] Terrain names finalized: 山地 renamed to 林地 (Forest/Forêt/Лес). Scene file: Assets/Scenes/林地.unity (was 山地.unity), NavMesh folder: Assets/Scenes/林地/, AB name: 林地, DB Name: 林地. All 4 terrains: 林地, 丘陵, 沙漠, 海岛. Old names (山地/平原/城市) completely removed from DB, SAMap, Localization.

Reference