Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Editor/PostprocessorDefineManager.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
// PostprocessorDefineManager.cs — sidecar replay toggle.
// Storage now lives in MeshLabProjectSettings (per-project, committed).
// Storage is a per-user opt-in so an untrusted project cannot enable replay.
// This class is kept as a thin shim so existing call sites don't need changes.

using UnityEditor;

namespace SashaRX.UnityMeshLab
{
static class PostprocessorDefineManager
{
const string PrefKey = "LightmapUvTool.SidecarUv2Mode";

internal static bool IsEnabled()
{
return MeshLabProjectSettings.Instance.sidecarMode;
return EditorPrefs.GetBool(PrefKey, false);
}

internal static void SetEnabled(bool enabled)
{
MeshLabProjectSettings.Instance.sidecarMode = enabled;
MeshLabProjectSettings.Save();
EditorPrefs.SetBool(PrefKey, enabled);
}
}
}
15 changes: 9 additions & 6 deletions Editor/Settings/MeshLabProjectSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ class MeshLabProjectSettings : ScriptableObject
// ── Output ──
public string savePath = "Assets/LightmapUvTool_Output";

// ── UV2 pipeline ──
public bool sidecarMode;

// ── Vertex AO defaults ──
public int aoChannelType; // 0=VertexColor, 1-5=UV0-UV4
public int aoChannelComp; // 0=R/X, 1=G/Y, 2=B, 3=A
Expand Down Expand Up @@ -115,8 +112,14 @@ static void OnGUI(string searchContext)

EditorGUILayout.Space(12);
EditorGUILayout.LabelField("UV2 Pipeline", EditorStyles.boldLabel);
inst.sidecarMode = EditorGUILayout.Toggle("Sidecar UV2 Mode", inst.sidecarMode);
if (!inst.sidecarMode)
bool sidecarMode = PostprocessorDefineManager.IsEnabled();
bool requestedSidecarMode = EditorGUILayout.Toggle(
new GUIContent("Sidecar UV2 Mode",
"Stored as a local Editor preference. Projects cannot enable persistent replay."),
sidecarMode);
if (requestedSidecarMode != sidecarMode)
PostprocessorDefineManager.SetEnabled(requestedSidecarMode);
if (!requestedSidecarMode)
EditorGUILayout.HelpBox(
"Persistent replay is OFF. FBX overwrite will use one-shot replay only.",
MessageType.None);
Expand Down Expand Up @@ -186,7 +189,7 @@ static void ResetToDefaults()
inst.borderPaddingPx = fresh.borderPaddingPx;
inst.repackPerMesh = fresh.repackPerMesh;
inst.savePath = fresh.savePath;
inst.sidecarMode = fresh.sidecarMode;
PostprocessorDefineManager.SetEnabled(false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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:


🏁 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}")
PY

Repository: 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.

inst.aoChannelType = fresh.aoChannelType;
inst.aoChannelComp = fresh.aoChannelComp;
inst.showDebugUI = fresh.showDebugUI;
Expand Down
Loading