mirror of
https://github.com/Siccity/xNode.git
synced 2026-03-26 22:49:02 +08:00
Fix SceneGraphs in Prefabs
Allow SceneGraphs to save to prefab assets if contained in one.
This commit is contained in:
parent
a1cf78d3fb
commit
f58d2bb392
@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEditor.Experimental.SceneManagement;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using XNodeEditor.Internal;
|
using XNodeEditor.Internal;
|
||||||
|
|
||||||
@ -227,18 +228,18 @@ namespace XNodeEditor {
|
|||||||
draggedOutput = null;
|
draggedOutput = null;
|
||||||
draggedOutputTarget = null;
|
draggedOutputTarget = null;
|
||||||
EditorUtility.SetDirty(graph);
|
EditorUtility.SetDirty(graph);
|
||||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
if (NodeEditorPreferences.GetSettings().autoSave) SaveAssets();
|
||||||
} else if (currentActivity == NodeActivity.DragNode) {
|
} else if (currentActivity == NodeActivity.DragNode) {
|
||||||
IEnumerable<XNode.Node> nodes = Selection.objects.Where(x => x is XNode.Node).Select(x => x as XNode.Node);
|
IEnumerable<XNode.Node> nodes = Selection.objects.Where(x => x is XNode.Node).Select(x => x as XNode.Node);
|
||||||
foreach (XNode.Node node in nodes) EditorUtility.SetDirty(node);
|
foreach (XNode.Node node in nodes) EditorUtility.SetDirty(node);
|
||||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
if (NodeEditorPreferences.GetSettings().autoSave) SaveAssets();
|
||||||
} else if (!IsHoveringNode) {
|
} else if (!IsHoveringNode) {
|
||||||
// If click outside node, release field focus
|
// If click outside node, release field focus
|
||||||
if (!isPanning) {
|
if (!isPanning) {
|
||||||
EditorGUI.FocusTextInControl(null);
|
EditorGUI.FocusTextInControl(null);
|
||||||
EditorGUIUtility.editingTextField = false;
|
EditorGUIUtility.editingTextField = false;
|
||||||
}
|
}
|
||||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
if (NodeEditorPreferences.GetSettings().autoSave) SaveAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If click node header, select it.
|
// If click node header, select it.
|
||||||
@ -543,5 +544,12 @@ namespace XNodeEditor {
|
|||||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||||
autoConnectOutput = null;
|
autoConnectOutput = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Save assets normally or to prefab is contained in one </summary>
|
||||||
|
private void SaveAssets(){
|
||||||
|
PrefabStage prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
|
||||||
|
if (prefabStage == null) AssetDatabase.SaveAssets();
|
||||||
|
else AssetDatabase.AddObjectToAsset(graph,prefabStage.prefabAssetPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user