Skip to content

Commit

Permalink
feat: show dialog after changing InstanceHandling to warn against los…
Browse files Browse the repository at this point in the history
…t changes (#729)

* Adding dialog to warn user that they may lose changes.

* Giving user the option to never show the warning again.

* Save setting per session, not machine
  • Loading branch information
schinkowski authored Jul 28, 2022
1 parent c0ba54e commit e754e3c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Editor/Scripts/MeshSyncServerInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Unity.MeshSync.Editor {
[CustomEditor(typeof(MeshSyncServer))]
[InitializeOnLoad]
internal class MeshSyncServerInspector : BaseMeshSyncInspector {
private const string OPT_OUT_INSTANCE_HANDLING = "MeshSync.InstanceHandling.OptOut";

//----------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -87,14 +88,20 @@ public void DrawServerSettings(MeshSyncServer t)
}
}

private void DrawInstanceSettings(MeshSyncServer t)
{
private void DrawInstanceSettings(MeshSyncServer t) {
var style = EditorStyles.foldout;
style.fontStyle = FontStyle.Bold;
style.fontStyle = FontStyle.Bold;
t.foldInstanceSettings = EditorGUILayout.Foldout(t.foldInstanceSettings, "Instances", true, style);
if (t.foldInstanceSettings)
{
t.InstanceHandling = (BaseMeshSync.InstanceHandlingType)EditorGUILayout.EnumPopup("Instance handling", t.InstanceHandling);
if (t.foldInstanceSettings) {
var newInstanceHandling =
(BaseMeshSync.InstanceHandlingType)EditorGUILayout.EnumPopup("Instance handling", t.InstanceHandling);

if (t.InstanceHandling != newInstanceHandling &&
EditorUtility.DisplayDialog("Warning",
"Changing the instance handling mode will delete any prefabs and previously synced objects for this server. Are you sure you want to do this?",
"Yes", "No", DialogOptOutDecisionType.ForThisSession, OPT_OUT_INSTANCE_HANDLING)) {
t.InstanceHandling = newInstanceHandling;
}

DrawPrefabListElement(t);
}
Expand Down

0 comments on commit e754e3c

Please sign in to comment.