Сделать Sidecar UV2 replay локальным (EditorPrefs, по умолчанию выключено) - #121
Сделать Sidecar UV2 replay локальным (EditorPrefs, по умолчанию выключено)#121SashaRX wants to merge 1 commit into
Conversation
WalkthroughРежим Sidecar UV2 больше не хранится в ChangesНастройки Sidecar UV2
Estimated code review effort: 2 (Простой) | ~10 минут Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Editor/Settings/MeshLabProjectSettings.cs`:
- Line 192: Update the reset flow around
PostprocessorDefineManager.SetEnabled(false) so its prompt and confirmation
dialog explicitly state that the setting is stored in user-level EditorPrefs and
disabling Sidecar Mode affects other projects for the same user on the machine.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 45804767-87e6-42ed-a793-83b77a44222e
📒 Files selected for processing (2)
Editor/PostprocessorDefineManager.csEditor/Settings/MeshLabProjectSettings.cs
| inst.repackPerMesh = fresh.repackPerMesh; | ||
| inst.savePath = fresh.savePath; | ||
| inst.sidecarMode = fresh.sidecarMode; | ||
| PostprocessorDefineManager.SetEnabled(false); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- target context ---'
sed -n '150,215p' Editor/Settings/MeshLabProjectSettings.cs
printf '%s\n' '--- definitions and usages ---'
rg -n -C 3 'class PostprocessorDefineManager|SetEnabled\(|Sidecar Mode|Sidecar mode|Reset every Mesh Lab project setting|ResetToDefaults' .Repository: SashaRX/UnityMeshLab
Length of output: 10399
🌐 Web query:
Unity EditorPrefs stores preferences per user machine project scope documentation
💡 Result:
In Unity, the EditorPrefs class is used to store and access user-specific Editor preferences that are scoped to the local machine, not to a specific project [1][2][3]. Key characteristics of EditorPrefs include: Scope and Persistence: - Machine Scope: EditorPrefs store settings that persist across all projects on a specific local machine [2][4]. They are not saved within the project folder or shared via version control [2][4]. - Storage Location: On Windows, these are stored in the registry under HKEY_CURRENT_USER\Software\Unity Technologies\Unity Editor 5.x [1][3]. On macOS, they are stored in a.plist file in ~/Library/Preferences/ [1][3]. On Linux, they are stored in ~/.local/share/unity3d/prefs [1][3]. Distinction from Project Settings: - While EditorPrefs are personal, machine-level settings, Project Settings are intended for settings that are shared across a team [2][4]. Project Settings are stored within the project's folder structure (typically in the ProjectSettings directory) and are intended to be tracked by version control systems [2][5][4]. Implementing Project-Specific Preferences: - Because EditorPrefs are machine-wide by default, they do not inherently support project-scoped storage [6][7]. To associate EditorPrefs with a specific project, developers often manually prepend a project-specific identifier (such as a hash of the project's path or a unique project ID) to the preference key [6][7]. Alternatively, for project-scoped settings, developers typically use files stored within the project’s Assets or ProjectSettings folders (such as ScriptableObjects or JSON files), or utilize the Settings Manager package to handle project-specific repositories [5][7][8].
Citations:
- 1: https://docs.unity3d.com/2022.3/Documentation/ScriptReference/EditorPrefs.html
- 2: https://docs.unity3d.com/6/Documentation/Manual/editor-settings-reference.html
- 3: https://docs.unity3d.com/ScriptReference/EditorPrefs.html
- 4: https://docs.unity3d.com/Manual/editor-settings-reference.html
- 5: https://docs.unity3d.com/Packages/com.unity.settings-manager@2.1/manual/index.html
- 6: https://discussions.unity.com/t/project-preferences-what-should-i-use-as-project-id/77480
- 7: https://discussions.unity.com/t/how-should-i-save-preferences-data-for-a-package/846011
- 8: https://docs.unity3d.com/Packages/com.unity.settings-manager@1.0/manual/index.html
🏁 Script executed:
#!/bin/bash
set -e
python3 - <<'PY'
from pathlib import Path
settings = Path("Editor/Settings/MeshLabProjectSettings.cs").read_text()
manager = Path("Editor/PostprocessorDefineManager.cs").read_text()
checks = {
"reset calls SetEnabled(false)": "PostprocessorDefineManager.SetEnabled(false);" in settings,
"SetEnabled writes EditorPrefs": "EditorPrefs.SetBool(PrefKey, enabled);" in manager,
"shared preference key": 'const string PrefKey = "LightmapUvTool.SidecarUv2Mode";' in manager,
"tooltip calls it a project setting": "Reset every Mesh Lab project setting" in settings,
"dialog calls it a project setting": "Reset every project setting" in settings,
}
for name, result in checks.items():
print(f"{name}: {result}")
PYRepository: SashaRX/UnityMeshLab
Length of output: 339
Уточните область действия сброса.
PostprocessorDefineManager.SetEnabled(false) записывает пользовательский EditorPrefs. Поэтому сброс в одном проекте отключает Sidecar Mode в других проектах того же пользователя на этой машине. Обновите подсказку и диалог, чтобы явно указать эту область действия.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Editor/Settings/MeshLabProjectSettings.cs` at line 192, Update the reset flow
around PostprocessorDefineManager.SetEnabled(false) so its prompt and
confirmation dialog explicitly state that the setting is stored in user-level
EditorPrefs and disabling Sidecar Mode affects other projects for the same user
on the machine.
|
Закрыт без применения: PR отключает sidecar replay по умолчанию (per-user EditorPrefs) вместо валидации данных; вместо этого приняты валидационные фиксы #126/#139/#151/#189. Generated by Claude Code |
Motivation
MeshLabSettings.assetмог навязать автоматическую воспроизводимость sidecar-файлов при импорте моделей и тем самым позволял злоумышленнику управлять поведением импортера.Description
Editor/PostprocessorDefineManager.csтеперь читает и пишет локальнуюEditorPrefsс ключомLightmapUvTool.SidecarUv2ModeчерезEditorPrefs.GetBool/SetBool, по умолчаниюfalse, вместо обращения кMeshLabProjectSettings.Instance.sidecarMode.sidecarModeизEditor/Settings/MeshLabProjectSettings.cs, и UI-переключатель в настройках проекта теперь отображает и меняет локальную настройку черезPostprocessorDefineManager, с явной подсказкой, что значение хранится локально вEditorPrefs.ResetToDefaults()проектных настроек локальный флаг реплея явно сбрасывается вfalseчерезPostprocessorDefineManager.SetEnabled(false).Editor/PostprocessorDefineManager.csиEditor/Settings/MeshLabProjectSettings.cs.Testing
python3-snippet) который подтвердил, чтоPostprocessorDefineManagerиспользуетEditorPrefs, значение по умолчанию —false, и что полеpublic bool sidecarModeудалено из проектных настроек, и проверка прошла успешно.rg/поиск по коду иgit diff --checkдля валидации правок и обнаружения остаточных вхождений, и они не выявили проблем; проверки завершились успешно.Codex Task
Summary by CodeRabbit