Skip to content

Commit 5bda990

Browse files
committed
Mark scene dirty only if options changed
1 parent 5f7b79c commit 5bda990

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

scripts/DllManipulator.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,33 @@ public class DllManipulatorOptions
692692
public bool mockAllNativeFunctions;
693693
public bool onlyInEditor;
694694
public bool enableInEditMode;
695+
696+
public DllManipulatorOptions CloneTo(DllManipulatorOptions other)
697+
{
698+
other.dllPathPattern = dllPathPattern;
699+
other.assemblyNames = (string[]) assemblyNames.Clone();
700+
other.loadingMode = loadingMode;
701+
other.posixDlopenFlags = posixDlopenFlags;
702+
other.threadSafe = threadSafe;
703+
other.enableCrashLogs = enableCrashLogs;
704+
other.crashLogsDir = crashLogsDir;
705+
other.crashLogsStackTrace = crashLogsStackTrace;
706+
other.mockAllNativeFunctions = mockAllNativeFunctions;
707+
other.onlyInEditor = onlyInEditor;
708+
other.enableInEditMode = enableInEditMode;
709+
710+
return other;
711+
}
712+
713+
public bool Equals(DllManipulatorOptions other)
714+
{
715+
return other.dllPathPattern == dllPathPattern && other.assemblyNames.SequenceEqual(assemblyNames) &&
716+
other.loadingMode == loadingMode && other.posixDlopenFlags == posixDlopenFlags &&
717+
other.threadSafe == threadSafe && other.enableCrashLogs == enableCrashLogs &&
718+
other.crashLogsDir == crashLogsDir && other.crashLogsStackTrace == crashLogsStackTrace &&
719+
other.mockAllNativeFunctions == mockAllNativeFunctions && other.onlyInEditor == onlyInEditor &&
720+
other.enableInEditMode == enableInEditMode;
721+
}
695722
}
696723

697724
public enum DllLoadingMode

scripts/Editor/DllManipulatorEditor.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public class DllManipulatorEditor : Editor
6363
private bool _showTargetAssemblies = true;
6464
private string[] _allKnownAssemblies = null;
6565
private DateTime _lastKnownAssembliesRefreshTime;
66+
67+
/// <summary>
68+
/// To check if the options have change in order to set the object as dirty
69+
/// </summary>
70+
private DllManipulatorOptions _prevOptions = new DllManipulatorOptions();
6671

6772
public static event Action RepaintAllEditors = delegate {};
6873

@@ -72,6 +77,11 @@ public DllManipulatorEditor()
7277
EditorApplication.playModeStateChanged += _ => Repaint();
7378
RepaintAllEditors += Repaint;
7479
}
80+
81+
private void Awake()
82+
{
83+
((DllManipulatorScript)target).Options.CloneTo(_prevOptions);
84+
}
7585

7686
public override void OnInspectorGUI()
7787
{
@@ -147,9 +157,14 @@ public override void OnInspectorGUI()
147157
EditorGUILayout.LabelField($"Initialized in: {(int)time.TotalSeconds}.{time.Milliseconds.ToString("D3")}s");
148158
}
149159

160+
// Set the target as dirty so changes can be saved, if there are changes
150161
if (GUI.changed)
151162
{
152-
EditorUtility.SetDirty(target);
163+
if (!t.Options.Equals(_prevOptions))
164+
{
165+
t.Options.CloneTo(_prevOptions);
166+
EditorUtility.SetDirty(target);
167+
}
153168
}
154169
}
155170

0 commit comments

Comments
 (0)