mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
Added option to disable autosave in preferences
This commit is contained in:
parent
9f09452b43
commit
2582d5aaf3
@ -201,9 +201,9 @@ namespace XNodeEditor {
|
||||
draggedOutput = null;
|
||||
draggedOutputTarget = null;
|
||||
EditorUtility.SetDirty(graph);
|
||||
AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
} else if (currentActivity == NodeActivity.DragNode) {
|
||||
AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
} else if (!IsHoveringNode) {
|
||||
// If click outside node, release field focus
|
||||
if (!isPanning) {
|
||||
@ -214,7 +214,7 @@ namespace XNodeEditor {
|
||||
EditorGUIUtility.keyboardControl = 0;
|
||||
EditorGUIUtility.hotControl = 0;
|
||||
}
|
||||
AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
// If click node header, select it.
|
||||
@ -298,7 +298,7 @@ namespace XNodeEditor {
|
||||
node.position = position;
|
||||
node.name = UnityEditor.ObjectNames.NicifyVariableName(type.ToString());
|
||||
AssetDatabase.AddObjectToAsset(node, graph);
|
||||
AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
Repaint();
|
||||
}
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ namespace XNodeEditor {
|
||||
GenericMenu contextMenu = new GenericMenu();
|
||||
contextMenu.AddItem(new GUIContent("Remove"), false, () => reroute.RemovePoint());
|
||||
contextMenu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
|
||||
AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
/// <summary> Show right-click context menu for hovered port </summary>
|
||||
@ -102,7 +102,7 @@ namespace XNodeEditor {
|
||||
GenericMenu contextMenu = new GenericMenu();
|
||||
contextMenu.AddItem(new GUIContent("Clear Connections"), false, () => hoveredPort.ClearConnections());
|
||||
contextMenu.DropDown(new Rect(Event.current.mousePosition, Vector2.zero));
|
||||
AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
/// <summary> Show right-click context menu for selected nodes </summary>
|
||||
|
||||
@ -25,6 +25,7 @@ namespace XNodeEditor {
|
||||
|
||||
public Color32 highlightColor = new Color32(255, 255, 255, 255);
|
||||
public bool gridSnap = true;
|
||||
public bool autoSave = true;
|
||||
[SerializeField] private string typeColorsData = "";
|
||||
[NonSerialized] public Dictionary<string, Color> typeColors = new Dictionary<string, Color>();
|
||||
public NoodleType noodleType = NoodleType.Curve;
|
||||
@ -73,9 +74,9 @@ namespace XNodeEditor {
|
||||
XNodeEditor.NodeGraphEditor.CustomNodeGraphEditorAttribute attrib = attribs[0] as XNodeEditor.NodeGraphEditor.CustomNodeGraphEditorAttribute;
|
||||
lastEditor = XNodeEditor.NodeEditorWindow.current.graphEditor;
|
||||
lastKey = attrib.editorPrefsKey;
|
||||
VerifyLoaded();
|
||||
} else return null;
|
||||
}
|
||||
if (!settings.ContainsKey(lastKey)) VerifyLoaded();
|
||||
return settings[lastKey];
|
||||
}
|
||||
|
||||
@ -86,6 +87,7 @@ namespace XNodeEditor {
|
||||
|
||||
NodeSettingsGUI(lastKey, settings);
|
||||
GridSettingsGUI(lastKey, settings);
|
||||
SystemSettingsGUI(lastKey, settings);
|
||||
TypeColorsGUI(lastKey, settings);
|
||||
if (GUILayout.Button(new GUIContent("Set Default", "Reset all values to default"), GUILayout.Width(120))) {
|
||||
ResetPrefs();
|
||||
@ -95,7 +97,7 @@ namespace XNodeEditor {
|
||||
private static void GridSettingsGUI(string key, Settings settings) {
|
||||
//Label
|
||||
EditorGUILayout.LabelField("Grid", EditorStyles.boldLabel);
|
||||
settings.gridSnap = EditorGUILayout.Toggle("Snap", settings.gridSnap);
|
||||
settings.gridSnap = EditorGUILayout.Toggle(new GUIContent("Snap", "Hold CTRL in editor to invert"), settings.gridSnap);
|
||||
|
||||
settings.gridLineColor = EditorGUILayout.ColorField("Color", settings.gridLineColor);
|
||||
settings.gridBgColor = EditorGUILayout.ColorField(" ", settings.gridBgColor);
|
||||
@ -107,6 +109,14 @@ namespace XNodeEditor {
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
private static void SystemSettingsGUI(string key, Settings settings) {
|
||||
//Label
|
||||
EditorGUILayout.LabelField("System", EditorStyles.boldLabel);
|
||||
settings.autoSave = EditorGUILayout.Toggle(new GUIContent("Autosave", "Disable for better editor performance"), settings.autoSave);
|
||||
if (GUI.changed) SavePrefs(key, settings);
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
private static void NodeSettingsGUI(string key, Settings settings) {
|
||||
//Label
|
||||
EditorGUILayout.LabelField("Node", EditorStyles.boldLabel);
|
||||
|
||||
@ -20,8 +20,8 @@ namespace XNodeEditor {
|
||||
private float _zoom = 1;
|
||||
|
||||
void OnFocus() {
|
||||
AssetDatabase.SaveAssets();
|
||||
current = this;
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
partial void OnEnable();
|
||||
@ -37,7 +37,7 @@ namespace XNodeEditor {
|
||||
public void Save() {
|
||||
if (AssetDatabase.Contains(graph)) {
|
||||
EditorUtility.SetDirty(graph);
|
||||
AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
} else SaveAs();
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ namespace XNodeEditor {
|
||||
if (existingGraph != null) AssetDatabase.DeleteAsset(path);
|
||||
AssetDatabase.CreateAsset(graph, path);
|
||||
EditorUtility.SetDirty(graph);
|
||||
AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ namespace XNodeEditor {
|
||||
XNode.Node node = target.CopyNode(original);
|
||||
node.name = original.name;
|
||||
AssetDatabase.AddObjectToAsset(node, target);
|
||||
AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ namespace XNodeEditor {
|
||||
public void RemoveNode(XNode.Node node) {
|
||||
UnityEngine.Object.DestroyImmediate(node, true);
|
||||
target.RemoveNode(node);
|
||||
AssetDatabase.SaveAssets();
|
||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user